whitespace cleanup: replace tabs and remove trailing whitespace

This commit is contained in:
Axel Kohlmeyer
2020-07-27 17:14:53 -04:00
parent 41535d8de3
commit 634f274a04
27 changed files with 1150 additions and 1150 deletions

View File

@ -80,7 +80,7 @@ const Complex cerfc_continued_fraction( const Complex z )
C = z + a/C ; C = z + a/C ;
if (D.real() == 0.0 && D.imag() == 0.0) if (D.real() == 0.0 && D.imag() == 0.0)
D = tiny ; D = tiny ;
D = 1.0 / D ; D = 1.0 / D ;

View File

@ -2,9 +2,9 @@
* *
* Copyright (c), Ilya Valuev 2006 All Rights Reserved. * Copyright (c), Ilya Valuev 2006 All Rights Reserved.
* *
* Author : Ilya Valuev, MIPT, Moscow, Russia * Author : Ilya Valuev, MIPT, Moscow, Russia
* *
* Project : ivutils * Project : ivutils
* *
*****************************************************************************/ *****************************************************************************/
/*s**************************************************************************** /*s****************************************************************************

View File

@ -2,9 +2,9 @@
* *
* Copyright (c), Ilya Valuev 2005 All Rights Reserved. * Copyright (c), Ilya Valuev 2005 All Rights Reserved.
* *
* Author : Ilya Valuev, MIPT, Moscow, Russia * Author : Ilya Valuev, MIPT, Moscow, Russia
* *
* Project : GridMD, ivutils * Project : GridMD, ivutils
* *
*****************************************************************************/ *****************************************************************************/

View File

@ -77,7 +77,7 @@ void ArithmeticPathBase<element_type, scalar_type, path_type>::computeValue() {
exponent_tmp += weights[j_elem] * frame_element_distances[i_frame][j_elem] * weights[j_elem] * frame_element_distances[i_frame][j_elem]; exponent_tmp += weights[j_elem] * frame_element_distances[i_frame][j_elem] * weights[j_elem] * frame_element_distances[i_frame][j_elem];
} }
exponent_tmp = exponent_tmp * -1.0 * lambda; exponent_tmp = exponent_tmp * -1.0 * lambda;
// prevent underflow if the argument of cvm::exp is less than -708.4 // prevent underflow if the argument of cvm::exp is less than -708.4
if (exponent_tmp > -708.4) { if (exponent_tmp > -708.4) {
exponent_tmp = cvm::exp(exponent_tmp); exponent_tmp = cvm::exp(exponent_tmp);
} else { } else {

View File

@ -210,7 +210,7 @@ public:
/// parameters from another grid, but doesn't reallocate stuff; /// parameters from another grid, but doesn't reallocate stuff;
/// setup() must be called after that; /// setup() must be called after that;
colvar_grid(colvar_grid<T> const &g) : colvarparse(), colvar_grid(colvar_grid<T> const &g) : colvarparse(),
nd(g.nd), nd(g.nd),
nx(g.nx), nx(g.nx),
mult(g.mult), mult(g.mult),
data(), data(),

View File

@ -76,7 +76,7 @@ extern "C" {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
DLL_MAPPING DLL_MAPPING
void CUTIL_API void CUTIL_API
cutFree( void* ptr); cutFree( void* ptr);
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
//! Helper for bank conflict checking (should only be used with the //! Helper for bank conflict checking (should only be used with the

View File

@ -65,7 +65,7 @@ static void MPI_Allreduce(const void *in, void *out, int, MPI_Datatype type,
if (type == MPI_INT) *((int *) out) = *((int *) in); if (type == MPI_INT) *((int *) out) = *((int *) in);
} }
static void MPI_Scan(const void *in, void *out, int, MPI_Datatype intype, static void MPI_Scan(const void *in, void *out, int, MPI_Datatype intype,
MPI_Op op,MPI_Comm) MPI_Op op,MPI_Comm)
{ {
if (intype == MPI_INT) *((int *) out) = *((int *) in); if (intype == MPI_INT) *((int *) out) = *((int *) in);
} }

View File

@ -21,54 +21,54 @@
#include "poemslist.h" #include "poemslist.h"
struct ChildRingData { struct ChildRingData {
List<int> * childRing; List<int> * childRing;
int entranceNodeId; int entranceNodeId;
}; };
struct POEMSChain{ struct POEMSChain{
~POEMSChain(){ ~POEMSChain(){
for(int i = 0; i < childChains.GetNumElements(); i++) for(int i = 0; i < childChains.GetNumElements(); i++)
{ {
delete childChains(i); delete childChains(i);
} }
listOfNodes.DeleteValues(); listOfNodes.DeleteValues();
} }
//void printTreeStructure(int tabs); //void printTreeStructure(int tabs);
//void getTreeAsList(List<int> * temp); //void getTreeAsList(List<int> * temp);
List<int> listOfNodes; List<int> listOfNodes;
List<POEMSChain> childChains; List<POEMSChain> childChains;
POEMSChain * parentChain; POEMSChain * parentChain;
List<ChildRingData> childRings; List<ChildRingData> childRings;
void printTreeStructure(int tabs){ void printTreeStructure(int tabs){
for(int i = 0; i < tabs; i++) for(int i = 0; i < tabs; i++)
{ {
cout << "\t"; cout << "\t";
} }
cout << "Chain: "; cout << "Chain: ";
for(int i = 0; i < listOfNodes.GetNumElements(); i++) for(int i = 0; i < listOfNodes.GetNumElements(); i++)
{ {
cout << *(listOfNodes(i)) << " "; cout << *(listOfNodes(i)) << " ";
} }
cout << endl; cout << endl;
for(int i = 0; i < childChains.GetNumElements(); i++) for(int i = 0; i < childChains.GetNumElements(); i++)
{ {
childChains(i)->printTreeStructure(tabs + 1); childChains(i)->printTreeStructure(tabs + 1);
} }
} }
void getTreeAsList(List<int> * temp) void getTreeAsList(List<int> * temp)
{ {
for(int i = 0; i < listOfNodes.GetNumElements(); i++) for(int i = 0; i < listOfNodes.GetNumElements(); i++)
{ {
int * integer = new int; int * integer = new int;
*integer = *(listOfNodes(i)); *integer = *(listOfNodes(i));
temp->Append(integer); temp->Append(integer);
} }
for(int i = 0; i < childChains.GetNumElements(); i++) for(int i = 0; i < childChains.GetNumElements(); i++)
{ {
childChains(i)->getTreeAsList(temp); childChains(i)->getTreeAsList(temp);
} }
} }
}; };
#endif #endif

View File

@ -23,47 +23,47 @@
struct POEMSNode { struct POEMSNode {
List<POEMSNode> links; List<POEMSNode> links;
List<bool> taken; List<bool> taken;
int idNumber; int idNumber;
bool visited; bool visited;
~POEMSNode(){ ~POEMSNode(){
for(int i = 0; i < taken.GetNumElements(); i++) for(int i = 0; i < taken.GetNumElements(); i++)
{ {
delete taken(i); delete taken(i);
} }
}; };
}; };
class SystemProcessor{ class SystemProcessor{
private: private:
Tree nodes; Tree nodes;
static void POEMSNodeDelete_cb(void *node) { static void POEMSNodeDelete_cb(void *node) {
delete (POEMSNode *) node; delete (POEMSNode *) node;
} }
List<POEMSChain> headsOfSystems; List<POEMSChain> headsOfSystems;
List<List<int> > ringsInSystem; List<List<int> > ringsInSystem;
POEMSNode * findSingleLink(TreeNode * aNode); POEMSNode * findSingleLink(TreeNode * aNode);
POEMSChain * AddNewChain(POEMSNode * currentNode); POEMSChain * AddNewChain(POEMSNode * currentNode);
bool setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode); bool setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode);
public: public:
SystemProcessor(void); SystemProcessor(void);
~SystemProcessor(void) { ~SystemProcessor(void) {
headsOfSystems.DeleteValues(); headsOfSystems.DeleteValues();
for(int i = 0; i < ringsInSystem.GetNumElements(); i++) for(int i = 0; i < ringsInSystem.GetNumElements(); i++)
{ {
for(int k = 0; k < ringsInSystem(i)->GetNumElements(); i++) for(int k = 0; k < ringsInSystem(i)->GetNumElements(); i++)
{ {
delete (*ringsInSystem(i))(k); delete (*ringsInSystem(i))(k);
} }
} }
}; };
void processArray(int** links, int numLinks); void processArray(int** links, int numLinks);
List<POEMSChain> * getSystemData(); List<POEMSChain> * getSystemData();
int getNumberOfHeadChains(); int getNumberOfHeadChains();
}; };
SystemProcessor::SystemProcessor(void){ SystemProcessor::SystemProcessor(void){
@ -73,145 +73,145 @@ SystemProcessor::SystemProcessor(void){
void SystemProcessor::processArray(int** links, int numLinks) void SystemProcessor::processArray(int** links, int numLinks)
{ {
bool * false_var; //holds the value false; needed because a constant cannot be put into a list; the list requires a bool * false_var; //holds the value false; needed because a constant cannot be put into a list; the list requires a
//reference. //reference.
for(int i = 0; i < numLinks; i++) //go through all the links in the input array for(int i = 0; i < numLinks; i++) //go through all the links in the input array
{ {
if(!nodes.Find(links[i][0])) //if the first node in the pair is not found in the storage tree if(!nodes.Find(links[i][0])) //if the first node in the pair is not found in the storage tree
{ {
POEMSNode * newNode = new POEMSNode; //make a new node POEMSNode * newNode = new POEMSNode; //make a new node
// forDeletion.Append(newNode); // forDeletion.Append(newNode);
newNode->idNumber = links[i][0]; //set its ID to the value newNode->idNumber = links[i][0]; //set its ID to the value
newNode->visited = false; //set it to be unvisited newNode->visited = false; //set it to be unvisited
nodes.Insert(links[i][0], links[i][0], (void *) newNode); //and add it to the tree storage structure nodes.Insert(links[i][0], links[i][0], (void *) newNode); //and add it to the tree storage structure
} }
if(!nodes.Find(links[i][1])) //repeat process for the other half of each link if(!nodes.Find(links[i][1])) //repeat process for the other half of each link
{ {
POEMSNode * newNode = new POEMSNode; POEMSNode * newNode = new POEMSNode;
// forDeletion.Append(newNode); // forDeletion.Append(newNode);
newNode->idNumber = links[i][1]; newNode->idNumber = links[i][1];
newNode->visited = false; newNode->visited = false;
nodes.Insert(links[i][1], links[i][1], (void *) newNode); nodes.Insert(links[i][1], links[i][1], (void *) newNode);
} }
POEMSNode * firstNode = (POEMSNode *)nodes.Find(links[i][0]); //now that we are sure both nodes exist, POEMSNode * firstNode = (POEMSNode *)nodes.Find(links[i][0]); //now that we are sure both nodes exist,
POEMSNode * secondNode = (POEMSNode *)nodes.Find(links[i][1]); //we can get both of them out of the tree POEMSNode * secondNode = (POEMSNode *)nodes.Find(links[i][1]); //we can get both of them out of the tree
firstNode->links.Append(secondNode); //and add the link from the first to the second... firstNode->links.Append(secondNode); //and add the link from the first to the second...
false_var = new bool; false_var = new bool;
*false_var = false; //make a new false boolean to note that the link between these two *false_var = false; //make a new false boolean to note that the link between these two
firstNode->taken.Append(false_var); //has not already been taken, and append it to the taken list firstNode->taken.Append(false_var); //has not already been taken, and append it to the taken list
secondNode->links.Append(firstNode); //repeat process for link from second node to first secondNode->links.Append(firstNode); //repeat process for link from second node to first
false_var = new bool; false_var = new bool;
*false_var = false; *false_var = false;
secondNode->taken.Append(false_var); secondNode->taken.Append(false_var);
} }
TreeNode * temp = nodes.GetRoot(); //get the root node of the node storage tree TreeNode * temp = nodes.GetRoot(); //get the root node of the node storage tree
POEMSNode * currentNode; POEMSNode * currentNode;
do do
{ {
currentNode = findSingleLink(temp); //find the start of the next available chain currentNode = findSingleLink(temp); //find the start of the next available chain
if(currentNode != NULL) if(currentNode != NULL)
{ {
headsOfSystems.Append(AddNewChain(currentNode)); //and add it to the headsOfSystems list of chains headsOfSystems.Append(AddNewChain(currentNode)); //and add it to the headsOfSystems list of chains
} }
} }
while(currentNode != NULL); //repeat this until all chains have been added while(currentNode != NULL); //repeat this until all chains have been added
} }
POEMSChain * SystemProcessor::AddNewChain(POEMSNode * currentNode){ POEMSChain * SystemProcessor::AddNewChain(POEMSNode * currentNode){
if(currentNode == NULL) //Termination condition; if the currentNode is null, then return null if(currentNode == NULL) //Termination condition; if the currentNode is null, then return null
{ {
return NULL; return NULL;
} }
int * tmp; int * tmp;
POEMSNode * nextNode = NULL; //nextNode stores the proposed next node to add to the chain. this will be checked to make sure no backtracking is occurring before being assigned as the current node. POEMSNode * nextNode = NULL; //nextNode stores the proposed next node to add to the chain. this will be checked to make sure no backtracking is occurring before being assigned as the current node.
POEMSChain * newChain = new POEMSChain; //make a new POEMSChain object. This will be the object returned POEMSChain * newChain = new POEMSChain; //make a new POEMSChain object. This will be the object returned
if(currentNode->links.GetNumElements() == 0) //if we have no links from this node, then the whole chain is only one node. Add this node to the chain and return it; mark node as visited for future reference if(currentNode->links.GetNumElements() == 0) //if we have no links from this node, then the whole chain is only one node. Add this node to the chain and return it; mark node as visited for future reference
{ {
currentNode->visited = true; currentNode->visited = true;
tmp = new int; tmp = new int;
*tmp = currentNode->idNumber; *tmp = currentNode->idNumber;
newChain->listOfNodes.Append(tmp); newChain->listOfNodes.Append(tmp);
return newChain; return newChain;
} }
while(currentNode->links.GetNumElements() <= 2) //we go until we get to a node that branches, or both branches have already been taken both branches can already be taken if a loop with no spurs is found in the input data while(currentNode->links.GetNumElements() <= 2) //we go until we get to a node that branches, or both branches have already been taken both branches can already be taken if a loop with no spurs is found in the input data
{ {
currentNode->visited = true; currentNode->visited = true;
tmp = new int; tmp = new int;
*tmp = currentNode->idNumber; *tmp = currentNode->idNumber;
newChain->listOfNodes.Append(tmp); //append the current node to the chain & mark as visited newChain->listOfNodes.Append(tmp); //append the current node to the chain & mark as visited
//cout << "Appending node " << currentNode->idNumber << " to chain" << endl; //cout << "Appending node " << currentNode->idNumber << " to chain" << endl;
nextNode = currentNode->links.GetHeadElement()->value; //the next node is the first or second value stored in the links array nextNode = currentNode->links.GetHeadElement()->value; //the next node is the first or second value stored in the links array
//of the current node. We get the first value... //of the current node. We get the first value...
if(!setLinkVisited(currentNode, nextNode)) //...and see if it points back to where we came from. If it does... if(!setLinkVisited(currentNode, nextNode)) //...and see if it points back to where we came from. If it does...
{ //either way, we set this link as visited { //either way, we set this link as visited
if(currentNode->links.GetNumElements() == 1) //if it does, then if that is the only link to this node, we're done with the chain, so append the chain to the list and return the newly created chain if(currentNode->links.GetNumElements() == 1) //if it does, then if that is the only link to this node, we're done with the chain, so append the chain to the list and return the newly created chain
{ {
// headsOfSystems.Append(newChain); // headsOfSystems.Append(newChain);
return newChain; return newChain;
} }
nextNode = currentNode->links.GetHeadElement()->next->value;//follow the other link if there is one, so we go down the chain nextNode = currentNode->links.GetHeadElement()->next->value;//follow the other link if there is one, so we go down the chain
if(!setLinkVisited(currentNode, nextNode)) //mark link as followed, so we know not to backtrack if(!setLinkVisited(currentNode, nextNode)) //mark link as followed, so we know not to backtrack
{ {
// headsOfSystems.Append(newChain); // headsOfSystems.Append(newChain);
return newChain; //This condition, where no branches have occurred but both links have already return newChain; //This condition, where no branches have occurred but both links have already
//been taken can only occur in a loop with no spurs; add this loop to the //been taken can only occur in a loop with no spurs; add this loop to the
//system (currently added as a chain for consistency), and return. //system (currently added as a chain for consistency), and return.
} }
} }
currentNode = nextNode; //set the current node to be the next node in the chain currentNode = nextNode; //set the current node to be the next node in the chain
} }
currentNode->visited = true; currentNode->visited = true;
tmp = new int; tmp = new int;
*tmp = currentNode->idNumber; *tmp = currentNode->idNumber;
newChain->listOfNodes.Append(tmp); //append the last node before branch (node shared jointly with branch chains) newChain->listOfNodes.Append(tmp); //append the last node before branch (node shared jointly with branch chains)
//re-mark as visited, just to make sure //re-mark as visited, just to make sure
ListElement<POEMSNode> * tempNode = currentNode->links.GetHeadElement(); //go through all of the links, one at a time that branch ListElement<POEMSNode> * tempNode = currentNode->links.GetHeadElement(); //go through all of the links, one at a time that branch
POEMSChain * tempChain = NULL; //temporary variable to hold data POEMSChain * tempChain = NULL; //temporary variable to hold data
while(tempNode != NULL) //when we have followed all links, stop while(tempNode != NULL) //when we have followed all links, stop
{ {
if(setLinkVisited(tempNode->value, currentNode)) //dont backtrack, or create closed loops if(setLinkVisited(tempNode->value, currentNode)) //dont backtrack, or create closed loops
{ {
tempChain = AddNewChain(tempNode->value); //Add a new chain created out of the next node down that link tempChain = AddNewChain(tempNode->value); //Add a new chain created out of the next node down that link
tempChain->parentChain = newChain; //set the parent to be this chain tempChain->parentChain = newChain; //set the parent to be this chain
newChain->childChains.Append(tempChain); //append the chain to this chain's list of child chains newChain->childChains.Append(tempChain); //append the chain to this chain's list of child chains
} }
tempNode = tempNode->next; //go to process the next chain tempNode = tempNode->next; //go to process the next chain
} }
//headsOfSystems.Append(newChain); //append this chain to the system list //headsOfSystems.Append(newChain); //append this chain to the system list
return newChain; return newChain;
} }
POEMSNode * SystemProcessor::findSingleLink(TreeNode * aNode) POEMSNode * SystemProcessor::findSingleLink(TreeNode * aNode)
//This function takes the root of a search tree containing POEMSNodes and returns a POEMSNode corresponding to the start of a chain in the //This function takes the root of a search tree containing POEMSNodes and returns a POEMSNode corresponding to the start of a chain in the
//system. It finds a node that has not been visited before, and only has one link; this node will be used as the head of the chain. //system. It finds a node that has not been visited before, and only has one link; this node will be used as the head of the chain.
{ {
if(aNode == NULL) if(aNode == NULL)
{ {
return NULL; return NULL;
} }
POEMSNode * returnVal = (POEMSNode *)aNode->GetAuxData(); //get the poemsnode data out of the treenode POEMSNode * returnVal = (POEMSNode *)aNode->GetAuxData(); //get the poemsnode data out of the treenode
POEMSNode * detectLoneLoops = NULL; //is used to handle a loop that has no protruding chains POEMSNode * detectLoneLoops = NULL; //is used to handle a loop that has no protruding chains
if(returnVal->visited == false) if(returnVal->visited == false)
{ {
detectLoneLoops = returnVal; //if we find any node that has not been visited yet, save it detectLoneLoops = returnVal; //if we find any node that has not been visited yet, save it
} }
if(returnVal->links.GetNumElements() == 1 && returnVal->visited == false) //see if it has one element and hasnt been visited already if(returnVal->links.GetNumElements() == 1 && returnVal->visited == false) //see if it has one element and hasnt been visited already
{ {
return returnVal; //return the node is it meets this criteria return returnVal; //return the node is it meets this criteria
} }
returnVal = findSingleLink(aNode->Left()); //otherwise, check the left subtree returnVal = findSingleLink(aNode->Left()); //otherwise, check the left subtree
if(returnVal == NULL) //and if we find nothing... if(returnVal == NULL) //and if we find nothing...
{ {
returnVal = findSingleLink(aNode->Right()); //check the right subtree returnVal = findSingleLink(aNode->Right()); //check the right subtree
} }
if(returnVal == NULL) //if we could not find any chains if(returnVal == NULL) //if we could not find any chains
{ {
returnVal = detectLoneLoops; //see if we found any nodes at all that havent been processed returnVal = detectLoneLoops; //see if we found any nodes at all that havent been processed
} }
return returnVal; //return what we find (will be NULL if no new chains are return returnVal; //return what we find (will be NULL if no new chains are
//found) //found)
} }
bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode) bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNode)
@ -223,65 +223,65 @@ bool SystemProcessor::setLinkVisited(POEMSNode * firstNode, POEMSNode * secondNo
//value for that particular link. Because each link is represented twice, (once at each node in the link), both of the boolean values need //value for that particular link. Because each link is represented twice, (once at each node in the link), both of the boolean values need
//to be set in the event that the link has to be set as visited. //to be set in the event that the link has to be set as visited.
{ {
//cout << "Checking link between nodes " << firstNode->idNumber << " and " << secondNode->idNumber << "... "; //cout << "Checking link between nodes " << firstNode->idNumber << " and " << secondNode->idNumber << "... ";
ListElement<POEMSNode> * tmp = firstNode->links.GetHeadElement(); //get the head element of the list of pointers for node 1 ListElement<POEMSNode> * tmp = firstNode->links.GetHeadElement(); //get the head element of the list of pointers for node 1
ListElement<bool> * tmp2 = firstNode->taken.GetHeadElement(); //get the head element of the list of bool isVisited flags for node 1 ListElement<bool> * tmp2 = firstNode->taken.GetHeadElement(); //get the head element of the list of bool isVisited flags for node 1
while(tmp->value != NULL || tmp2->value != NULL) //go through until we reach the end of the lists while(tmp->value != NULL || tmp2->value != NULL) //go through until we reach the end of the lists
{ {
if(tmp->value == secondNode) //if we find the link to the other node if(tmp->value == secondNode) //if we find the link to the other node
{ {
if(*(tmp2->value) == true) //if the link has already been visited if(*(tmp2->value) == true) //if the link has already been visited
{ {
//cout << "visited already" << endl; //cout << "visited already" << endl;
return false; //return false to indicate that the link has been visited before this attempt return false; //return false to indicate that the link has been visited before this attempt
} }
else //otherwise, visit it else //otherwise, visit it
{ {
*tmp2->value = true; *tmp2->value = true;
} }
break; break;
} }
tmp = tmp->next; //go check next link tmp = tmp->next; //go check next link
tmp2 = tmp2->next; tmp2 = tmp2->next;
} }
tmp = secondNode->links.GetHeadElement(); //now, if the link was unvisited, we need to go set the other node's list such that tmp = secondNode->links.GetHeadElement(); //now, if the link was unvisited, we need to go set the other node's list such that
//it also knows this link is being visited //it also knows this link is being visited
tmp2 = secondNode->taken.GetHeadElement(); tmp2 = secondNode->taken.GetHeadElement();
while(tmp->value != NULL || tmp2->value != NULL) //go through the list while(tmp->value != NULL || tmp2->value != NULL) //go through the list
{ {
if(tmp->value == firstNode) //if we find the link if(tmp->value == firstNode) //if we find the link
{ {
if(*(tmp2->value) == true) //and it has already been visited, then signal an error; this shouldnt ever happen if(*(tmp2->value) == true) //and it has already been visited, then signal an error; this shouldnt ever happen
{ {
cout << "Error in parsing structure! Should never reach this condition! \n" << cout << "Error in parsing structure! Should never reach this condition! \n" <<
"Record of visited links out of synch between two adjacent nodes.\n"; "Record of visited links out of synch between two adjacent nodes.\n";
return false; return false;
} }
else else
{ {
*tmp2->value = true; //set the appropriate value to true to indicate this link has been visited *tmp2->value = true; //set the appropriate value to true to indicate this link has been visited
} }
break; break;
} }
tmp = tmp->next; tmp = tmp->next;
tmp2 = tmp2->next; tmp2 = tmp2->next;
} }
//cout << "not visited" << endl; //cout << "not visited" << endl;
return true; //return true to indicate that this is the first time the link has been visited return true; //return true to indicate that this is the first time the link has been visited
} }
List<POEMSChain> * SystemProcessor::getSystemData(void) //Gets the list of POEMSChains that comprise the system. Might eventually only List<POEMSChain> * SystemProcessor::getSystemData(void) //Gets the list of POEMSChains that comprise the system. Might eventually only
//return chains linked to the reference plane, but currently returns every chain //return chains linked to the reference plane, but currently returns every chain
//in the system. //in the system.
{ {
return &headsOfSystems; return &headsOfSystems;
} }
int SystemProcessor::getNumberOfHeadChains(void) //This function isnt implemented yet, and might be taken out entirely; this was a holdover int SystemProcessor::getNumberOfHeadChains(void) //This function isnt implemented yet, and might be taken out entirely; this was a holdover
//from when I intended to return an array of chain pointers, rather than a list of chains //from when I intended to return an array of chain pointers, rather than a list of chains
//It will probably be deleted once I finish figuring out exactly what needs to be returned //It will probably be deleted once I finish figuring out exactly what needs to be returned
{ {
return 0; return 0;
} }
#endif #endif

View File

@ -2,7 +2,7 @@
*_________________________________________________________________________* *_________________________________________________________________________*
* POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE *
* DESCRIPTION: SEE READ-ME * * DESCRIPTION: SEE READ-ME *
* FILE NAME: body23joint.h * * FILE NAME: body23joint.h *
* AUTHORS: See Author List * * AUTHORS: See Author List *
* GRANTS: See Grants List * * GRANTS: See Grants List *
* COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List *

View File

@ -62,23 +62,23 @@ public:
void BasicMin(double& value, int& index); void BasicMin(double& value, int& index);
// fast matrix operations // fast matrix operations
friend void FastQuaternions(ColMatrix& q, Mat3x3& C); friend void FastQuaternions(ColMatrix& q, Mat3x3& C);
friend void FastInvQuaternions(Mat3x3& C, ColMatrix& q); friend void FastInvQuaternions(Mat3x3& C, ColMatrix& q);
friend void FastQuaternionDerivatives(ColMatrix& q, ColMatrix& omega, ColMatrix& qdot); friend void FastQuaternionDerivatives(ColMatrix& q, ColMatrix& omega, ColMatrix& qdot);
friend void FastTMult(Matrix& A, Vect6& B, ColMatrix& C); friend void FastTMult(Matrix& A, Vect6& B, ColMatrix& C);
friend void FastMult(Matrix& A, ColMatrix& B, Vect6& C); friend void FastMult(Matrix& A, ColMatrix& B, Vect6& C);
friend void FastAssign(ColMatrix& A, ColMatrix& C); friend void FastAssign(ColMatrix& A, ColMatrix& C);
friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C); friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C);
friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C); friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C);
friend void FastAssign(ColMatrix&A, Vect3& C); friend void FastAssign(ColMatrix&A, Vect3& C);
friend void EP_Derivatives(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); friend void EP_Derivatives(ColMatrix& q, ColMatrix& u, ColMatrix& qdot);
friend void EP_Transformation(ColMatrix& q, Mat3x3& C); friend void EP_Transformation(ColMatrix& q, Mat3x3& C);
friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C); friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C);
friend void EP_Normalize(ColMatrix& q); friend void EP_Normalize(ColMatrix& q);
friend void EPdotdot_udot(ColMatrix& Audot, ColMatrix& Aqdot, ColMatrix& Aq,ColMatrix& Aqddot); friend void EPdotdot_udot(ColMatrix& Audot, ColMatrix& Aqdot, ColMatrix& Aq,ColMatrix& Aqddot);
friend void qdot_to_u(ColMatrix& q, ColMatrix& u, ColMatrix& qdot); friend void qdot_to_u(ColMatrix& q, ColMatrix& u, ColMatrix& qdot);
}; };
#endif #endif

View File

@ -2,7 +2,7 @@
*_________________________________________________________________________* *_________________________________________________________________________*
* POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE *
* DESCRIPTION: SEE READ-ME * * DESCRIPTION: SEE READ-ME *
* FILE NAME: defines.h * * FILE NAME: defines.h *
* AUTHORS: See Author List * * AUTHORS: See Author List *
* GRANTS: See Grants List * * GRANTS: See Grants List *
* COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List *

View File

@ -44,22 +44,22 @@ Mat4x4 Inverse(Mat4x4& A);
Mat6x6 Inverse(Mat6x6& A); Mat6x6 Inverse(Mat6x6& A);
// overloaded addition // overloaded addition
Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition
//Mat3x3 operator+ (const Mat3x3 &A, const Mat3x3 &B); // addition //Mat3x3 operator+ (const Mat3x3 &A, const Mat3x3 &B); // addition
//Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition //Matrix operator+ (const VirtualMatrix &A, const VirtualMatrix &B); // addition
// overloaded subtraction // overloaded subtraction
Matrix operator- (const VirtualMatrix &A, const VirtualMatrix &B); // subtraction Matrix operator- (const VirtualMatrix &A, const VirtualMatrix &B); // subtraction
// overloaded matrix multiplication // overloaded matrix multiplication
Matrix operator* (const VirtualMatrix &A, const VirtualMatrix &B); // multiplication Matrix operator* (const VirtualMatrix &A, const VirtualMatrix &B); // multiplication
// overloaded scalar-matrix multiplication // overloaded scalar-matrix multiplication
Matrix operator* (const VirtualMatrix &A, double b); // overloaded * Matrix operator* (const VirtualMatrix &A, double b); // overloaded *
Matrix operator* (double b, const VirtualMatrix &A); // overloaded * Matrix operator* (double b, const VirtualMatrix &A); // overloaded *
// overloaded negative // overloaded negative
Matrix operator- (const VirtualMatrix &A); // negative Matrix operator- (const VirtualMatrix &A); // negative
Vect3 Cross(Vect3& a, Vect3& b); Vect3 Cross(Vect3& a, Vect3& b);
Mat3x3 CrossMat(Vect3& a); Mat3x3 CrossMat(Vect3& a);

View File

@ -2,7 +2,7 @@
*_________________________________________________________________________* *_________________________________________________________________________*
* POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE *
* DESCRIPTION: SEE READ-ME * * DESCRIPTION: SEE READ-ME *
* FILE NAME: mixedjoint.h * * FILE NAME: mixedjoint.h *
* AUTHORS: See Author List * * AUTHORS: See Author List *
* GRANTS: See Grants List * * GRANTS: See Grants List *
* COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List *

View File

@ -92,7 +92,7 @@ public:
void Setup(); void Setup();
void SetupInertialFrame(); void SetupInertialFrame();
void LocalKinematics(); void LocalKinematics();
void LocalTriangularization(Vect3& Torque, Vect3& Force); void LocalTriangularization(Vect3& Torque, Vect3& Force);
void LocalForwardSubstitution(); void LocalForwardSubstitution();
}; };

View File

@ -31,7 +31,7 @@ class OnSolver : public Solver {
OnBody** bodyarray; OnBody** bodyarray;
ColMatrix** q; ColMatrix** q;
ColMatrix** qdot; ColMatrix** qdot;
ColMatrix** qdotdot; ColMatrix** qdotdot;
ColMatrix** u; ColMatrix** u;
ColMatrix** udot; ColMatrix** udot;
@ -40,7 +40,7 @@ class OnSolver : public Solver {
void DeleteModel(); void DeleteModel();
int CreateTopologyArray(int i, OnBody* body); int CreateTopologyArray(int i, OnBody* body);
void CreateStateMatrixMaps(); void CreateStateMatrixMaps();
void GetType(); void GetType();
public: public:
OnSolver(); OnSolver();
~OnSolver(); ~OnSolver();

View File

@ -90,9 +90,9 @@ template<class S> List<S>::~List(){
template<class S> void List<S>::Append(List<S> * listToAppend) template<class S> void List<S>::Append(List<S> * listToAppend)
{ {
tail->next = listToAppend->head; tail->next = listToAppend->head;
listToAppend->head->prev = tail; listToAppend->head->prev = tail;
tail = listToAppend->tail; tail = listToAppend->tail;
} }
template<class S> int List<S>::GetNumElements(){ template<class S> int List<S>::GetNumElements(){
@ -104,7 +104,7 @@ template<class S> ListElement<S>* List<S>::GetHeadElement(){
} }
template<class S> ListElement<S>* List<S>::GetTailElement(){ template<class S> ListElement<S>* List<S>::GetTailElement(){
return tail; return tail;
} }
@ -145,14 +145,14 @@ template<class S> ListElement<S>* List<S>::Append(S* v){
if(numelements==1) if(numelements==1)
head = tail = ele; head = tail = ele;
else{ else{
/* /*
tail->next = ele; tail->next = ele;
ele->prev = tail; ele->prev = tail;
tail = ele;*/ tail = ele;*/
ele->prev = tail; ele->prev = tail;
tail = ele; tail = ele;
ele->prev->next = ele; ele->prev->next = ele;
} }
return ele; return ele;
@ -170,9 +170,9 @@ template<class S> ListElement<S>* List<S>::Prepend(S* v){
if(numelements==1) if(numelements==1)
head = tail = ele; head = tail = ele;
else{ else{
ele->next = head; ele->next = head;
head = ele; head = ele;
ele->next->prev = ele; ele->next->prev = ele;
} }
return ele; return ele;
} }
@ -214,15 +214,15 @@ template<class S> void List<S>::RemoveElementAndDeleteValue(ListElement<S>* ele)
} }
template<class S> void List<S>::PrintList(){ template<class S> void List<S>::PrintList(){
cout<<"Printing List "<<endl; cout<<"Printing List "<<endl;
ListElement<S>* ele = head; ListElement<S>* ele = head;
cout<<*(ele->value)<<" "; cout<<*(ele->value)<<" ";
ele = ele->next; ele = ele->next;
for(int k =2; k<numelements; k++){ for(int k =2; k<numelements; k++){
cout<<*(ele->value)<<" "; cout<<*(ele->value)<<" ";
ele = ele->next; ele = ele->next;
} }
cout<<*(ele->value)<<endl; cout<<*(ele->value)<<endl;
} }

View File

@ -45,26 +45,26 @@ void PrintTree (TreeNode *t, int level);
// postorder recursive scan of the nodes in a tree // postorder recursive scan of the nodes in a tree
void Postorder (TreeNode *t, void visit(TreeNode* &t)) void Postorder (TreeNode *t, void visit(TreeNode* &t))
{ {
// the recursive scan terminates on a empty subtree // the recursive scan terminates on a empty subtree
if (t != NULL) if (t != NULL)
{ {
Postorder(t->Left(), visit); // descend left Postorder(t->Left(), visit); // descend left
Postorder(t->Right(), visit); // descend right Postorder(t->Right(), visit); // descend right
visit(t); // visit the node visit(t); // visit the node
} }
} }
// preorder recursive scan of the nodes in a tree // preorder recursive scan of the nodes in a tree
void Preorder (TreeNode *t, void visit(TreeNode* &t)) void Preorder (TreeNode *t, void visit(TreeNode* &t))
{ {
// the recursive scan terminates on a empty subtree // the recursive scan terminates on a empty subtree
if (t != NULL) if (t != NULL)
{ {
visit(t); // visit the node visit(t); // visit the node
Preorder(t->Left(), visit); // descend left Preorder(t->Left(), visit); // descend left
Preorder(t->Right(), visit); // descend right Preorder(t->Right(), visit); // descend right
} }
} }
@ -72,21 +72,21 @@ void Preorder (TreeNode *t, void visit(TreeNode* &t))
// The pointers have default value NULL // The pointers have default value NULL
TreeNode *GetTreeNode(int item,TreeNode *lptr,TreeNode *rptr) TreeNode *GetTreeNode(int item,TreeNode *lptr,TreeNode *rptr)
{ {
TreeNode *p; TreeNode *p;
// call new to allocate the new node // call new to allocate the new node
// pass parameters lptr and rptr to the function // pass parameters lptr and rptr to the function
p = new TreeNode(item, lptr, rptr); p = new TreeNode(item, lptr, rptr);
// if insufficient memory, terminatewith an error message // if insufficient memory, terminatewith an error message
if (p == NULL) if (p == NULL)
{ {
cerr << "Memory allocation failure!\n"; cerr << "Memory allocation failure!\n";
exit(1); exit(1);
} }
// return the pointer to the system generated memory // return the pointer to the system generated memory
return p; return p;
} }
@ -94,7 +94,7 @@ TreeNode *GetTreeNode(int item,TreeNode *lptr,TreeNode *rptr)
void FreeTreeNode(TreeNode *p) void FreeTreeNode(TreeNode *p)
{ {
delete p; delete p;
} }
@ -102,17 +102,17 @@ void FreeTreeNode(TreeNode *p)
// tests whether the node is a leaf node // tests whether the node is a leaf node
void CountLeaf (TreeNode *t, int& count) void CountLeaf (TreeNode *t, int& count)
{ {
//use postorder descent //use postorder descent
if(t !=NULL) if(t !=NULL)
{ {
CountLeaf(t->Left(), count); // descend left CountLeaf(t->Left(), count); // descend left
CountLeaf(t->Right(), count); // descend right CountLeaf(t->Right(), count); // descend right
// check if node t is a leaf node (no descendants) // check if node t is a leaf node (no descendants)
// if so, increment the variable count // if so, increment the variable count
if (t->Left() == NULL && t->Right() == NULL) if (t->Left() == NULL && t->Right() == NULL)
count++; count++;
} }
} }
@ -122,41 +122,41 @@ void CountLeaf (TreeNode *t, int& count)
// the depth of an empty tree is -1 // the depth of an empty tree is -1
int Depth (TreeNode *t) int Depth (TreeNode *t)
{ {
int depthLeft, depthRight, depthval; int depthLeft, depthRight, depthval;
if (t == NULL) if (t == NULL)
depthval = -1; depthval = -1;
else else
{ {
depthLeft = Depth(t->Left()); depthLeft = Depth(t->Left());
depthRight = Depth(t->Right()); depthRight = Depth(t->Right());
depthval = 1+(depthLeft > depthRight?depthLeft:depthRight); depthval = 1+(depthLeft > depthRight?depthLeft:depthRight);
} }
return depthval; return depthval;
} }
void IndentBlanks(int num) void IndentBlanks(int num)
{ {
// const int indentblock = 6; // const int indentblock = 6;
for(int i = 0; i < num; i++) for(int i = 0; i < num; i++)
cout << " "; cout << " ";
} }
void PrintTree (TreeNode *t, int level) void PrintTree (TreeNode *t, int level)
{ {
//print tree with root t, as long as t!=NULL //print tree with root t, as long as t!=NULL
if (t != NULL) if (t != NULL)
{ {
int indentUnit = 5; int indentUnit = 5;
// print right branch of tree t // print right branch of tree t
PrintTree(t->Right(),level + 1); PrintTree(t->Right(),level + 1);
// indent to current level; output node data // indent to current level; output node data
IndentBlanks(indentUnit*level); IndentBlanks(indentUnit*level);
cout << t->GetData() << endl; cout << t->GetData() << endl;
// print left branch of tree t // print left branch of tree t
PrintTree(t->Left(),level + 1); PrintTree(t->Left(),level + 1);
} }
} }
#endif #endif

View File

@ -31,74 +31,74 @@ const int rightheavy = 1;
class Tree{ class Tree{
protected: protected:
// pointer to tree root and node most recently accessed // pointer to tree root and node most recently accessed
TreeNode *root; TreeNode *root;
TreeNode *current; TreeNode *current;
// number of elements in the tree // number of elements in the tree
int size; int size;
// used by the copy constructor and assignment operator // used by the copy constructor and assignment operator
TreeNode *CopyTree(TreeNode *t); TreeNode *CopyTree(TreeNode *t);
// callback function to delete aux data // callback function to delete aux data
void (*DeleteAuxData)(void *); void (*DeleteAuxData)(void *);
// used by insert and delete method to re-establish // used by insert and delete method to re-establish
// the avl conditions after a node is added or deleted // the avl conditions after a node is added or deleted
// from a subtree // from a subtree
void SingleRotateLeft (TreeNode* &p); void SingleRotateLeft (TreeNode* &p);
void SingleRotateRight (TreeNode* &p); void SingleRotateRight (TreeNode* &p);
void DoubleRotateLeft (TreeNode* &p); void DoubleRotateLeft (TreeNode* &p);
void DoubleRotateRight (TreeNode* &p); void DoubleRotateRight (TreeNode* &p);
void UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor); void UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor);
void UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor); void UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor);
// used by destructor, assignment operator and ClearList // used by destructor, assignment operator and ClearList
void DeleteTree(TreeNode *t); void DeleteTree(TreeNode *t);
void ClearTree(TreeNode * &t); void ClearTree(TreeNode * &t);
// locate a node with data item and its parent in tree // locate a node with data item and its parent in tree
// used by Find and Delete // used by Find and Delete
TreeNode *FindNode(const int& item, TreeNode* & parent) const; TreeNode *FindNode(const int& item, TreeNode* & parent) const;
public: public:
// constructor, destructor // constructor, destructor
Tree(void); Tree(void);
~Tree(void) ~Tree(void)
{ {
ClearTree(root); ClearTree(root);
}; };
// assignment operator // assignment operator
Tree& operator= (const Tree& rhs); Tree& operator= (const Tree& rhs);
// standard list handling methods // standard list handling methods
void * Find(int& item); void * Find(int& item);
void * GetAuxData(int item) { void * GetAuxData(int item) {
return (void *)(FindNode(item, root)->GetAuxData()); return (void *)(FindNode(item, root)->GetAuxData());
} }
void SetDeleteAuxData(void (*callback)(void *)) { void SetDeleteAuxData(void (*callback)(void *)) {
DeleteAuxData = callback; DeleteAuxData = callback;
} }
void Insert(const int& item, const int& data, void * AuxData = NULL); void Insert(const int& item, const int& data, void * AuxData = NULL);
void Delete(const int& item); void Delete(const int& item);
void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor); void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor);
void ClearList(void); void ClearList(void);
// tree specific methods // tree specific methods
void Update(const int& item); void Update(const int& item);
TreeNode *GetRoot(void) const; TreeNode *GetRoot(void) const;
}; };
// constructor // constructor
Tree::Tree(void) Tree::Tree(void)
{ {
root = 0; root = 0;
current = 0; current = 0;
size = 0; size = 0;
DeleteAuxData = NULL; DeleteAuxData = NULL;
} }
@ -107,418 +107,418 @@ Tree::Tree(void)
// return root pointer // return root pointer
TreeNode *Tree::GetRoot(void) const TreeNode *Tree::GetRoot(void) const
{ {
return root; return root;
} }
// assignment operator // assignment operator
Tree& Tree::operator = (const Tree& rhs) Tree& Tree::operator = (const Tree& rhs)
{ {
// can't copy a tree to itself // can't copy a tree to itself
if (this == &rhs) if (this == &rhs)
return *this; return *this;
// clear current tree. copy new tree into current object // clear current tree. copy new tree into current object
ClearList(); ClearList();
root = CopyTree(rhs.root); root = CopyTree(rhs.root);
// assign current to root and set the tree size // assign current to root and set the tree size
current = root; current = root;
size = rhs.size; size = rhs.size;
// return reference to current object // return reference to current object
return *this; return *this;
} }
// search for data item in the tree. if found, return its node // search for data item in the tree. if found, return its node
// address and a pointer to its parent; otherwise, return NULL // address and a pointer to its parent; otherwise, return NULL
TreeNode *Tree::FindNode(const int& item, TreeNode *Tree::FindNode(const int& item,
TreeNode* & parent) const TreeNode* & parent) const
{ {
// cycle t through the tree starting with root // cycle t through the tree starting with root
TreeNode *t = root; TreeNode *t = root;
// the parent of the root is NULL // the parent of the root is NULL
parent = NULL; parent = NULL;
// terminate on empty subtree // terminate on empty subtree
while(t != NULL) while(t != NULL)
{ {
// stop on a match // stop on a match
if (item == t->data) if (item == t->data)
break; break;
else else
{ {
// update the parent pointer and move right of left // update the parent pointer and move right of left
parent = t; parent = t;
if (item < t->data) if (item < t->data)
t = t->left; t = t->left;
else else
t = t->right; t = t->right;
} }
} }
// return pointer to node; NULL if not found // return pointer to node; NULL if not found
return t; return t;
} }
// search for item. if found, assign the node data to item // search for item. if found, assign the node data to item
void * Tree::Find(int& item) void * Tree::Find(int& item)
{ {
// we use FindNode, which requires a parent parameter // we use FindNode, which requires a parent parameter
TreeNode *parent; TreeNode *parent;
// search tree for item. assign matching node to current // search tree for item. assign matching node to current
current = FindNode (item, parent); current = FindNode (item, parent);
// if item found, assign data to item and return True // if item found, assign data to item and return True
if (current != NULL) if (current != NULL)
{ {
item = current->data; item = current->data;
return current->GetAuxData(); return current->GetAuxData();
} }
else else
// item not found in the tree. return False // item not found in the tree. return False
return NULL; return NULL;
} }
void Tree::Insert(const int& item, const int& data, void * AuxData) void Tree::Insert(const int& item, const int& data, void * AuxData)
{ {
// declare AVL tree node pointer; using base class method // declare AVL tree node pointer; using base class method
// GetRoot. cast to larger node and assign root pointer // GetRoot. cast to larger node and assign root pointer
TreeNode *treeRoot, *newNode; TreeNode *treeRoot, *newNode;
treeRoot = GetRoot(); treeRoot = GetRoot();
// flag used by AVLInsert to rebalance nodes // flag used by AVLInsert to rebalance nodes
int reviseBalanceFactor = 0; int reviseBalanceFactor = 0;
// get a new AVL tree node with empty pointer fields // get a new AVL tree node with empty pointer fields
newNode = GetTreeNode(item,NULL,NULL); newNode = GetTreeNode(item,NULL,NULL);
newNode->data = data; newNode->data = data;
newNode->SetAuxData(AuxData); newNode->SetAuxData(AuxData);
// call recursive routine to actually insert the element // call recursive routine to actually insert the element
AVLInsert(treeRoot, newNode, reviseBalanceFactor); AVLInsert(treeRoot, newNode, reviseBalanceFactor);
// assign new values to data members in the base class // assign new values to data members in the base class
root = treeRoot; root = treeRoot;
current = newNode; current = newNode;
size++; size++;
} }
void Tree::AVLInsert(TreeNode *&tree, TreeNode *newNode, int &reviseBalanceFactor) void Tree::AVLInsert(TreeNode *&tree, TreeNode *newNode, int &reviseBalanceFactor)
{ {
// flag indicates change node's balanceFactor will occur // flag indicates change node's balanceFactor will occur
int rebalanceCurrNode; int rebalanceCurrNode;
// scan reaches an empty tree; time to insert the new node // scan reaches an empty tree; time to insert the new node
if (tree == NULL) if (tree == NULL)
{ {
// update the parent to point at newNode // update the parent to point at newNode
tree = newNode; tree = newNode;
// assign balanceFactor = 0 to new node // assign balanceFactor = 0 to new node
tree->balanceFactor = balanced; tree->balanceFactor = balanced;
// broadcast message; balanceFactor value is modified // broadcast message; balanceFactor value is modified
reviseBalanceFactor = 1; reviseBalanceFactor = 1;
} }
// recursively move left if new data < current data // recursively move left if new data < current data
else if (newNode->data < tree->data) else if (newNode->data < tree->data)
{ {
AVLInsert(tree->left,newNode,rebalanceCurrNode); AVLInsert(tree->left,newNode,rebalanceCurrNode);
// check if balanceFactor must be updated. // check if balanceFactor must be updated.
if (rebalanceCurrNode) if (rebalanceCurrNode)
{ {
// went left from node that is left heavy. will // went left from node that is left heavy. will
// violate AVL condition; use rotation (case 3) // violate AVL condition; use rotation (case 3)
if (tree->balanceFactor == leftheavy) if (tree->balanceFactor == leftheavy)
UpdateLeftTree(tree,reviseBalanceFactor); UpdateLeftTree(tree,reviseBalanceFactor);
// went left from balanced node. will create // went left from balanced node. will create
// node left on the left. AVL condition OK (case 1) // node left on the left. AVL condition OK (case 1)
else if (tree->balanceFactor == balanced) else if (tree->balanceFactor == balanced)
{ {
tree->balanceFactor = leftheavy; tree->balanceFactor = leftheavy;
reviseBalanceFactor = 1; reviseBalanceFactor = 1;
} }
// went left from node that is right heavy. will // went left from node that is right heavy. will
// balance the node. AVL condition OK (case 2) // balance the node. AVL condition OK (case 2)
else else
{ {
tree->balanceFactor = balanced; tree->balanceFactor = balanced;
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
} }
else else
// no balancing occurs; do not ask previous nodes // no balancing occurs; do not ask previous nodes
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
// otherwise recursively move right // otherwise recursively move right
else else
{ {
AVLInsert(tree->right, newNode, rebalanceCurrNode); AVLInsert(tree->right, newNode, rebalanceCurrNode);
// check if balanceFactor must be updated. // check if balanceFactor must be updated.
if (rebalanceCurrNode) if (rebalanceCurrNode)
{ {
// went right from node that is left heavy. wil; // went right from node that is left heavy. wil;
// balance the node. AVL condition OK (case 2) // balance the node. AVL condition OK (case 2)
if (tree->balanceFactor == leftheavy) if (tree->balanceFactor == leftheavy)
{ {
// scanning right subtree. node heavy on left. // scanning right subtree. node heavy on left.
// the node will become balanced // the node will become balanced
tree->balanceFactor = balanced; tree->balanceFactor = balanced;
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
// went right from balanced node. will create // went right from balanced node. will create
// node heavy on the right. AVL condition OK (case 1) // node heavy on the right. AVL condition OK (case 1)
else if (tree->balanceFactor == balanced) else if (tree->balanceFactor == balanced)
{ {
// node is balanced; will become heavy on right // node is balanced; will become heavy on right
tree->balanceFactor = rightheavy; tree->balanceFactor = rightheavy;
reviseBalanceFactor = 1; reviseBalanceFactor = 1;
} }
// went right from node that is right heavy. will // went right from node that is right heavy. will
// violate AVL condition; use rotation (case 3) // violate AVL condition; use rotation (case 3)
else else
UpdateRightTree(tree, reviseBalanceFactor); UpdateRightTree(tree, reviseBalanceFactor);
} }
else else
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
} }
void Tree::UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor) void Tree::UpdateLeftTree (TreeNode* &p, int &reviseBalanceFactor)
{ {
TreeNode *lc; TreeNode *lc;
lc = p->Left(); // left subtree is also heavy lc = p->Left(); // left subtree is also heavy
if (lc->balanceFactor == leftheavy) if (lc->balanceFactor == leftheavy)
{ {
SingleRotateRight(p); SingleRotateRight(p);
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
// is right subtree heavy? // is right subtree heavy?
else if (lc->balanceFactor == rightheavy) else if (lc->balanceFactor == rightheavy)
{ {
// make a double rotation // make a double rotation
DoubleRotateRight(p); DoubleRotateRight(p);
// root is now balance // root is now balance
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
} }
void Tree::UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor) void Tree::UpdateRightTree (TreeNode* &p, int &reviseBalanceFactor)
{ {
TreeNode *lc; TreeNode *lc;
lc = p->Right(); // right subtree is also heavy lc = p->Right(); // right subtree is also heavy
if (lc->balanceFactor == rightheavy) if (lc->balanceFactor == rightheavy)
{ {
SingleRotateLeft(p); SingleRotateLeft(p);
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
// is left subtree heavy? // is left subtree heavy?
else if (lc->balanceFactor == leftheavy) else if (lc->balanceFactor == leftheavy)
{ {
// make a double rotation // make a double rotation
DoubleRotateLeft(p); DoubleRotateLeft(p);
// root is now balance // root is now balance
reviseBalanceFactor = 0; reviseBalanceFactor = 0;
} }
} }
void Tree::SingleRotateRight (TreeNode* &p) void Tree::SingleRotateRight (TreeNode* &p)
{ {
// the left subtree of p is heavy // the left subtree of p is heavy
TreeNode *lc; TreeNode *lc;
// assign the left subtree to lc // assign the left subtree to lc
lc = p->Left(); lc = p->Left();
// update the balance factor for parent and left child // update the balance factor for parent and left child
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
// any right subtree st of lc must continue as right // any right subtree st of lc must continue as right
// subtree of lc. do by making it a left subtree of p // subtree of lc. do by making it a left subtree of p
p->left = lc->Right(); p->left = lc->Right();
// rotate p (larger node) into right subtree of lc // rotate p (larger node) into right subtree of lc
// make lc the pivot node // make lc the pivot node
lc->right = p; lc->right = p;
p = lc; p = lc;
} }
void Tree::SingleRotateLeft (TreeNode* &p) void Tree::SingleRotateLeft (TreeNode* &p)
{ {
// the right subtree of p is heavy // the right subtree of p is heavy
TreeNode *lc; TreeNode *lc;
// assign the left subtree to lc // assign the left subtree to lc
lc = p->Right(); lc = p->Right();
// update the balance factor for parent and left child // update the balance factor for parent and left child
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
// any right subtree st of lc must continue as right // any right subtree st of lc must continue as right
// subtree of lc. do by making it a left subtree of p // subtree of lc. do by making it a left subtree of p
p->right = lc->Left(); p->right = lc->Left();
// rotate p (larger node) into right subtree of lc // rotate p (larger node) into right subtree of lc
// make lc the pivot node // make lc the pivot node
lc->left = p; lc->left = p;
p = lc; p = lc;
} }
// double rotation right about node p // double rotation right about node p
void Tree::DoubleRotateRight (TreeNode* &p) void Tree::DoubleRotateRight (TreeNode* &p)
{ {
// two subtrees that are rotated // two subtrees that are rotated
TreeNode *lc, *np; TreeNode *lc, *np;
// in the tree, node(lc) <= node(np) < node(p) // in the tree, node(lc) <= node(np) < node(p)
lc = p->Left(); // lc is left child of parent lc = p->Left(); // lc is left child of parent
np = lc->Right(); // np is right child of lc np = lc->Right(); // np is right child of lc
// update balance factors for p, lc, and np // update balance factors for p, lc, and np
if (np->balanceFactor == rightheavy) if (np->balanceFactor == rightheavy)
{ {
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = rightheavy; lc->balanceFactor = rightheavy;
} }
else if (np->balanceFactor == balanced) else if (np->balanceFactor == balanced)
{ {
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
} }
else else
{ {
p->balanceFactor = rightheavy; p->balanceFactor = rightheavy;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
} }
np->balanceFactor = balanced; np->balanceFactor = balanced;
// before np replaces the parent p, take care of subtrees // before np replaces the parent p, take care of subtrees
// detach old children and attach new children // detach old children and attach new children
lc->right = np->Left(); lc->right = np->Left();
np->left = lc; np->left = lc;
p->left = np->Right(); p->left = np->Right();
np->right = p; np->right = p;
p = np; p = np;
} }
void Tree::DoubleRotateLeft (TreeNode* &p) void Tree::DoubleRotateLeft (TreeNode* &p)
{ {
// two subtrees that are rotated // two subtrees that are rotated
TreeNode *lc, *np; TreeNode *lc, *np;
// in the tree, node(lc) <= node(np) < node(p) // in the tree, node(lc) <= node(np) < node(p)
lc = p->Right(); // lc is right child of parent lc = p->Right(); // lc is right child of parent
np = lc->Left(); // np is left child of lc np = lc->Left(); // np is left child of lc
// update balance factors for p, lc, and np // update balance factors for p, lc, and np
if (np->balanceFactor == leftheavy) if (np->balanceFactor == leftheavy)
{ {
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = leftheavy; lc->balanceFactor = leftheavy;
} }
else if (np->balanceFactor == balanced) else if (np->balanceFactor == balanced)
{ {
p->balanceFactor = balanced; p->balanceFactor = balanced;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
} }
else else
{ {
p->balanceFactor = leftheavy; p->balanceFactor = leftheavy;
lc->balanceFactor = balanced; lc->balanceFactor = balanced;
} }
np->balanceFactor = balanced; np->balanceFactor = balanced;
// before np replaces the parent p, take care of subtrees // before np replaces the parent p, take care of subtrees
// detach old children and attach new children // detach old children and attach new children
lc->left = np->Right(); lc->left = np->Right();
np->right = lc; np->right = lc;
p->right = np->Left(); p->right = np->Left();
np->left = p; np->left = p;
p = np; p = np;
} }
// if item is in the tree, delete it // if item is in the tree, delete it
void Tree::Delete(const int& item) void Tree::Delete(const int& item)
{ {
// DNodePtr = pointer to node D that is deleted // DNodePtr = pointer to node D that is deleted
// PNodePtr = pointer to parent P of node D // PNodePtr = pointer to parent P of node D
// RNodePtr = pointer to node R that replaces D // RNodePtr = pointer to node R that replaces D
TreeNode *DNodePtr, *PNodePtr, *RNodePtr; TreeNode *DNodePtr, *PNodePtr, *RNodePtr;
// search for a node containing data value item. obtain its // search for a node containing data value item. obtain its
// node address and that of its parent // node address and that of its parent
if ((DNodePtr = FindNode (item, PNodePtr)) == NULL) if ((DNodePtr = FindNode (item, PNodePtr)) == NULL)
return; return;
// If D has NULL pointer, the // If D has NULL pointer, the
// replacement node is the one on the other branch // replacement node is the one on the other branch
if (DNodePtr->right == NULL) if (DNodePtr->right == NULL)
RNodePtr = DNodePtr->left; RNodePtr = DNodePtr->left;
else if (DNodePtr->left == NULL) else if (DNodePtr->left == NULL)
RNodePtr = DNodePtr->right; RNodePtr = DNodePtr->right;
// Both pointers of DNodePtr are non-NULL // Both pointers of DNodePtr are non-NULL
else else
{ {
// Find and unlink replacement node for D // Find and unlink replacement node for D
// Starting on the left branch of node D, // Starting on the left branch of node D,
// find node whose data value is the largest of all // find node whose data value is the largest of all
// nodes whose values are less than the value in D // nodes whose values are less than the value in D
// Unlink the node from the tree // Unlink the node from the tree
// PofRNodePtr = pointer to parent of replacement node // PofRNodePtr = pointer to parent of replacement node
TreeNode *PofRNodePtr = DNodePtr; TreeNode *PofRNodePtr = DNodePtr;
// frist possible replacement is left child D // frist possible replacement is left child D
RNodePtr = DNodePtr->left; RNodePtr = DNodePtr->left;
// descend down right subtree of the left child of D // descend down right subtree of the left child of D
// keeping a record of current node and its parent. // keeping a record of current node and its parent.
// when we stop, we have found the replacement // when we stop, we have found the replacement
while (RNodePtr->right != NULL) while (RNodePtr->right != NULL)
{ {
PofRNodePtr = RNodePtr; PofRNodePtr = RNodePtr;
RNodePtr = RNodePtr; RNodePtr = RNodePtr;
} }
if (PofRNodePtr == DNodePtr) if (PofRNodePtr == DNodePtr)
// left child of deleted node is the replacement // left child of deleted node is the replacement
// assign right subtree of D to R // assign right subtree of D to R
RNodePtr->right = DNodePtr->right; RNodePtr->right = DNodePtr->right;
else else
{ {
// we moved at least one node down a right brance // we moved at least one node down a right brance
// delete replacement node from tree by assigning // delete replacement node from tree by assigning
// its left branc to its parent // its left branc to its parent
PofRNodePtr->right = RNodePtr->left; PofRNodePtr->right = RNodePtr->left;
// put replacement node in place of DNodePtr. // put replacement node in place of DNodePtr.
RNodePtr->left = DNodePtr->left; RNodePtr->left = DNodePtr->left;
RNodePtr->right = DNodePtr->right; RNodePtr->right = DNodePtr->right;
} }
} }
// complete the link to the parent node // complete the link to the parent node
// deleting the root node. assign new root // deleting the root node. assign new root
if (PNodePtr == NULL) if (PNodePtr == NULL)
root = RNodePtr; root = RNodePtr;
// attach R to the correct branch of P // attach R to the correct branch of P
else if (DNodePtr->data < PNodePtr->data) else if (DNodePtr->data < PNodePtr->data)
PNodePtr->left = RNodePtr; PNodePtr->left = RNodePtr;
else else
PNodePtr->right = RNodePtr; PNodePtr->right = RNodePtr;
// delete the node from memory and decrement list size // delete the node from memory and decrement list size
FreeTreeNode(DNodePtr); // this says FirstTreeNode in the book, should be a typo FreeTreeNode(DNodePtr); // this says FirstTreeNode in the book, should be a typo
size--; size--;
} }
@ -529,49 +529,49 @@ void Tree::Delete(const int& item)
// assign node value to item; otherwise, insert item in tree // assign node value to item; otherwise, insert item in tree
void Tree::Update(const int& item) void Tree::Update(const int& item)
{ {
if (current !=NULL && current->data == item) if (current !=NULL && current->data == item)
current->data = item; current->data = item;
else else
Insert(item, item); Insert(item, item);
} }
// create duplicate of tree t; return the new root // create duplicate of tree t; return the new root
TreeNode *Tree::CopyTree(TreeNode *t) TreeNode *Tree::CopyTree(TreeNode *t)
{ {
// variable newnode points at each new node that is // variable newnode points at each new node that is
// created by a call to GetTreeNode and later attached to // created by a call to GetTreeNode and later attached to
// the new tree. newlptr and newrptr point to the child of // the new tree. newlptr and newrptr point to the child of
// newnode and are passed as parameters to GetTreeNode // newnode and are passed as parameters to GetTreeNode
TreeNode *newlptr, *newrptr, *newnode; TreeNode *newlptr, *newrptr, *newnode;
// stop the recursive scan when we arrive at an empty tree // stop the recursive scan when we arrive at an empty tree
if (t == NULL) if (t == NULL)
return NULL; return NULL;
// CopyTree builds a new tree by scanning the nodes of t. // CopyTree builds a new tree by scanning the nodes of t.
// At each node in t, CopyTree checks for a left child. if // At each node in t, CopyTree checks for a left child. if
// present it makes a copy of left child or returns NULL. // present it makes a copy of left child or returns NULL.
// the algorithm similarly checks for a right child. // the algorithm similarly checks for a right child.
// CopyTree builds a copy of node using GetTreeNode and // CopyTree builds a copy of node using GetTreeNode and
// appends copy of left and right children to node. // appends copy of left and right children to node.
if (t->Left() !=NULL) if (t->Left() !=NULL)
newlptr = CopyTree(t->Left()); newlptr = CopyTree(t->Left());
else else
newlptr = NULL; newlptr = NULL;
if (t->Right() !=NULL) if (t->Right() !=NULL)
newrptr = CopyTree(t->Right()); newrptr = CopyTree(t->Right());
else else
newrptr = NULL; newrptr = NULL;
// Build new tree from the bottom up by building the two // Build new tree from the bottom up by building the two
// children and then building the parent // children and then building the parent
newnode = GetTreeNode(t->data, newlptr, newrptr); newnode = GetTreeNode(t->data, newlptr, newrptr);
// return a pointer to the newly created node // return a pointer to the newly created node
return newnode; return newnode;
} }
@ -598,16 +598,16 @@ void Tree::DeleteTree(TreeNode *t)
// set the root pointer back to NULL // set the root pointer back to NULL
void Tree::ClearTree(TreeNode * &t) void Tree::ClearTree(TreeNode * &t)
{ {
DeleteTree(t); DeleteTree(t);
t = NULL; // root now NULL t = NULL; // root now NULL
} }
// delete all nodes in list // delete all nodes in list
void Tree::ClearList(void) void Tree::ClearList(void)
{ {
delete root; delete root;
delete current; delete current;
size = 0; size = 0;
} }
#endif #endif

View File

@ -29,23 +29,23 @@ class TreeNode{
private: private:
// points to the left and right children of the node // points to the left and right children of the node
TreeNode *left; TreeNode *left;
TreeNode *right; TreeNode *right;
int balanceFactor; int balanceFactor;
int data; int data;
void * aux_data; void * aux_data;
public: public:
// make Tree a friend because it needs access to left and right pointer fields of a node // make Tree a friend because it needs access to left and right pointer fields of a node
friend class Tree; friend class Tree;
TreeNode * Left(); TreeNode * Left();
TreeNode * Right(); TreeNode * Right();
int GetData(); int GetData();
void * GetAuxData() {return aux_data;}; void * GetAuxData() {return aux_data;};
void SetAuxData(void * AuxData) {aux_data = AuxData;}; void SetAuxData(void * AuxData) {aux_data = AuxData;};
int GetBalanceFactor(); int GetBalanceFactor();
TreeNode(const int &item, TreeNode *lptr, TreeNode *rptr, int balfac = 0); TreeNode(const int &item, TreeNode *lptr, TreeNode *rptr, int balfac = 0);
//friend class DCASolver; //friend class DCASolver;
}; };
#endif #endif

View File

@ -2,7 +2,7 @@
*_________________________________________________________________________* *_________________________________________________________________________*
* POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE *
* DESCRIPTION: SEE READ-ME * * DESCRIPTION: SEE READ-ME *
* FILE NAME: points.h * * FILE NAME: points.h *
* AUTHORS: See Author List * * AUTHORS: See Author List *
* GRANTS: See Grants List * * GRANTS: See Grants List *
* COPYRIGHT: (C) 2005 by Authors as listed in Author's List * * COPYRIGHT: (C) 2005 by Authors as listed in Author's List *

View File

@ -47,8 +47,8 @@
class Joint; class Joint;
class System{ class System{
private: private:
int * mappings; int * mappings;
public: public:
double time; double time;
@ -61,7 +61,7 @@
int GetNumBodies(); int GetNumBodies();
int * GetMappings(); int * GetMappings();
void AddBody(Body* body); void AddBody(Body* body);

View File

@ -24,21 +24,21 @@
class VirtualColMatrix : public VirtualMatrix { class VirtualColMatrix : public VirtualMatrix {
public: public:
VirtualColMatrix(); VirtualColMatrix();
~VirtualColMatrix(); ~VirtualColMatrix();
double& operator_2int (int i, int j); // array access double& operator_2int (int i, int j); // array access
double Get_2int (int i, int j) const; double Get_2int (int i, int j) const;
void Set_2int (int i, int j, double value); void Set_2int (int i, int j, double value);
double BasicGet_2int(int i, int j) const; double BasicGet_2int(int i, int j) const;
void BasicSet_2int(int i, int j, double value); void BasicSet_2int(int i, int j, double value);
void BasicIncrement_2int(int i, int j, double value); void BasicIncrement_2int(int i, int j, double value);
virtual double& operator_1int (int i) = 0; // array access virtual double& operator_1int (int i) = 0; // array access
virtual double Get_1int(int i) const = 0; virtual double Get_1int(int i) const = 0;
virtual void Set_1int(int i, double value) = 0; virtual void Set_1int(int i, double value) = 0;
virtual double BasicGet_1int(int i) const = 0; virtual double BasicGet_1int(int i) const = 0;
virtual void BasicSet_1int(int i, double value) = 0; virtual void BasicSet_1int(int i, double value) = 0;
virtual void BasicIncrement_1int(int i, double value) = 0; virtual void BasicIncrement_1int(int i, double value) = 0;
}; };

View File

@ -21,62 +21,62 @@
#include <iostream> #include <iostream>
enum MatrixType { enum MatrixType {
MATRIX = 0, MATRIX = 0,
COLMATRIX = 1, COLMATRIX = 1,
ROWMATRIX = 2, ROWMATRIX = 2,
MAT3X3 = 3, MAT3X3 = 3,
VECT3 = 4, VECT3 = 4,
MAT6X6 = 5, MAT6X6 = 5,
VECT6 = 6, VECT6 = 6,
COLMATMAP = 7, COLMATMAP = 7,
VECT4 = 8, VECT4 = 8,
MAT4X4 = 9 MAT4X4 = 9
}; };
class VirtualMatrix { class VirtualMatrix {
protected: protected:
int numrows, numcols; int numrows, numcols;
public: public:
VirtualMatrix(); VirtualMatrix();
virtual ~VirtualMatrix(); virtual ~VirtualMatrix();
int GetNumRows() const; int GetNumRows() const;
int GetNumCols() const; int GetNumCols() const;
double& operator() (int i, int j); // array access double& operator() (int i, int j); // array access
double Get(int i, int j) const; double Get(int i, int j) const;
void Set(int i, int j, double value); void Set(int i, int j, double value);
double BasicGet(int i, int j) const; double BasicGet(int i, int j) const;
void BasicSet(int i, int j, double value); void BasicSet(int i, int j, double value);
void BasicIncrement(int i, int j, double value); void BasicIncrement(int i, int j, double value);
double& operator() (int i); // array access double& operator() (int i); // array access
double Get(int i) const; double Get(int i) const;
void Set(int i, double value); void Set(int i, double value);
double BasicGet(int i) const; double BasicGet(int i) const;
void BasicSet(int i, double value); void BasicSet(int i, double value);
void BasicIncrement(int i, double value); void BasicIncrement(int i, double value);
virtual void Const(double value) = 0; virtual void Const(double value) = 0;
virtual MatrixType GetType() const = 0; virtual MatrixType GetType() const = 0;
virtual void AssignVM(const VirtualMatrix& A) = 0; virtual void AssignVM(const VirtualMatrix& A) = 0;
void Zeros(); void Zeros();
void Ones(); void Ones();
virtual std::ostream& WriteData(std::ostream& c) const; virtual std::ostream& WriteData(std::ostream& c) const;
virtual std::istream& ReadData(std::istream& c); virtual std::istream& ReadData(std::istream& c);
protected: protected:
virtual double& operator_2int(int i, int j) = 0; virtual double& operator_2int(int i, int j) = 0;
virtual double& operator_1int(int i); virtual double& operator_1int(int i);
virtual double Get_2int(int i, int j) const = 0; virtual double Get_2int(int i, int j) const = 0;
virtual double Get_1int(int i) const ; virtual double Get_1int(int i) const ;
virtual void Set_2int(int i, int j, double value) = 0; virtual void Set_2int(int i, int j, double value) = 0;
virtual void Set_1int(int i, double value); virtual void Set_1int(int i, double value);
virtual double BasicGet_2int(int i, int j) const = 0; virtual double BasicGet_2int(int i, int j) const = 0;
virtual double BasicGet_1int(int i) const ; virtual double BasicGet_1int(int i) const ;
virtual void BasicSet_2int(int i, int j, double value) = 0; virtual void BasicSet_2int(int i, int j, double value) = 0;
virtual void BasicSet_1int(int i, double value); virtual void BasicSet_1int(int i, double value);
virtual void BasicIncrement_2int(int i, int j, double value) = 0; virtual void BasicIncrement_2int(int i, int j, double value) = 0;
virtual void BasicIncrement_1int(int i, double value); virtual void BasicIncrement_1int(int i, double value);
}; };

View File

@ -32,15 +32,15 @@ class System;
class Solver; class Solver;
struct SysData{ struct SysData{
System * system; System * system;
int solver; int solver;
int integrator; int integrator;
}; };
class Workspace { class Workspace {
SysData * system; // the multibody systems data SysData * system; // the multibody systems data
int currentIndex; int currentIndex;
int maxAlloc; int maxAlloc;
public: public:
Workspace(); Workspace();
@ -50,7 +50,7 @@ public:
double Tfull; double Tfull;
double ConFac; double ConFac;
double KE_val; double KE_val;
int FirstTime; int FirstTime;
bool LoadFile(char* filename); bool LoadFile(char* filename);
@ -69,20 +69,20 @@ public:
bool MakeSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, int &njoint, int **&jointbody, double **&xjoint, int& nfree, int*freelist, double dthalf, double dtv, double tempcon, double KE); bool MakeSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, int &njoint, int **&jointbody, double **&xjoint, int& nfree, int*freelist, double dthalf, double dtv, double tempcon, double KE);
bool SaveSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&xjoint, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, double **&acm, double **&alpha, double **&torque, double **&fcm, int **&jointbody, int &njoint); bool SaveSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&xjoint, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, double **&acm, double **&alpha, double **&torque, double **&fcm, int **&jointbody, int &njoint);
bool MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space); bool MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space);
int getNumberOfSystems(); int getNumberOfSystems();
void SetLammpsValues(double dtv, double dthalf, double tempcon); void SetLammpsValues(double dtv, double dthalf, double tempcon);
void SetKE(int temp, double SysKE); void SetKE(int temp, double SysKE);
void RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space); void RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space);
void WriteFile(char* filename); void WriteFile(char* filename);
private: private:
void allocateNewSystem(); //helper function to handle vector resizing and such for the array of system pointers void allocateNewSystem(); //helper function to handle vector resizing and such for the array of system pointers
}; };
#endif #endif