Changeset f5bca2
- Timestamp:
- Dec 4, 2010, 11:56:28 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 9c5296
- Parents:
- 742371
- git-author:
- Frederik Heber <heber@…> (11/22/10 11:10:57)
- git-committer:
- Frederik Heber <heber@…> (12/04/10 23:56:28)
- Location:
- src/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/SubspaceFactorizerUnittest.cpp
r742371 rf5bca2 45 45 46 46 void SubspaceFactorizerUnittest::setUp(){ 47 fourbyfour = new MatrixContent(4,4); 48 fourbyfour->setZero(); 49 for (int i=0; i<4 ; i++) { 50 fourbyfour->set(i,i, 2.); 51 if (i < (4-1)) { 52 fourbyfour->set(i+1,i, 1.); 53 fourbyfour->set(i,i+1, 1.); 54 } 55 } 56 transformation = new MatrixContent**[3]; 57 58 // 1d subspace 59 transformation[0] = new MatrixContent*[4]; 60 for(size_t i=0; i<4;++i) { 61 transformation[0][i] = new MatrixContent(4,4); 62 transformation[0][i]->setZero(); 63 for (size_t j=0; j<1; ++j) 64 transformation[0][i]->set(i+j,i+j, 1.); 65 // std::cout << i << "th transformation matrix, " << 1 << "d subspace is " 66 // << *transformation[0][i] << std::endl; 67 } 68 69 // 2d subspace 70 transformation[1] = new MatrixContent*[3]; 71 for(size_t i=0; i<3;++i) { 72 transformation[1][i] = new MatrixContent(4,4); 73 transformation[1][i]->setZero(); 74 for (size_t j=0; j<2; ++j) 75 transformation[1][i]->set(i+j,i+j, 1.); 76 // std::cout << i << "th transformation matrix, " << 2 << "d subspace is " 77 // << *transformation[1][i] << std::endl; 78 } 79 80 // 3d subspace 81 transformation[2] = new MatrixContent*[2]; 82 for(size_t i=0; i<2;++i) { 83 transformation[2][i] = new MatrixContent(4,4); 84 transformation[2][i]->setZero(); 85 for (size_t j=0; j<3; ++j) 86 transformation[2][i]->set(i+j,i+j, 1.); 87 // std::cout << i << "th transformation matrix, " << 3 << "d subspace is " 88 // << *transformation[2][i] << std::endl; 89 } 90 } 47 matrix = new MatrixContent(matrixdimension,matrixdimension); 48 matrix->setZero(); 49 for (int i=0; i<matrixdimension ; i++) { 50 matrix->set(i,i, 2.); 51 if (i < (matrixdimension-1)) { 52 matrix->set(i+1,i, 1.); 53 matrix->set(i,i+1, 1.); 54 } 55 } 56 } 57 91 58 void SubspaceFactorizerUnittest::tearDown(){ 92 59 // delete test matrix 93 delete fourbyfour; 94 95 // delete all transformations 96 for(size_t i=0; i<3;++i) 97 delete transformation[0][i]; 98 delete[] transformation[0]; 99 for(size_t i=0; i<3;++i) 100 delete transformation[1][i]; 101 delete[] transformation[1]; 102 for(size_t i=0; i<2;++i) 103 delete transformation[2][i]; 104 delete[] transformation[2]; 105 delete[] transformation; 60 delete matrix; 106 61 } 107 62 108 63 void SubspaceFactorizerUnittest::BlockTest() 109 64 { 110 MatrixContent temp((*fourbyfour)&(*transformation[0][0])); 111 std::cout << "Our matrix is " << *fourbyfour << "." << std::endl; 112 113 std::cout << "Hadamard product of " << *fourbyfour << " with " << *transformation[0][0] << " is: " << std::endl; 65 MatrixContent *transformation = new MatrixContent(matrixdimension,matrixdimension); 66 transformation->setZero(); 67 for (size_t j=0; j<1; ++j) 68 transformation->set(j,j, 1.); 69 70 MatrixContent temp((*matrix)&(*transformation)); 71 std::cout << "Our matrix is " << *matrix << "." << std::endl; 72 73 std::cout << "Hadamard product of " << *matrix << " with " << *transformation << " is: " << std::endl; 114 74 std::cout << temp << std::endl; 115 75 … … 120 80 delete eigenvaluesView; 121 81 gsl_vector_free(eigenvalues); 82 delete (transformation); 122 83 123 84 … … 329 290 330 291 // (for now settle with the one we are most parallel to) 331 size_t mostparallel_index = 4;292 size_t mostparallel_index = SubspaceFactorizerUnittest::matrixdimension; 332 293 double mostparallel_scalarproduct = 0.; 333 294 BOOST_FOREACH( size_t indexiter, CorrespondenceList) { … … 340 301 } 341 302 } 342 if (mostparallel_index != 4) {303 if (mostparallel_index != SubspaceFactorizerUnittest::matrixdimension) { 343 304 // put into std::list for later use 344 305 // invert if pointing in negative direction … … 358 319 VectorArray CurrentEigenvectors; 359 320 ValueArray CurrentEigenvalues; 360 VectorValueList *ParallelEigenvectorList = new VectorValueList[ 4];321 VectorValueList *ParallelEigenvectorList = new VectorValueList[matrixdimension]; 361 322 IndexSet AllIndices; 362 323 363 324 // create the total index set 364 for (size_t i=0;i< 4;++i)325 for (size_t i=0;i<matrixdimension;++i) 365 326 AllIndices.insert(i); 366 327 … … 368 329 IndexMap Dimension_to_Indexset; 369 330 for (size_t dim = 0; dim<3;++dim) { 370 for (size_t i=0;i< 4-dim;++i) {331 for (size_t i=0;i<matrixdimension;++i) { 371 332 IndexSet *indexset = new IndexSet; 372 for (size_t j=0;j<=dim;++j) { 373 //std::cout << "Putting " << i+j << " into " << i << "th map " << dim << std::endl; 374 CPPUNIT_ASSERT_MESSAGE("index "+toString(i+j)+" already present in "+toString(dim)+"-dim "+toString(i)+"th indexset.", indexset->count(i+j) == 0); 375 indexset->insert(i+j); 333 for (size_t j=0;j<dim+1;++j) { 334 const int value = (i+j) % matrixdimension; 335 //std::cout << "Putting " << value << " into " << i << "th map " << dim << std::endl; 336 CPPUNIT_ASSERT_MESSAGE("index "+toString(value)+" already present in "+toString(dim)+"-dim "+toString(i)+"th indexset.", indexset->count(value) == 0); 337 indexset->insert(value); 376 338 } 377 339 Dimension_to_Indexset.insert( make_pair(dim, boost::shared_ptr<IndexSet>(indexset)) ); … … 381 343 } 382 344 383 // set to first guess, i.e. the unit vectors of R^ 4345 // set to first guess, i.e. the unit vectors of R^matrixdimension 384 346 BOOST_FOREACH( size_t index, AllIndices) { 385 boost::shared_ptr<VectorContent> EV(new VectorContent( 4));347 boost::shared_ptr<VectorContent> EV(new VectorContent(matrixdimension)); 386 348 EV->setZero(); 387 349 EV->at(index) = 1.; … … 392 354 size_t run=1; // counting iterations 393 355 double threshold = 1.; // containing threshold value 394 while ((threshold > 1e- 6) && (run < 200)) {356 while ((threshold > 1e-10) && (run < 200)) { 395 357 // for every dimension 396 for (size_t dim = 0; dim< 3;++dim) {358 for (size_t dim = 0; dim<4;++dim) { 397 359 // for every index set of this dimension 398 360 Log() << Verbose(0) << std::endl << std::endl; … … 407 369 408 370 // create transformation matrices from these 409 MatrixContent *subsystem = getSubspaceMatrix(* fourbyfour, CurrentEigenvectors, *(IndexsetIter->second));371 MatrixContent *subsystem = getSubspaceMatrix(*matrix, CurrentEigenvectors, *(IndexsetIter->second)); 410 372 Log() << Verbose(2) << "Subsystem matrix is " << *subsystem << std::endl; 411 373 … … 415 377 Log() << Verbose(2) << "Eigenvalues are " << *Eigenvalues << std::endl; 416 378 417 // blow up eigenvectors to 4dim column vector again379 // blow up eigenvectors to matrixdimensiondim column vector again 418 380 MatrixContent *Eigenvectors = embedSubspaceMatrix(CurrentEigenvectors, *subsystem, *(IndexsetIter->second)); 419 Log() << Verbose(1) << "4x4Eigenvector matrix is " << *Eigenvectors << std::endl;381 Log() << Verbose(1) << matrixdimension << "x" << matrixdimension << " Eigenvector matrix is " << *Eigenvectors << std::endl; 420 382 421 383 // we don't need the subsystem anymore … … 488 450 } 489 451 490 // check orthonormality again491 checkOrthogonality(AllIndices, CurrentEigenvectors);452 // // check orthonormality again 453 // checkOrthogonality(AllIndices, CurrentEigenvectors); 492 454 493 455 // show new ones -
src/unittests/SubspaceFactorizerUnittest.hpp
r742371 rf5bca2 34 34 void EigenvectorTest(); 35 35 36 MatrixContent *fourbyfour; 36 enum { matrixdimension = 3 }; 37 private: 38 39 MatrixContent *matrix; 37 40 38 41 MatrixContent ***transformation;
Note:
See TracChangeset
for help on using the changeset viewer.