Changeset 29812d for src/molecules.cpp
- Timestamp:
- Sep 21, 2009, 11:48:42 AM (16 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:
- b66c22, c30180
- Parents:
- 89c8b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
r89c8b2 r29812d 6 6 7 7 #include "config.hpp" 8 #include "memoryallocator.hpp" 8 9 #include "molecules.hpp" 9 10 … … 55 56 if (ListOfBondsPerAtom != NULL) 56 57 for(int i=AtomCount;i--;) 57 Free( (void **)&ListOfBondsPerAtom[i], "molecule::~molecule: ListOfBondsPerAtom[i]");58 Free( (void **)&ListOfBondsPerAtom, "molecule::~molecule: ListOfBondsPerAtom");59 Free( (void **)&NumberOfBondsPerAtom, "molecule::~molecule: NumberOfBondsPerAtom");58 Free(&ListOfBondsPerAtom[i]); 59 Free(&ListOfBondsPerAtom); 60 Free(&NumberOfBondsPerAtom); 60 61 if (TesselStruct != NULL) 61 62 delete(TesselStruct); … … 163 164 NoNonHydrogen++; 164 165 if (pointer->Name == NULL) { 165 Free( (void **)&pointer->Name, "molecule::AddAtom: *pointer->Name");166 pointer->Name = (char *) Malloc(sizeof(char)*6, "molecule::AddAtom: *pointer->Name");166 Free(&pointer->Name); 167 pointer->Name = Malloc<char>(6, "molecule::AddAtom: *pointer->Name"); 167 168 sprintf(pointer->Name, "%2s%02d", pointer->type->symbol, pointer->nr+1); 168 169 } … … 182 183 if (pointer != NULL) { 183 184 atom *walker = new atom(pointer); 184 walker->Name = (char *) Malloc(sizeof(char)*strlen(pointer->Name)+1, "atom::atom: *Name");185 walker->Name = Malloc<char>(strlen(pointer->Name) + 1, "atom::atom: *Name"); 185 186 strcpy (walker->Name, pointer->Name); 186 187 walker->nr = last_atom++; // increase number within molecule … … 267 268 Orthovector1.MatrixMultiplication(matrix); 268 269 InBondvector.SubtractVector(&Orthovector1); // subtract just the additional translation 269 Free( (void **)&matrix, "molecule::AddHydrogenReplacementAtom: *matrix");270 Free(&matrix); 270 271 bondlength = InBondvector.Norm(); 271 272 // *out << Verbose(4) << "Corrected InBondvector is now: "; … … 1080 1081 } 1081 1082 } while (!flag); 1082 Free( (void **)&matrix, "molecule::DetermineCenter: *matrix");1083 Free(&matrix); 1083 1084 Center.Scale(1./(double)AtomCount); 1084 1085 }; … … 1339 1340 { 1340 1341 stringstream zeile1, zeile2; 1341 int *DoubleList = (int *) Malloc(Nr*sizeof(int), "PrintPermutationMap: *DoubleList");1342 int *DoubleList = Malloc<int>(Nr, "PrintPermutationMap: *DoubleList"); 1342 1343 int doubles = 0; 1343 1344 for (int i=0;i<Nr;i++) … … 1354 1355 doubles++; 1355 1356 // *out << "Found " << doubles << " Doubles." << endl; 1356 Free( (void **)&DoubleList, "PrintPermutationMap: *DoubleList");1357 Free(&DoubleList); 1357 1358 // *out << zeile1.str() << endl << zeile2.str() << endl; 1358 1359 }; … … 1388 1389 { 1389 1390 double Potential, OldPotential, OlderPotential; 1390 PermutationMap = (atom **) Malloc(AtomCount*sizeof(atom *), "molecule::MinimiseConstrainedPotential: **PermutationMap");1391 DistanceMap **DistanceList = (DistanceMap **) Malloc(AtomCount*sizeof(DistanceMap *), "molecule::MinimiseConstrainedPotential: **DistanceList");1392 DistanceMap::iterator *DistanceIterators = (DistanceMap::iterator *) Malloc(AtomCount*sizeof(DistanceMap::iterator), "molecule::MinimiseConstrainedPotential: *DistanceIterators");1393 int *DoubleList = (int *) Malloc(AtomCount*sizeof(int), "molecule::MinimiseConstrainedPotential: *DoubleList");1394 DistanceMap::iterator *StepList = (DistanceMap::iterator *) Malloc(AtomCount*sizeof(DistanceMap::iterator), "molecule::MinimiseConstrainedPotential: *StepList");1391 PermutationMap = Malloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: **PermutationMap"); 1392 DistanceMap **DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: **DistanceList"); 1393 DistanceMap::iterator *DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: *DistanceIterators"); 1394 int *DoubleList = Malloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: *DoubleList"); 1395 DistanceMap::iterator *StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: *StepList"); 1395 1396 double constants[3]; 1396 1397 int round; … … 1468 1469 } 1469 1470 *out << Verbose(1) << "done." << endl; 1470 Free( (void **)&DoubleList, "molecule::MinimiseConstrainedPotential: *DoubleList");1471 Free(&DoubleList); 1471 1472 // argument minimise the constrained potential in this injective PermutationMap 1472 1473 *out << Verbose(1) << "Argument minimising the PermutationMap, at current potential " << OldPotential << " ... " << endl; … … 1549 1550 for (int i=AtomCount; i--;) 1550 1551 DistanceList[i]->clear(); 1551 Free( (void **)&DistanceList, "molecule::MinimiseConstrainedPotential: **DistanceList");1552 Free( (void **)&DistanceIterators, "molecule::MinimiseConstrainedPotential: *DistanceIterators");1552 Free(&DistanceList); 1553 Free(&DistanceIterators); 1553 1554 return ConstrainedPotential(out, PermutationMap, startstep, endstep, constants, IsAngstroem); 1554 1555 }; … … 1647 1648 1648 1649 // store the list to single step files 1649 int *SortIndex = (int *) Malloc(AtomCount*sizeof(int), "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");1650 int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex"); 1650 1651 for (int i=AtomCount; i--; ) 1651 1652 SortIndex[i] = i; … … 1653 1654 1654 1655 // free and return 1655 Free( (void **)&PermutationMap, "molecule::MinimiseConstrainedPotential: *PermutationMap");1656 Free(&PermutationMap); 1656 1657 delete(MoleculePerStep); 1657 1658 return status; … … 1712 1713 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(out, PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 1713 1714 EvaluateConstrainedForces(out, configuration.DoConstrainedMD, 0, PermutationMap, &Force); 1714 Free( (void **)&PermutationMap, "molecule::MinimiseConstrainedPotential: *PermutationMap");1715 Free(&PermutationMap); 1715 1716 } 1716 1717 … … 2412 2413 if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it 2413 2414 NoNonHydrogen++; 2414 Free( (void **)&Walker->Name, "molecule::CountAtoms: *walker->Name");2415 Walker->Name = (char *) Malloc(sizeof(char)*6, "molecule::CountAtoms: *walker->Name");2415 Free(&Walker->Name); 2416 Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name"); 2416 2417 sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1); 2417 2418 *out << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl; … … 2624 2625 NumberCells = divisor[0]*divisor[1]*divisor[2]; 2625 2626 *out << Verbose(1) << "Allocating " << NumberCells << " cells." << endl; 2626 CellList = (molecule **) Malloc(sizeof(molecule *)*NumberCells, "molecule::CreateAdjacencyList - ** CellList");2627 CellList = Malloc<molecule*>(NumberCells, "molecule::CreateAdjacencyList - ** CellList"); 2627 2628 for (int i=NumberCells;i--;) 2628 2629 CellList[i] = NULL; … … 2706 2707 delete(CellList[i]); 2707 2708 } 2708 Free( (void **)&CellList, "molecule::CreateAdjacencyList - ** CellList");2709 Free(&CellList); 2709 2710 2710 2711 // create the adjacency list per atom … … 2771 2772 *out << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl; 2772 2773 *out << Verbose(0) << "End of CreateAdjacencyList." << endl; 2773 Free( (void **)&matrix, "molecule::CreateAdjacencyList: *matrix");2774 Free(&matrix); 2774 2775 2775 2776 }; … … 2981 2982 void molecule::CyclicStructureAnalysis(ofstream *out, class StackClass<bond *> * BackEdgeStack, int *&MinimumRingSize) 2982 2983 { 2983 atom **PredecessorList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::CyclicStructureAnalysis: **PredecessorList");2984 int *ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::CyclicStructureAnalysis: *ShortestPathList");2985 enum Shading *ColorList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::CyclicStructureAnalysis: *ColorList");2984 atom **PredecessorList = Malloc<atom*>(AtomCount, "molecule::CyclicStructureAnalysis: **PredecessorList"); 2985 int *ShortestPathList = Malloc<int>(AtomCount, "molecule::CyclicStructureAnalysis: *ShortestPathList"); 2986 enum Shading *ColorList = Malloc<enum Shading>(AtomCount, "molecule::CyclicStructureAnalysis: *ColorList"); 2986 2987 class StackClass<atom *> *BFSStack = new StackClass<atom *> (AtomCount); // will hold the current ring 2987 2988 class StackClass<atom *> *TouchedStack = new StackClass<atom *> (AtomCount); // contains all "touched" atoms (that need to be reset after BFS loop) … … 3174 3175 *out << Verbose(1) << "No rings were detected in the molecular structure." << endl; 3175 3176 3176 Free( (void **)&PredecessorList, "molecule::CyclicStructureAnalysis: **PredecessorList");3177 Free( (void **)&ShortestPathList, "molecule::CyclicStructureAnalysis: **ShortestPathList");3178 Free( (void **)&ColorList, "molecule::CyclicStructureAnalysis: **ColorList");3177 Free(&PredecessorList); 3178 Free(&ShortestPathList); 3179 Free(&ColorList); 3179 3180 delete(BFSStack); 3180 3181 }; … … 3220 3221 Walker = Walker->next; 3221 3222 if (Walker->ComponentNr != NULL) 3222 Free( (void **)&Walker->ComponentNr, "molecule::InitComponentNumbers: **Walker->ComponentNr");3223 Walker->ComponentNr = (int *) Malloc(sizeof(int)*NumberOfBondsPerAtom[Walker->nr], "molecule::InitComponentNumbers: *Walker->ComponentNr");3223 Free(&Walker->ComponentNr); 3224 Walker->ComponentNr = Malloc<int>(NumberOfBondsPerAtom[Walker->nr], "molecule::InitComponentNumbers: *Walker->ComponentNr"); 3224 3225 for (int i=NumberOfBondsPerAtom[Walker->nr];i--;) 3225 3226 Walker->ComponentNr[i] = -1; … … 3344 3345 int NumberOfFragments = 0; 3345 3346 double TEFactor; 3346 char *filename = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");3347 char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename"); 3347 3348 3348 3349 if (FragmentList == NULL) { // check list pointer … … 3356 3357 if (InputFile != NULL) { 3357 3358 // each line represents a new fragment 3358 char *buffer = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");3359 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer"); 3359 3360 // 1. parse keysets and insert into temp. graph 3360 3361 while (!InputFile.eof()) { … … 3371 3372 InputFile.close(); 3372 3373 InputFile.clear(); 3373 Free( (void **)&buffer, "molecule::ParseKeySetFile - *buffer");3374 Free(&buffer); 3374 3375 *out << Verbose(1) << "done." << endl; 3375 3376 } else { … … 3404 3405 3405 3406 // free memory 3406 Free( (void **)&filename, "molecule::ParseKeySetFile - filename");3407 Free(&filename); 3407 3408 3408 3409 return status; … … 3511 3512 stringstream filename; 3512 3513 bool status = true; 3513 char *buffer = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");3514 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer"); 3514 3515 3515 3516 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; … … 3519 3520 // allocate storage structure 3520 3521 int NonMatchNumber = 0; // will number of atoms with differing bond structure 3521 int *CurrentBonds = (int *) Malloc(sizeof(int)*8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom3522 int *CurrentBonds = Malloc<int>(8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 3522 3523 int CurrentBondsOfAtom; 3523 3524 … … 3564 3565 } else 3565 3566 *out << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl; 3566 Free( (void **)&CurrentBonds, "molecule::CheckAdjacencyFileAgainstMolecule - **CurrentBonds");3567 Free(&CurrentBonds); 3567 3568 } else { 3568 3569 *out << Verbose(1) << "Adjacency file not found." << endl; … … 3570 3571 } 3571 3572 *out << endl; 3572 Free( (void **)&buffer, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");3573 Free(&buffer); 3573 3574 3574 3575 return status; … … 3598 3599 return false; 3599 3600 // parse the EnergyPerFragment file 3600 char *buffer = (char *) Malloc(sizeof(char)*MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");3601 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer"); 3601 3602 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 3602 3603 InputFile.open(buffer, ios::in); … … 3705 3706 } 3706 3707 } 3707 Free( (void **)&buffer, "molecule::CheckOrderAtSite: *buffer");3708 Free(&buffer); 3708 3709 // pick a given number of highest values and set AtomMask 3709 3710 } else { // global increase of Bond Order … … 3757 3758 return false; 3758 3759 } 3759 SortIndex = (int *) Malloc(sizeof(int)*AtomCount, "molecule::FragmentMolecule: *SortIndex");3760 SortIndex = Malloc<int>(AtomCount, "molecule::FragmentMolecule: *SortIndex"); 3760 3761 for(int i=AtomCount;i--;) 3761 3762 SortIndex[i] = -1; … … 3831 3832 // === compare it with adjacency file === 3832 3833 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms); 3833 Free( (void **)&ListOfAtoms, "molecule::FragmentMolecule - **ListOfAtoms");3834 Free(&ListOfAtoms); 3834 3835 3835 3836 // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===== … … 3920 3921 delete(Subgraphs); 3921 3922 } 3922 Free( (void **)&FragmentList, "molecule::FragmentMolecule - **FragmentList");3923 Free(&FragmentList); 3923 3924 3924 3925 // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass ===== … … 3967 3968 *out << Verbose(1) << "Freeing bond memory" << endl; 3968 3969 delete(FragmentList); // remove bond molecule from memory 3969 Free( (void **)&SortIndex, "molecule::FragmentMolecule: *SortIndex");3970 Free(&SortIndex); 3970 3971 } else 3971 3972 *out << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl; … … 4055 4056 bool molecule::ParseOrderAtSiteFromFile(ofstream *out, char *path) 4056 4057 { 4057 unsigned char *OrderArray = (unsigned char *) Malloc(sizeof(unsigned char)*AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");4058 bool *MaxArray = (bool *) Malloc(sizeof(bool)*AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");4058 unsigned char *OrderArray = Malloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray"); 4059 bool *MaxArray = Malloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray"); 4059 4060 bool status; 4060 4061 int AtomNr, value; … … 4097 4098 status = false; 4098 4099 } 4099 Free( (void **)&OrderArray, "molecule::ParseOrderAtSiteFromFile - *OrderArray");4100 Free( (void **)&MaxArray, "molecule::ParseOrderAtSiteFromFile - *MaxArray");4100 Free(&OrderArray); 4101 Free(&MaxArray); 4101 4102 4102 4103 *out << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl; … … 4121 4122 if (ListOfBondsPerAtom != NULL) { 4122 4123 for(int i=AtomCount;i--;) 4123 Free( (void **)&ListOfBondsPerAtom[i], "molecule::CreateListOfBondsPerAtom: ListOfBondsPerAtom[i]");4124 Free( (void **)&ListOfBondsPerAtom, "molecule::CreateListOfBondsPerAtom: ListOfBondsPerAtom");4124 Free(&ListOfBondsPerAtom[i]); 4125 Free(&ListOfBondsPerAtom); 4125 4126 } 4126 4127 if (NumberOfBondsPerAtom != NULL) 4127 Free( (void **)&NumberOfBondsPerAtom, "molecule::CreateListOfBondsPerAtom: NumberOfBondsPerAtom");4128 ListOfBondsPerAtom = (bond ***) Malloc(sizeof(bond **)*AtomCount, "molecule::CreateListOfBondsPerAtom: ***ListOfBondsPerAtom");4129 NumberOfBondsPerAtom = (int *) Malloc(sizeof(int)*AtomCount, "molecule::CreateListOfBondsPerAtom: *NumberOfBondsPerAtom");4128 Free(&NumberOfBondsPerAtom); 4129 ListOfBondsPerAtom = Malloc<bond**>(AtomCount, "molecule::CreateListOfBondsPerAtom: ***ListOfBondsPerAtom"); 4130 NumberOfBondsPerAtom = Malloc<int>(AtomCount, "molecule::CreateListOfBondsPerAtom: *NumberOfBondsPerAtom"); 4130 4131 4131 4132 // reset bond counts per atom … … 4141 4142 for(int i=AtomCount;i--;) { 4142 4143 // allocate list of bonds per atom 4143 ListOfBondsPerAtom[i] = (bond **) Malloc(sizeof(bond *)*NumberOfBondsPerAtom[i], "molecule::CreateListOfBondsPerAtom: **ListOfBondsPerAtom[]");4144 ListOfBondsPerAtom[i] = Malloc<bond*>(NumberOfBondsPerAtom[i], "molecule::CreateListOfBondsPerAtom: **ListOfBondsPerAtom[]"); 4144 4145 // clear the list again, now each NumberOfBondsPerAtom marks current free field 4145 4146 NumberOfBondsPerAtom[i] = 0; … … 4183 4184 void molecule::BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem) 4184 4185 { 4185 atom **PredecessorList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::BreadthFirstSearchAdd: **PredecessorList");4186 int *ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::BreadthFirstSearchAdd: *ShortestPathList");4187 enum Shading *ColorList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::BreadthFirstSearchAdd: *ColorList");4186 atom **PredecessorList = Malloc<atom*>(AtomCount, "molecule::BreadthFirstSearchAdd: **PredecessorList"); 4187 int *ShortestPathList = Malloc<int>(AtomCount, "molecule::BreadthFirstSearchAdd: *ShortestPathList"); 4188 enum Shading *ColorList = Malloc<enum Shading>(AtomCount, "molecule::BreadthFirstSearchAdd: *ColorList"); 4188 4189 class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount); 4189 4190 atom *Walker = NULL, *OtherAtom = NULL; … … 4290 4291 *out << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl; 4291 4292 } 4292 Free( (void **)&PredecessorList, "molecule::BreadthFirstSearchAdd: **PredecessorList");4293 Free( (void **)&ShortestPathList, "molecule::BreadthFirstSearchAdd: **ShortestPathList");4294 Free( (void **)&ColorList, "molecule::BreadthFirstSearchAdd: **ColorList");4293 Free(&PredecessorList); 4294 Free(&ShortestPathList); 4295 Free(&ColorList); 4295 4296 delete(AtomStack); 4296 4297 }; … … 4309 4310 atom *Walker = NULL, *OtherAtom = NULL; 4310 4311 bool status = true; 4311 atom **ParentList = (atom **) Malloc(sizeof(atom *)*Father->AtomCount, "molecule::BuildInducedSubgraph: **ParentList");4312 atom **ParentList = Malloc<atom*>(Father->AtomCount, "molecule::BuildInducedSubgraph: **ParentList"); 4312 4313 4313 4314 *out << Verbose(2) << "Begin of BuildInducedSubgraph." << endl; … … 4348 4349 } 4349 4350 4350 Free( (void **)&ParentList, "molecule::BuildInducedSubgraph: **ParentList");4351 Free(&ParentList); 4351 4352 *out << Verbose(2) << "End of BuildInducedSubgraph." << endl; 4352 4353 return status; … … 4391 4392 { 4392 4393 atom *Runner = NULL, *FatherOfRunner = NULL, *OtherFather = NULL; 4393 atom **SonList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::StoreFragmentFromStack: **SonList");4394 atom **SonList = Malloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList"); 4394 4395 molecule *Leaf = new molecule(elemente); 4395 4396 bool LonelyFlag = false; … … 4461 4462 Leaf->CreateListOfBondsPerAtom(out); 4462 4463 //Leaflet->Leaf->ScanForPeriodicCorrection(out); 4463 Free( (void **)&SonList, "molecule::StoreFragmentFromStack: **SonList");4464 Free(&SonList); 4464 4465 // *out << Verbose(1) << "End of StoreFragmentFromKeyset." << endl; 4465 4466 return Leaf; … … 4482 4483 MoleculeListClass * molecule::CreateListOfUniqueFragmentsOfOrder(ofstream *out, int Order, config *configuration) 4483 4484 { 4484 atom **PredecessorList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: **PredecessorList");4485 int *ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ShortestPathList");4486 int *Labels = (int *) Malloc(sizeof(int)*AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *Labels");4487 enum Shading *ColorVertexList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorList");4488 enum Shading *ColorEdgeList = (enum Shading *) Malloc(sizeof(enum Shading)*BondCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorBondList");4485 atom **PredecessorList = Malloc<atom*>(AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: **PredecessorList"); 4486 int *ShortestPathList = Malloc<int>(AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ShortestPathList"); 4487 int *Labels = Malloc<int>(AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *Labels"); 4488 enum Shading *ColorVertexList = Malloc<enum Shading>(AtomCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorList"); 4489 enum Shading *ColorEdgeList = Malloc<enum Shading>(BondCount, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorBondList"); 4489 4490 StackClass<atom *> *RootStack = new StackClass<atom *>(AtomCount); 4490 4491 StackClass<atom *> *TouchedStack = new StackClass<atom *>((int)pow(4,Order)+2); // number of atoms reached from one with maximal 4 bonds plus Root itself … … 4616 4617 4617 4618 // free memory and exit 4618 Free( (void **)&PredecessorList, "molecule::CreateListOfUniqueFragmentsOfOrder: **PredecessorList");4619 Free( (void **)&ShortestPathList, "molecule::CreateListOfUniqueFragmentsOfOrder: *ShortestPathList");4620 Free( (void **)&Labels, "molecule::CreateListOfUniqueFragmentsOfOrder: *Labels");4621 Free( (void **)&ColorVertexList, "molecule::CreateListOfUniqueFragmentsOfOrder: *ColorList");4619 Free(&PredecessorList); 4620 Free(&ShortestPathList); 4621 Free(&Labels); 4622 Free(&ColorVertexList); 4622 4623 delete(RootStack); 4623 4624 delete(TouchedStack); … … 4669 4670 int Removal; 4670 4671 int SpaceLeft; 4671 int *TouchedList = (int *) Malloc(sizeof(int)*(SubOrder+1), "molecule::SPFragmentGenerator: *TouchedList");4672 int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList"); 4672 4673 bond *Binder = NULL; 4673 4674 bond **BondsList = NULL; … … 4677 4678 4678 4679 // Hier muessen von 1 bis NumberOfBondsPerAtom[Walker->nr] alle Kombinationen 4679 // von Endstuecken (aus den Bonds) hinzugef ᅵᅵgt werden und fᅵᅵr verbleibende ANOVAOrder4680 // rekursiv GraphCrawler in der n ᅵᅵchsten Ebene aufgerufen werden4680 // von Endstuecken (aus den Bonds) hinzugefuegt werden und fuer verbleibende ANOVAOrder 4681 // rekursiv GraphCrawler in der naechsten Ebene aufgerufen werden 4681 4682 4682 4683 *out << Verbose(1+verbosity) << "Begin of SPFragmentGenerator." << endl; … … 4738 4739 } 4739 4740 // then allocate and fill the list 4740 BondsList = (bond **) Malloc(sizeof(bond *)*SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");4741 BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList"); 4741 4742 SubSetDimension = 0; 4742 4743 Binder = FragmentSearch->BondsPerSPList[2*SP]; … … 4750 4751 *out << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl; 4751 4752 SPFragmentGenerator(out, FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits); 4752 Free( (void **)&BondsList, "molecule::SPFragmentGenerator: **BondsList");4753 Free(&BondsList); 4753 4754 } 4754 4755 } else { … … 4784 4785 } 4785 4786 } 4786 Free( (void **)&TouchedList, "molecule::SPFragmentGenerator: *TouchedList");4787 Free(&TouchedList); 4787 4788 *out << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl; 4788 4789 }; … … 4962 4963 *out << Verbose(0) << "Preparing subset for this root and calling generator." << endl; 4963 4964 // prepare the subset and call the generator 4964 BondsList = (bond **) Malloc(sizeof(bond *)*FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");4965 BondsList = Malloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList"); 4965 4966 BondsList[0] = FragmentSearch.BondsPerSPList[0]->next; // on SP level 0 there's only the root bond 4966 4967 4967 4968 SPFragmentGenerator(out, &FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order); 4968 4969 4969 Free( (void **)&BondsList, "molecule::PowerSetGenerator: **BondsList");4970 Free(&BondsList); 4970 4971 } else { 4971 4972 *out << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl; … … 5021 5022 *out << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl; 5022 5023 5023 ColorList = (enum Shading *) Malloc(sizeof(enum Shading)*AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");5024 ColorList = Malloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); 5024 5025 while (flag) { 5025 5026 // remove bonds that are beyond bonddistance … … 5082 5083 // free allocated space from ReturnFullMatrixforSymmetric() 5083 5084 delete(AtomStack); 5084 Free( (void **)&ColorList, "molecule::ScanForPeriodicCorrection: *ColorList");5085 Free( (void **)&matrix, "molecule::ScanForPeriodicCorrection: *matrix");5085 Free(&ColorList); 5086 Free(&matrix); 5086 5087 *out << Verbose(2) << "End of ScanForPeriodicCorrection." << endl; 5087 5088 }; … … 5093 5094 double * molecule::ReturnFullMatrixforSymmetric(double *symm) 5094 5095 { 5095 double *matrix = (double *) Malloc(sizeof(double)*NDIM*NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");5096 double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix"); 5096 5097 matrix[0] = symm[0]; 5097 5098 matrix[1] = symm[1]; … … 5220 5221 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) 5221 5222 // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5) 5222 NumMoleculesOfOrder = (int *) Malloc(sizeof(int)*UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder");5223 FragmentLowerOrdersList = (Graph ***) Malloc(sizeof(Graph **)*UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList");5223 NumMoleculesOfOrder = Malloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder"); 5224 FragmentLowerOrdersList = Malloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList"); 5224 5225 5225 5226 // initialise the fragments structure 5226 FragmentSearch.ShortestPathList = (int *) Malloc(sizeof(int)*AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");5227 FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList"); 5227 5228 FragmentSearch.FragmentCounter = 0; 5228 5229 FragmentSearch.FragmentSet = new KeySet; … … 5259 5260 5260 5261 // initialise Order-dependent entries of UniqueFragments structure 5261 FragmentSearch.BondsPerSPList = (bond **) Malloc(sizeof(bond *)*Order*2, "molecule::PowerSetGenerator: ***BondsPerSPList");5262 FragmentSearch.BondsPerSPCount = (int *) Malloc(sizeof(int)*Order, "molecule::PowerSetGenerator: *BondsPerSPCount");5262 FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList"); 5263 FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount"); 5263 5264 for (int i=Order;i--;) { 5264 5265 FragmentSearch.BondsPerSPList[2*i] = new bond(); // start node … … 5271 5272 // allocate memory for all lower level orders in this 1D-array of ptrs 5272 5273 NumLevels = 1 << (Order-1); // (int)pow(2,Order); 5273 FragmentLowerOrdersList[RootNr] = (Graph **) Malloc(sizeof(Graph *)*NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]");5274 FragmentLowerOrdersList[RootNr] = Malloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]"); 5274 5275 for (int i=0;i<NumLevels;i++) 5275 5276 FragmentLowerOrdersList[RootNr][i] = NULL; … … 5338 5339 5339 5340 // free Order-dependent entries of UniqueFragments structure for next loop cycle 5340 Free( (void **)&FragmentSearch.BondsPerSPCount, "molecule::PowerSetGenerator: *BondsPerSPCount");5341 Free(&FragmentSearch.BondsPerSPCount); 5341 5342 for (int i=Order;i--;) { 5342 5343 delete(FragmentSearch.BondsPerSPList[2*i]); 5343 5344 delete(FragmentSearch.BondsPerSPList[2*i+1]); 5344 5345 } 5345 Free( (void **)&FragmentSearch.BondsPerSPList, "molecule::PowerSetGenerator: ***BondsPerSPList");5346 Free(&FragmentSearch.BondsPerSPList); 5346 5347 } 5347 5348 } … … 5351 5352 5352 5353 // cleanup FragmentSearch structure 5353 Free( (void **)&FragmentSearch.ShortestPathList, "molecule::PowerSetGenerator: *ShortestPathList");5354 Free(&FragmentSearch.ShortestPathList); 5354 5355 delete(FragmentSearch.FragmentSet); 5355 5356 … … 5382 5383 } 5383 5384 } 5384 Free( (void **)&FragmentLowerOrdersList[RootNr], "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]");5385 Free(&FragmentLowerOrdersList[RootNr]); 5385 5386 RootNr++; 5386 5387 } 5387 Free( (void **)&FragmentLowerOrdersList, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList");5388 Free( (void **)&NumMoleculesOfOrder, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder");5388 Free(&FragmentLowerOrdersList); 5389 Free(&NumMoleculesOfOrder); 5389 5390 5390 5391 *out << Verbose(0) << "End of FragmentBOSSANOVA." << endl; … … 5476 5477 if (result) { 5477 5478 *out << Verbose(5) << "Calculating distances" << endl; 5478 Distances = (double *) Malloc(sizeof(double)*AtomCount, "molecule::IsEqualToWithinThreshold: Distances");5479 OtherDistances = (double *) Malloc(sizeof(double)*AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");5479 Distances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances"); 5480 OtherDistances = Malloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances"); 5480 5481 Walker = start; 5481 5482 while (Walker->next != end) { … … 5491 5492 /// ... sort each list (using heapsort (o(N log N)) from GSL) 5492 5493 *out << Verbose(5) << "Sorting distances" << endl; 5493 PermMap = (size_t *) Malloc(sizeof(size_t)*AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");5494 OtherPermMap = (size_t *) Malloc(sizeof(size_t)*AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");5494 PermMap = Malloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap"); 5495 OtherPermMap = Malloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap"); 5495 5496 gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles); 5496 5497 gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles); 5497 PermutationMap = (int *) Malloc(sizeof(int)*AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");5498 PermutationMap = Malloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap"); 5498 5499 *out << Verbose(5) << "Combining Permutation Maps" << endl; 5499 5500 for(int i=AtomCount;i--;) 5500 5501 PermutationMap[PermMap[i]] = (int) OtherPermMap[i]; 5501 5502 5502 /// ... and compare them step by step, whether the difference is individ iually(!) below \a threshold for all5503 /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all 5503 5504 *out << Verbose(4) << "Comparing distances" << endl; 5504 5505 flag = 0; … … 5508 5509 flag = 1; 5509 5510 } 5510 Free((void **)&PermMap, "molecule::IsEqualToWithinThreshold: *PermMap"); 5511 Free((void **)&OtherPermMap, "molecule::IsEqualToWithinThreshold: *OtherPermMap");5512 5513 /// free memory5514 Free( (void **)&Distances, "molecule::IsEqualToWithinThreshold: Distances");5515 Free( (void **)&OtherDistances, "molecule::IsEqualToWithinThreshold: OtherDistances");5511 5512 // free memory 5513 Free(&PermMap); 5514 Free(&OtherPermMap); 5515 Free(&Distances); 5516 Free(&OtherDistances); 5516 5517 if (flag) { // if not equal 5517 Free( (void **)&PermutationMap, "molecule::IsEqualToWithinThreshold: *PermutationMap");5518 Free(&PermutationMap); 5518 5519 result = false; 5519 5520 } … … 5541 5542 atom *Walker = NULL, *OtherWalker = NULL; 5542 5543 *out << Verbose(3) << "Begin of GetFatherAtomicMap." << endl; 5543 int *AtomicMap = (int *) Malloc(sizeof(int)*AtomCount, "molecule::GetAtomicMap: *AtomicMap"); //Calloc5544 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap"); 5544 5545 for (int i=AtomCount;i--;) 5545 5546 AtomicMap[i] = -1;
Note:
See TracChangeset
for help on using the changeset viewer.