whitespace cleanup: replace tabs and remove trailing whitespace
This commit is contained in:
@ -26,7 +26,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Put together by John Smith john at arrows dot demon dot co dot uk,
|
// Put together by John Smith john at arrows dot demon dot co dot uk,
|
||||||
// using ideas by others.
|
// using ideas by others.
|
||||||
//
|
//
|
||||||
// Calculate erf(z) for complex z.
|
// Calculate erf(z) for complex z.
|
||||||
@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
//
|
//
|
||||||
// The code includes some hard coded constants that are intended to
|
// The code includes some hard coded constants that are intended to
|
||||||
// give about 14 decimal places of accuracy. This is appropriate for
|
// give about 14 decimal places of accuracy. This is appropriate for
|
||||||
// 64-bit floating point numbers.
|
// 64-bit floating point numbers.
|
||||||
//
|
//
|
||||||
// Oct 1999: Fixed a typo that in
|
// Oct 1999: Fixed a typo that in
|
||||||
// const Complex cerf_continued_fraction( const Complex z )
|
// const Complex cerf_continued_fraction( const Complex z )
|
||||||
@ -46,14 +46,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
// Abramowitz and Stegun: (eqn: 7.1.14) gives this continued
|
// Abramowitz and Stegun: (eqn: 7.1.14) gives this continued
|
||||||
// fraction for erfc(z)
|
// fraction for erfc(z)
|
||||||
//
|
//
|
||||||
// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2
|
// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2
|
||||||
// --- --- --- --- --- --- ...
|
// --- --- --- --- --- --- ...
|
||||||
// z + z + z + z + z + z +
|
// z + z + z + z + z + z +
|
||||||
//
|
//
|
||||||
// This is evaluated using Lentz's method, as described in the narative
|
// This is evaluated using Lentz's method, as described in the narative
|
||||||
// of Numerical Recipes in C.
|
// of Numerical Recipes in C.
|
||||||
//
|
//
|
||||||
// The continued fraction is true providing real(z)>0. In practice we
|
// The continued fraction is true providing real(z)>0. In practice we
|
||||||
// like real(z) to be significantly greater than 0, say greater than 0.5.
|
// like real(z) to be significantly greater than 0, say greater than 0.5.
|
||||||
//
|
//
|
||||||
template< class Complex>
|
template< class Complex>
|
||||||
@ -63,9 +63,9 @@ const Complex cerfc_continued_fraction( const Complex z )
|
|||||||
double eps = 1e-15 ; // large enough so that 1.0+eps > 1.0, when using
|
double eps = 1e-15 ; // large enough so that 1.0+eps > 1.0, when using
|
||||||
// the floating point arithmetic
|
// the floating point arithmetic
|
||||||
//
|
//
|
||||||
// first calculate z+ 1/2 1
|
// first calculate z+ 1/2 1
|
||||||
// --- --- ...
|
// --- --- ...
|
||||||
// z + z +
|
// z + z +
|
||||||
Complex f(z) ;
|
Complex f(z) ;
|
||||||
Complex C(f) ;
|
Complex C(f) ;
|
||||||
Complex D(0.0) ;
|
Complex D(0.0) ;
|
||||||
@ -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 ;
|
||||||
|
|
||||||
@ -134,9 +134,9 @@ const Complex cerf_series( const Complex z )
|
|||||||
|
|
||||||
return sum * 2.0 / sqrt(M_PI) ;
|
return sum * 2.0 / sqrt(M_PI) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Numerical Recipes quotes a formula due to Rybicki for evaluating
|
// Numerical Recipes quotes a formula due to Rybicki for evaluating
|
||||||
// Dawson's Integral:
|
// Dawson's Integral:
|
||||||
//
|
//
|
||||||
// exp(-x^2) integral exp(t^2).dt = 1/sqrt(pi) lim sum exp(-(z-n.h)^2) / n
|
// exp(-x^2) integral exp(t^2).dt = 1/sqrt(pi) lim sum exp(-(z-n.h)^2) / n
|
||||||
@ -151,9 +151,9 @@ const Complex cerf_rybicki( const Complex z )
|
|||||||
double h = 0.2 ; // numerical experiment suggests this is small enough
|
double h = 0.2 ; // numerical experiment suggests this is small enough
|
||||||
|
|
||||||
//
|
//
|
||||||
// choose an even n0, and then shift z->z-n0.h and n->n-h.
|
// choose an even n0, and then shift z->z-n0.h and n->n-h.
|
||||||
// n0 is chosen so that real((z-n0.h)^2) is as small as possible.
|
// n0 is chosen so that real((z-n0.h)^2) is as small as possible.
|
||||||
//
|
//
|
||||||
int n0 = 2*(int) (floor( z.imag()/(2*h) + 0.5 )) ;
|
int n0 = 2*(int) (floor( z.imag()/(2*h) + 0.5 )) ;
|
||||||
|
|
||||||
Complex z0( 0.0, n0*h ) ;
|
Complex z0( 0.0, n0*h ) ;
|
||||||
@ -161,14 +161,14 @@ const Complex cerf_rybicki( const Complex z )
|
|||||||
Complex sum(0.0,0.0) ;
|
Complex sum(0.0,0.0) ;
|
||||||
//
|
//
|
||||||
// limits of sum chosen so that the end sums of the sum are
|
// limits of sum chosen so that the end sums of the sum are
|
||||||
// fairly small. In this case exp(-(35.h)^2)=5e-22
|
// fairly small. In this case exp(-(35.h)^2)=5e-22
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
for (int np=-35; np<=35; np+=2)
|
for (int np=-35; np<=35; np+=2)
|
||||||
{
|
{
|
||||||
Complex t( zp.real(), zp.imag()-np*h) ;
|
Complex t( zp.real(), zp.imag()-np*h) ;
|
||||||
Complex b( exp(t*t) / (np+n0) ) ;
|
Complex b( exp(t*t) / (np+n0) ) ;
|
||||||
sum += b ;
|
sum += b ;
|
||||||
}
|
}
|
||||||
|
|
||||||
sum = sum * 2 * exp(-z*z) / M_PI ;
|
sum = sum * 2 * exp(-z*z) / M_PI ;
|
||||||
@ -180,7 +180,7 @@ template< class Complex>
|
|||||||
const Complex cerf( const Complex z )
|
const Complex cerf( const Complex z )
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Use the method appropriate to size of z -
|
// Use the method appropriate to size of z -
|
||||||
// there probably ought to be an extra option for NaN z, or infinite z
|
// there probably ought to be an extra option for NaN z, or infinite z
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -194,20 +194,20 @@ const Complex cerf( const Complex z )
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Footnote:
|
// Footnote:
|
||||||
//
|
//
|
||||||
// Using the definitions from Abramowitz and Stegun (7.3.1, 7.3.2)
|
// Using the definitions from Abramowitz and Stegun (7.3.1, 7.3.2)
|
||||||
// The fresnel intgerals defined as:
|
// The fresnel intgerals defined as:
|
||||||
//
|
//
|
||||||
// / t=x
|
// / t=x
|
||||||
// C(x) = | cos(pi/2 t^2) dt
|
// C(x) = | cos(pi/2 t^2) dt
|
||||||
// /
|
// /
|
||||||
// t=0
|
// t=0
|
||||||
//
|
//
|
||||||
// and
|
// and
|
||||||
// / t=x
|
// / t=x
|
||||||
// S(x) = | sin(pi/2 t^2) dt
|
// S(x) = | sin(pi/2 t^2) dt
|
||||||
// /
|
// /
|
||||||
// t=0
|
// t=0
|
||||||
//
|
//
|
||||||
// These can be derived from erf(x) using 7.3.22
|
// These can be derived from erf(x) using 7.3.22
|
||||||
//
|
//
|
||||||
@ -216,8 +216,8 @@ const Complex cerf( const Complex z )
|
|||||||
// 2
|
// 2
|
||||||
//
|
//
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Some test examples -
|
// Some test examples -
|
||||||
// comparative data taken from Abramowitz and Stegun table 7.9.
|
// comparative data taken from Abramowitz and Stegun table 7.9.
|
||||||
// Table 7.9 tabulates w(z), where w(z) = exp(-z*z) erfc(iz)
|
// Table 7.9 tabulates w(z), where w(z) = exp(-z*z) erfc(iz)
|
||||||
// I have copied twelve values of w(z) from the table, and separately
|
// I have copied twelve values of w(z) from the table, and separately
|
||||||
// calculated them using this code. The results are identical.
|
// calculated them using this code. The results are identical.
|
||||||
|
|||||||
@ -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****************************************************************************
|
||||||
@ -250,7 +250,7 @@ public:
|
|||||||
if(man){
|
if(man){
|
||||||
iterator it=base_t::begin();
|
iterator it=base_t::begin();
|
||||||
for(;it!=base_t::end();++it)
|
for(;it!=base_t::end();++it)
|
||||||
if(*it)
|
if(*it)
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
base_t::clear();
|
base_t::clear();
|
||||||
@ -427,7 +427,7 @@ class RefObject{
|
|||||||
void *ref_data;
|
void *ref_data;
|
||||||
int ref_count;
|
int ref_count;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void delete_data(void *data);
|
virtual void delete_data(void *data);
|
||||||
virtual void *new_data();
|
virtual void *new_data();
|
||||||
@ -437,7 +437,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
class RefA: public RefObject{
|
class RefA: public RefObject{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
refA(){
|
refA(){
|
||||||
ref_data = new A;
|
ref_data = new A;
|
||||||
|
|||||||
@ -2,12 +2,12 @@
|
|||||||
*
|
*
|
||||||
* 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
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/*s****************************************************************************
|
/*s****************************************************************************
|
||||||
* $Log: wpmd.h,v $
|
* $Log: wpmd.h,v $
|
||||||
* Revision 1.4 2011/06/11 16:53:55 valuev
|
* Revision 1.4 2011/06/11 16:53:55 valuev
|
||||||
@ -134,8 +134,8 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
# ifndef WPMD_H
|
# ifndef WPMD_H
|
||||||
# define WPMD_H
|
# define WPMD_H
|
||||||
|
|
||||||
/** @file wpmd.h
|
/** @file wpmd.h
|
||||||
@brief Classes for Wave Packet Molecular Dynamics of two component plasma. */
|
@brief Classes for Wave Packet Molecular Dynamics of two component plasma. */
|
||||||
|
|
||||||
# ifndef _USE_MATH_DEFINES
|
# ifndef _USE_MATH_DEFINES
|
||||||
@ -143,7 +143,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# include <complex>
|
# include <complex>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
# include <cmath>
|
# include <cmath>
|
||||||
# include "logexc.h"
|
# include "logexc.h"
|
||||||
# include "cvector_3.h"
|
# include "cvector_3.h"
|
||||||
# include "pairhash.h"
|
# include "pairhash.h"
|
||||||
@ -168,7 +168,7 @@ const double h_plank2 = h_plank * 2.;
|
|||||||
inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){
|
inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){
|
||||||
if((fabs(real(z))+fabs(imag(z)))<1e-8)
|
if((fabs(real(z))+fabs(imag(z)))<1e-8)
|
||||||
return c*two_over_sqr_pi;
|
return c*two_over_sqr_pi;
|
||||||
else
|
else
|
||||||
return cerf(z*c)/z;
|
return cerf(z*c)/z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){
|
|||||||
inline double erf_div(const double &z, double c=1){
|
inline double erf_div(const double &z, double c=1){
|
||||||
if(fabs(z)<1e-8)
|
if(fabs(z)<1e-8)
|
||||||
return c*two_over_sqr_pi;
|
return c*two_over_sqr_pi;
|
||||||
else
|
else
|
||||||
return erf(z*c)/z;
|
return erf(z*c)/z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
OverlapDeriv():I0(0),I1(0),IDD(10){}
|
OverlapDeriv():I0(0),I1(0),IDD(10){}
|
||||||
|
|
||||||
void set1(const WavePacket& w1_) {
|
void set1(const WavePacket& w1_) {
|
||||||
w1=w1_;
|
w1=w1_;
|
||||||
d1.set(w1);
|
d1.set(w1);
|
||||||
@ -330,7 +330,7 @@ public:
|
|||||||
|
|
||||||
enum {NORM_UNDEFINED, NORM_CALCULATED, NORM_FACTORIZED, NORM_INVERTED};
|
enum {NORM_UNDEFINED, NORM_CALCULATED, NORM_FACTORIZED, NORM_INVERTED};
|
||||||
int norm_matrix_state[2];
|
int norm_matrix_state[2];
|
||||||
|
|
||||||
// Arrays for temporal data
|
// Arrays for temporal data
|
||||||
chmatrix IDD; // Second derivatives of the overlap integral (used in Norm matrix)
|
chmatrix IDD; // Second derivatives of the overlap integral (used in Norm matrix)
|
||||||
vector<cdouble> ID, IDYs; // First derivatives of the overlap integral (used in Norm matrix)
|
vector<cdouble> ID, IDYs; // First derivatives of the overlap integral (used in Norm matrix)
|
||||||
@ -346,7 +346,7 @@ public:
|
|||||||
/// HARTREE Hartree product (no antisymmetrization) \n
|
/// HARTREE Hartree product (no antisymmetrization) \n
|
||||||
/// DPRODUCT product of det0*det1 of antisymmetrized functions for spins 0, 1 \n
|
/// DPRODUCT product of det0*det1 of antisymmetrized functions for spins 0, 1 \n
|
||||||
/// UHF unrestricted Hartree-Fock
|
/// UHF unrestricted Hartree-Fock
|
||||||
enum APPROX {HARTREE, DPRODUCT, UHF } approx;
|
enum APPROX {HARTREE, DPRODUCT, UHF } approx;
|
||||||
///\em Sets overlap matrix element to zero if the overlap norm is less than this value
|
///\em Sets overlap matrix element to zero if the overlap norm is less than this value
|
||||||
double ovl_tolerance;
|
double ovl_tolerance;
|
||||||
|
|
||||||
@ -375,14 +375,14 @@ public:
|
|||||||
|
|
||||||
///\en 0 -- indicates that the inter-partition force should be full, and energy half,\n
|
///\en 0 -- indicates that the inter-partition force should be full, and energy half,\n
|
||||||
/// 1 -- inter-partition force and energy counts one half (LAMMPS compatibility)
|
/// 1 -- inter-partition force and energy counts one half (LAMMPS compatibility)
|
||||||
int newton_pair;
|
int newton_pair;
|
||||||
|
|
||||||
//int myid; ///<\en id for partitions
|
//int myid; ///<\en id for partitions
|
||||||
|
|
||||||
///\en Partition arrays storing the tags of particles. The initial tags should be >0.
|
///\en Partition arrays storing the tags of particles. The initial tags should be >0.
|
||||||
/// If the tag stored is <0, then the particle is ghost with -tag.
|
/// If the tag stored is <0, then the particle is ghost with -tag.
|
||||||
/// partition1[2] is for ions, 0, 1 for each electron spin
|
/// partition1[2] is for ions, 0, 1 for each electron spin
|
||||||
vector<int> partition1[3];
|
vector<int> partition1[3];
|
||||||
//vector<int> partition2[3]; ///<\en 2 for ions
|
//vector<int> partition2[3]; ///<\en 2 for ions
|
||||||
|
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term
|
///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term
|
||||||
int check_ee(int s1,int icj1,int ick2){
|
int check_ee(int s1,int icj1,int ick2){
|
||||||
//printf(" (%d %d) ",partition1[s1][icj1],partition1[s1][ick2]);
|
//printf(" (%d %d) ",partition1[s1][icj1],partition1[s1][ick2]);
|
||||||
int c1=(int)(partition1[s1][icj1]>0);
|
int c1=(int)(partition1[s1][icj1]>0);
|
||||||
@ -402,8 +402,8 @@ public:
|
|||||||
int tag2=abs(partition1[s1][ick2]);
|
int tag2=abs(partition1[s1][ick2]);
|
||||||
int num=tag_index(tag1-1,tag2-1);
|
int num=tag_index(tag1-1,tag2-1);
|
||||||
if(num<0){ // compare wave packets
|
if(num<0){ // compare wave packets
|
||||||
int cmp= s1<2 ?
|
int cmp= s1<2 ?
|
||||||
wp[s1][icj1].compare(wp[s1][ick2],1e-15) :
|
wp[s1][icj1].compare(wp[s1][ick2],1e-15) :
|
||||||
compare_vec(xi[icj1],xi[ick2],1e-15);
|
compare_vec(xi[icj1],xi[ick2],1e-15);
|
||||||
if((cmp>0 && c1) || (cmp<0 && c2))
|
if((cmp>0 && c1) || (cmp<0 && c2))
|
||||||
res= 2; // my mixed term
|
res= 2; // my mixed term
|
||||||
@ -421,12 +421,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///\en Returns electron-electron inter-partition multipliers for energy (first) and force (second)
|
///\en Returns electron-electron inter-partition multipliers for energy (first) and force (second)
|
||||||
/// for a 4- and 2- electron additive terms (all inter-partition interactions are
|
/// for a 4- and 2- electron additive terms (all inter-partition interactions are
|
||||||
/// calculated only once based on particle tags)
|
/// calculated only once based on particle tags)
|
||||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||||
/// NOW ASSIGNS BASED ON THE FIRST PAIR ONLY
|
/// NOW ASSIGNS BASED ON THE FIRST PAIR ONLY
|
||||||
pair<double, double> check_part1(int s1,int icj1,int ick2){
|
pair<double, double> check_part1(int s1,int icj1,int ick2){
|
||||||
int res=check_ee(s1,icj1,ick2);
|
int res=check_ee(s1,icj1,ick2);
|
||||||
if(res==1){ // my term
|
if(res==1){ // my term
|
||||||
//printf(" *\n");
|
//printf(" *\n");
|
||||||
return make_pair(1.,1.); // all at my partition
|
return make_pair(1.,1.); // all at my partition
|
||||||
@ -439,7 +439,7 @@ public:
|
|||||||
//printf(" *\n");
|
//printf(" *\n");
|
||||||
return make_pair(1.,1.); // my inter-partition
|
return make_pair(1.,1.); // my inter-partition
|
||||||
}
|
}
|
||||||
else if(res==-2){
|
else if(res==-2){
|
||||||
//printf(" \n");
|
//printf(" \n");
|
||||||
return make_pair(0., newton_pair ? 0.0 : 1. ); // other inter-partition: must add force if newton comm is off
|
return make_pair(0., newton_pair ? 0.0 : 1. ); // other inter-partition: must add force if newton comm is off
|
||||||
}
|
}
|
||||||
@ -447,18 +447,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///\en Returns elctron-ion inter-partition multipliers for energy (first) and force (second)
|
///\en Returns elctron-ion inter-partition multipliers for energy (first) and force (second)
|
||||||
/// for ion-electron additive terms (all inter-partition interactions are
|
/// for ion-electron additive terms (all inter-partition interactions are
|
||||||
/// calculated only once based on particle tags)
|
/// calculated only once based on particle tags)
|
||||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||||
/// BASED ON ION ATTACHMENT
|
/// BASED ON ION ATTACHMENT
|
||||||
pair<double,double> check_part1ei(int s1,int icj1,int ick2, int ion){
|
pair<double,double> check_part1ei(int s1,int icj1,int ick2, int ion){
|
||||||
//printf("%d ",partition1[2][ion]);
|
//printf("%d ",partition1[2][ion]);
|
||||||
int ci=(int)(partition1[2][ion]>0);
|
int ci=(int)(partition1[2][ion]>0);
|
||||||
|
|
||||||
if(!newton_pair){ // care about mixed terms
|
if(!newton_pair){ // care about mixed terms
|
||||||
int cee=check_ee(s1,icj1,ick2);
|
int cee=check_ee(s1,icj1,ick2);
|
||||||
if((cee==2 || cee==-2) || (ci && cee==-1) || (!ci && cee==1)) // all mixed variants
|
if((cee==2 || cee==-2) || (ci && cee==-1) || (!ci && cee==1)) // all mixed variants
|
||||||
make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off
|
make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off
|
||||||
}
|
}
|
||||||
if(ci){
|
if(ci){
|
||||||
//printf(" *\n");
|
//printf(" *\n");
|
||||||
@ -471,7 +471,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///\en Returns ion-ion inter-partition multipliers for energy (first) and force (second)
|
///\en Returns ion-ion inter-partition multipliers for energy (first) and force (second)
|
||||||
/// for ion-electron additive terms (all inter-partition interactions are
|
/// for ion-electron additive terms (all inter-partition interactions are
|
||||||
/// calculated only once based on particle tags)
|
/// calculated only once based on particle tags)
|
||||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||||
pair<double,double> check_part1ii(int ion1, int ion2){
|
pair<double,double> check_part1ii(int ion1, int ion2){
|
||||||
@ -485,7 +485,7 @@ public:
|
|||||||
norm_matrix_state[0] = norm_matrix_state[1] = NORM_UNDEFINED;
|
norm_matrix_state[0] = norm_matrix_state[1] = NORM_UNDEFINED;
|
||||||
ovl_tolerance=0.;
|
ovl_tolerance=0.;
|
||||||
approx = DPRODUCT;
|
approx = DPRODUCT;
|
||||||
|
|
||||||
me=m_electron;
|
me=m_electron;
|
||||||
one_h=1./h_plank;
|
one_h=1./h_plank;
|
||||||
h2_me=h_sq/me;
|
h2_me=h_sq/me;
|
||||||
@ -530,11 +530,11 @@ protected:
|
|||||||
///\en resizes all internal arrays according to new electrons added
|
///\en resizes all internal arrays according to new electrons added
|
||||||
virtual void resize(int flag);
|
virtual void resize(int flag);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///\en Prepares to setup a new system of particles using \ref add_ion() and add_electron().
|
///\en Prepares to setup a new system of particles using \ref add_ion() and add_electron().
|
||||||
/// There is no need to call this function when using
|
/// There is no need to call this function when using
|
||||||
/// \ref set_electrons() and \ref set_ions() to setup particles.
|
/// \ref set_electrons() and \ref set_ions() to setup particles.
|
||||||
virtual void reset(){
|
virtual void reset(){
|
||||||
for(int s=0;s<2;s++){
|
for(int s=0;s<2;s++){
|
||||||
@ -556,10 +556,10 @@ public:
|
|||||||
//e 0x4 -- PBC along Z
|
//e 0x4 -- PBC along Z
|
||||||
//e cell specifies the lengths of the simulation box in all directions
|
//e cell specifies the lengths of the simulation box in all directions
|
||||||
//e if PBCs are used, the corresponding coordinates of electrons and ions
|
//e if PBCs are used, the corresponding coordinates of electrons and ions
|
||||||
//e in periodic directions must be within the range [0, cell[per_dir])
|
//e in periodic directions must be within the range [0, cell[per_dir])
|
||||||
//e @returns 1 if OK
|
//e @returns 1 if OK
|
||||||
int set_pbc(const Vector_3P pcell=NULL, int pbc_=0x7);
|
int set_pbc(const Vector_3P pcell=NULL, int pbc_=0x7);
|
||||||
|
|
||||||
///\en Setup electrons: forms internal wave packet representations.
|
///\en Setup electrons: forms internal wave packet representations.
|
||||||
/// If PBCs are used the coords must be within a range [0, cell).
|
/// If PBCs are used the coords must be within a range [0, cell).
|
||||||
/// Default electron mass is AWPMD::me.
|
/// Default electron mass is AWPMD::me.
|
||||||
@ -572,9 +572,9 @@ public:
|
|||||||
|
|
||||||
///\en Adds an ion with charge q and position x,
|
///\en Adds an ion with charge q and position x,
|
||||||
/// \return id of the ion starting from 0
|
/// \return id of the ion starting from 0
|
||||||
/// The tags must be nonzero, >0 for the local particle, <0 for ghost particle.
|
/// The tags must be nonzero, >0 for the local particle, <0 for ghost particle.
|
||||||
/// Unique particle id is abs(tag).
|
/// Unique particle id is abs(tag).
|
||||||
/// Default tag (0) means inserting the current particle id as local particle.
|
/// Default tag (0) means inserting the current particle id as local particle.
|
||||||
int add_ion(double q, const Vector_3 &x, int tag=0){
|
int add_ion(double q, const Vector_3 &x, int tag=0){
|
||||||
qi.push_back(q);
|
qi.push_back(q);
|
||||||
xi.push_back(x);
|
xi.push_back(x);
|
||||||
@ -586,24 +586,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//e calculates interaction in the system of ni ions + electrons
|
//e calculates interaction in the system of ni ions + electrons
|
||||||
//e the electonic subsystem must be previously setup by set_electrons, ionic by set_ions
|
//e the electonic subsystem must be previously setup by set_electrons, ionic by set_ions
|
||||||
//e the iterators are describing ionic system only
|
//e the iterators are describing ionic system only
|
||||||
// 0x1 -- give back ion forces
|
// 0x1 -- give back ion forces
|
||||||
// 0x2 -- add ion forces to the existing set
|
// 0x2 -- add ion forces to the existing set
|
||||||
// 0x4 -- calculate derivatives for electronic time step (NOT IMPLEMENTED)
|
// 0x4 -- calculate derivatives for electronic time step (NOT IMPLEMENTED)
|
||||||
//e if PBCs are used the coords must be within a range [0, cell)
|
//e if PBCs are used the coords must be within a range [0, cell)
|
||||||
virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||||
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
||||||
|
|
||||||
//e same as interaction, but using Hartee factorization (no antisymmetrization)
|
//e same as interaction, but using Hartee factorization (no antisymmetrization)
|
||||||
virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||||
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
||||||
|
|
||||||
///\en Calculates ion-ion interactions and updates Eii and ion forces if requested. This function
|
///\en Calculates ion-ion interactions and updates Eii and ion forces if requested. This function
|
||||||
/// is called form intaraction() and interaction_hartree if calc_ii is set.
|
/// is called form intaraction() and interaction_hartree if calc_ii is set.
|
||||||
virtual int interaction_ii(int flag,Vector_3P fi=NULL);
|
virtual int interaction_ii(int flag,Vector_3P fi=NULL);
|
||||||
|
|
||||||
//e Calculates Norm matrix
|
//e Calculates Norm matrix
|
||||||
//e The result is saved in AWPMD::Norm[s]
|
//e The result is saved in AWPMD::Norm[s]
|
||||||
void norm_matrix(int s);
|
void norm_matrix(int s);
|
||||||
@ -642,7 +642,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///\en Prepares force arrays according to \a flag setting for interaction()
|
///\en Prepares force arrays according to \a flag setting for interaction()
|
||||||
virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x,
|
virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x,
|
||||||
Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c=NULL);
|
Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c=NULL);
|
||||||
|
|
||||||
|
|
||||||
@ -651,7 +651,7 @@ public:
|
|||||||
/// Default mass (-1) is the electron mass AWPMD::me.
|
/// Default mass (-1) is the electron mass AWPMD::me.
|
||||||
WavePacket create_wp(Vector_3 &x, Vector_3 &v, double &w, double &pw, double mass=-1);
|
WavePacket create_wp(Vector_3 &x, Vector_3 &v, double &w, double &pw, double mass=-1);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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(),
|
||||||
|
|||||||
@ -3,13 +3,13 @@
|
|||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// $Revision: 3572$
|
// $Revision: 3572$
|
||||||
// $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $
|
// $Date: 2010-11-23 13:04:43 -0700 (Tue, 23 Nov 2010) $
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// This source code is distributed under the terms of license.txt
|
// This source code is distributed under the terms of license.txt
|
||||||
// in the root directory of this source distribution.
|
// in the root directory of this source distribution.
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
#ifndef __CUDPP_PLAN_H__
|
#ifndef __CUDPP_PLAN_H__
|
||||||
#define __CUDPP_PLAN_H__
|
#define __CUDPP_PLAN_H__
|
||||||
|
|
||||||
typedef void* KernelPointer;
|
typedef void* KernelPointer;
|
||||||
|
|
||||||
extern "C" size_t getNumCTAs(KernelPointer kernel);
|
extern "C" size_t getNumCTAs(KernelPointer kernel);
|
||||||
@ -30,10 +30,10 @@ void computeNumCTAs(T kernel, unsigned int bytesDynamicSharedMem, size_t threads
|
|||||||
/** @brief Base class for CUDPP Plan data structures
|
/** @brief Base class for CUDPP Plan data structures
|
||||||
*
|
*
|
||||||
* CUDPPPlan and its subclasses provide the internal (i.e. not visible to the
|
* CUDPPPlan and its subclasses provide the internal (i.e. not visible to the
|
||||||
* library user) infrastructure for planning algorithm execution. They
|
* library user) infrastructure for planning algorithm execution. They
|
||||||
* own intermediate storage for CUDPP algorithms as well as, in some cases,
|
* own intermediate storage for CUDPP algorithms as well as, in some cases,
|
||||||
* information about optimal execution configuration for the present hardware.
|
* information about optimal execution configuration for the present hardware.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CUDPPPlan
|
class CUDPPPlan
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
CUDPPScanPlan *m_scanPlan; //!< @internal Compact performs a scan of type unsigned int using this plan
|
CUDPPScanPlan *m_scanPlan; //!< @internal Compact performs a scan of type unsigned int using this plan
|
||||||
unsigned int* m_d_outputIndices; //!< @internal Output address of compacted elements; this is the result of scan
|
unsigned int* m_d_outputIndices; //!< @internal Output address of compacted elements; this is the result of scan
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CUDPPRadixSortPlan : public CUDPPPlan
|
class CUDPPRadixSortPlan : public CUDPPPlan
|
||||||
@ -99,7 +99,7 @@ class CUDPPRadixSortPlan : public CUDPPPlan
|
|||||||
public:
|
public:
|
||||||
CUDPPRadixSortPlan(CUDPPConfiguration config, size_t numElements);
|
CUDPPRadixSortPlan(CUDPPConfiguration config, size_t numElements);
|
||||||
virtual ~CUDPPRadixSortPlan();
|
virtual ~CUDPPRadixSortPlan();
|
||||||
|
|
||||||
bool m_bKeysOnly;
|
bool m_bKeysOnly;
|
||||||
bool m_bManualCoalesce;
|
bool m_bManualCoalesce;
|
||||||
bool m_bUsePersistentCTAs;
|
bool m_bUsePersistentCTAs;
|
||||||
@ -123,22 +123,22 @@ class CUDPPSparseMatrixVectorMultiplyPlan : public CUDPPPlan
|
|||||||
public:
|
public:
|
||||||
CUDPPSparseMatrixVectorMultiplyPlan(CUDPPConfiguration config, size_t numNZElts,
|
CUDPPSparseMatrixVectorMultiplyPlan(CUDPPConfiguration config, size_t numNZElts,
|
||||||
const void *A,
|
const void *A,
|
||||||
const unsigned int *rowindx,
|
const unsigned int *rowindx,
|
||||||
const unsigned int *indx, size_t numRows);
|
const unsigned int *indx, size_t numRows);
|
||||||
virtual ~CUDPPSparseMatrixVectorMultiplyPlan();
|
virtual ~CUDPPSparseMatrixVectorMultiplyPlan();
|
||||||
|
|
||||||
CUDPPSegmentedScanPlan *m_segmentedScanPlan; //!< @internal Performs a segmented scan of type T using this plan
|
CUDPPSegmentedScanPlan *m_segmentedScanPlan; //!< @internal Performs a segmented scan of type T using this plan
|
||||||
void *m_d_prod; //!< @internal Vector of products (of an element in A and its corresponding (thats is
|
void *m_d_prod; //!< @internal Vector of products (of an element in A and its corresponding (thats is
|
||||||
//! belongs to the same row) element in x; this is the input and output of
|
//! belongs to the same row) element in x; this is the input and output of
|
||||||
//! segmented scan
|
//! segmented scan
|
||||||
unsigned int *m_d_flags; //!< @internal Vector of flags where a flag is set if an element of A is the first element
|
unsigned int *m_d_flags; //!< @internal Vector of flags where a flag is set if an element of A is the first element
|
||||||
//! of its row; this is the flags vector for segmented scan
|
//! of its row; this is the flags vector for segmented scan
|
||||||
unsigned int *m_d_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
unsigned int *m_d_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
||||||
//! which is the last element of that row. Resides in GPU memory.
|
//! which is the last element of that row. Resides in GPU memory.
|
||||||
unsigned int *m_d_rowIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
unsigned int *m_d_rowIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
||||||
//! which is the first element of that row. Resides in GPU memory.
|
//! which is the first element of that row. Resides in GPU memory.
|
||||||
unsigned int *m_d_index; //!<@internal Vector of column numbers one for each element in A
|
unsigned int *m_d_index; //!<@internal Vector of column numbers one for each element in A
|
||||||
void *m_d_A; //!<@internal The A matrix
|
void *m_d_A; //!<@internal The A matrix
|
||||||
unsigned int *m_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
unsigned int *m_rowFinalIndex; //!< @internal Vector of row end indices, which for each row specifies an index in A
|
||||||
//! which is the last element of that row. Resides in CPU memory.
|
//! which is the last element of that row. Resides in CPU memory.
|
||||||
size_t m_numRows; //!< Number of rows
|
size_t m_numRows; //!< Number of rows
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1993-2006 NVIDIA Corporation. All rights reserved.
|
* Copyright 1993-2006 NVIDIA Corporation. All rights reserved.
|
||||||
*
|
*
|
||||||
* NOTICE TO USER:
|
* NOTICE TO USER:
|
||||||
*
|
*
|
||||||
* This source code is subject to NVIDIA ownership rights under U.S. and
|
* This source code is subject to NVIDIA ownership rights under U.S. and
|
||||||
* international Copyright laws.
|
* international Copyright laws.
|
||||||
*
|
*
|
||||||
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
||||||
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
||||||
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
||||||
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
||||||
* OR PERFORMANCE OF THIS SOURCE CODE.
|
* OR PERFORMANCE OF THIS SOURCE CODE.
|
||||||
*
|
*
|
||||||
* U.S. Government End Users. This source code is a "commercial item" as
|
* U.S. Government End Users. This source code is a "commercial item" as
|
||||||
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
||||||
* "commercial computer software" and "commercial computer software
|
* "commercial computer software" and "commercial computer software
|
||||||
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
||||||
* and is provided to the U.S. Government only as a commercial end item.
|
* and is provided to the U.S. Government only as a commercial end item.
|
||||||
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
||||||
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
||||||
* source code with only those rights set forth herein.
|
* source code with only those rights set forth herein.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* CUda UTility Library */
|
/* CUda UTility Library */
|
||||||
|
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# pragma warning( disable : 4996 ) // disable deprecated warning
|
# pragma warning( disable : 4996 ) // disable deprecated warning
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -50,8 +50,8 @@ extern "C" {
|
|||||||
# else
|
# else
|
||||||
# define DLL_MAPPING __declspec(dllimport)
|
# define DLL_MAPPING __declspec(dllimport)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define DLL_MAPPING
|
# define DLL_MAPPING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -64,7 +64,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! CUT bool type
|
//! CUT bool type
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
enum CUTBoolean
|
enum CUTBoolean
|
||||||
{
|
{
|
||||||
CUTFalse = 0,
|
CUTFalse = 0,
|
||||||
CUTTrue = 1
|
CUTTrue = 1
|
||||||
@ -72,11 +72,11 @@ extern "C" {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Deallocate memory allocated within Cutil
|
//! Deallocate memory allocated within Cutil
|
||||||
//! @param pointer to memory
|
//! @param pointer to memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
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
|
||||||
@ -95,7 +95,7 @@ extern "C" {
|
|||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
void CUTIL_API
|
void CUTIL_API
|
||||||
cutCheckBankAccess( unsigned int tidx, unsigned int tidy, unsigned int tidz,
|
cutCheckBankAccess( unsigned int tidx, unsigned int tidy, unsigned int tidz,
|
||||||
unsigned int bdimx, unsigned int bdimy,
|
unsigned int bdimx, unsigned int bdimy,
|
||||||
unsigned int bdimz, const char* file, const int line,
|
unsigned int bdimz, const char* file, const int line,
|
||||||
const char* aname, const int index);
|
const char* aname, const int index);
|
||||||
|
|
||||||
@ -141,8 +141,8 @@ extern "C" {
|
|||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFilef( const char* filename, float** data, unsigned int* len,
|
cutReadFilef( const char* filename, float** data, unsigned int* len,
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -157,8 +157,8 @@ extern "C" {
|
|||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFiled( const char* filename, double** data, unsigned int* len,
|
cutReadFiled( const char* filename, double** data, unsigned int* len,
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -173,7 +173,7 @@ extern "C" {
|
|||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFilei( const char* filename, int** data, unsigned int* len, bool verbose = false);
|
cutReadFilei( const char* filename, int** data, unsigned int* len, bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -183,13 +183,13 @@ extern "C" {
|
|||||||
//! @param data uninitialized pointer, returned initialized and pointing to
|
//! @param data uninitialized pointer, returned initialized and pointing to
|
||||||
//! the data read
|
//! the data read
|
||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFileui( const char* filename, unsigned int** data,
|
cutReadFileui( const char* filename, unsigned int** data,
|
||||||
unsigned int* len, bool verbose = false);
|
unsigned int* len, bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -199,13 +199,13 @@ extern "C" {
|
|||||||
//! @param data uninitialized pointer, returned initialized and pointing to
|
//! @param data uninitialized pointer, returned initialized and pointing to
|
||||||
//! the data read
|
//! the data read
|
||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFileb( const char* filename, char** data, unsigned int* len,
|
cutReadFileb( const char* filename, char** data, unsigned int* len,
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -220,12 +220,12 @@ extern "C" {
|
|||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutReadFileub( const char* filename, unsigned char** data,
|
cutReadFileub( const char* filename, unsigned char** data,
|
||||||
unsigned int* len, bool verbose = false);
|
unsigned int* len, bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Write a data file \filename containing single precision floating point
|
//! Write a data file \filename containing single precision floating point
|
||||||
//! data
|
//! data
|
||||||
//! @return CUTTrue if writing the file succeeded, otherwise false
|
//! @return CUTTrue if writing the file succeeded, otherwise false
|
||||||
//! @param filename name of the file to write
|
//! @param filename name of the file to write
|
||||||
@ -234,12 +234,12 @@ extern "C" {
|
|||||||
//! @param epsilon epsilon for comparison
|
//! @param epsilon epsilon for comparison
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFilef( const char* filename, const float* data, unsigned int len,
|
cutWriteFilef( const char* filename, const float* data, unsigned int len,
|
||||||
const float epsilon, bool verbose = false);
|
const float epsilon, bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Write a data file \filename containing double precision floating point
|
//! Write a data file \filename containing double precision floating point
|
||||||
//! data
|
//! data
|
||||||
//! @return CUTTrue if writing the file succeeded, otherwise false
|
//! @return CUTTrue if writing the file succeeded, otherwise false
|
||||||
//! @param filename name of the file to write
|
//! @param filename name of the file to write
|
||||||
@ -248,7 +248,7 @@ extern "C" {
|
|||||||
//! @param epsilon epsilon for comparison
|
//! @param epsilon epsilon for comparison
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFiled( const char* filename, const float* data, unsigned int len,
|
cutWriteFiled( const char* filename, const float* data, unsigned int len,
|
||||||
const double epsilon, bool verbose = false);
|
const double epsilon, bool verbose = false);
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ extern "C" {
|
|||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFilei( const char* filename, const int* data, unsigned int len,
|
cutWriteFilei( const char* filename, const int* data, unsigned int len,
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
|
|
||||||
@ -272,8 +272,8 @@ extern "C" {
|
|||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFileui( const char* filename,const unsigned int* data,
|
cutWriteFileui( const char* filename,const unsigned int* data,
|
||||||
unsigned int len, bool verbose = false);
|
unsigned int len, bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -284,8 +284,8 @@ extern "C" {
|
|||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFileb( const char* filename, const char* data, unsigned int len,
|
cutWriteFileb( const char* filename, const char* data, unsigned int len,
|
||||||
bool verbose = false);
|
bool verbose = false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -296,7 +296,7 @@ extern "C" {
|
|||||||
//! @param len number of data elements in data, -1 on error
|
//! @param len number of data elements in data, -1 on error
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutWriteFileub( const char* filename,const unsigned char* data,
|
cutWriteFileub( const char* filename,const unsigned char* data,
|
||||||
unsigned int len, bool verbose = false);
|
unsigned int len, bool verbose = false);
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ extern "C" {
|
|||||||
//! @param data handle to the data read
|
//! @param data handle to the data read
|
||||||
//! @param w width of the image
|
//! @param w width of the image
|
||||||
//! @param h height of the image
|
//! @param h height of the image
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -326,11 +326,11 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutLoadPPMub( const char* file, unsigned char** data,
|
cutLoadPPMub( const char* file, unsigned char** data,
|
||||||
unsigned int *w,unsigned int *h);
|
unsigned int *w,unsigned int *h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Load PPM image file (with unsigned char as data element type), padding
|
//! Load PPM image file (with unsigned char as data element type), padding
|
||||||
//! 4th component
|
//! 4th component
|
||||||
//! @return CUTTrue if reading the file succeeded, otherwise false
|
//! @return CUTTrue if reading the file succeeded, otherwise false
|
||||||
//! @param file name of the image file
|
//! @param file name of the image file
|
||||||
@ -340,7 +340,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutLoadPPM4ub( const char* file, unsigned char** data,
|
cutLoadPPM4ub( const char* file, unsigned char** data,
|
||||||
unsigned int *w,unsigned int *h);
|
unsigned int *w,unsigned int *h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -350,13 +350,13 @@ extern "C" {
|
|||||||
//! @param data handle to the data read
|
//! @param data handle to the data read
|
||||||
//! @param w width of the image
|
//! @param w width of the image
|
||||||
//! @param h height of the image
|
//! @param h height of the image
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutLoadPGMi( const char* file, unsigned int** data,
|
cutLoadPGMi( const char* file, unsigned int** data,
|
||||||
unsigned int* w, unsigned int* h);
|
unsigned int* w, unsigned int* h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -366,13 +366,13 @@ extern "C" {
|
|||||||
//! @param data handle to the data read
|
//! @param data handle to the data read
|
||||||
//! @param w width of the image
|
//! @param w width of the image
|
||||||
//! @param h height of the image
|
//! @param h height of the image
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutLoadPGMs( const char* file, unsigned short** data,
|
cutLoadPGMs( const char* file, unsigned short** data,
|
||||||
unsigned int* w, unsigned int* h);
|
unsigned int* w, unsigned int* h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -381,7 +381,7 @@ extern "C" {
|
|||||||
//! @param data handle to the data read
|
//! @param data handle to the data read
|
||||||
//! @param w width of the image
|
//! @param w width of the image
|
||||||
//! @param h height of the image
|
//! @param h height of the image
|
||||||
//! @note If a NULL pointer is passed to this function and it is
|
//! @note If a NULL pointer is passed to this function and it is
|
||||||
//! initialized within Cutil then cutFree() has to be used to
|
//! initialized within Cutil then cutFree() has to be used to
|
||||||
//! deallocate the memory
|
//! deallocate the memory
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -399,7 +399,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutSavePGMub( const char* file, unsigned char* data,
|
cutSavePGMub( const char* file, unsigned char* data,
|
||||||
unsigned int w, unsigned int h);
|
unsigned int w, unsigned int h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -411,11 +411,11 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutSavePPMub( const char* file, unsigned char *data,
|
cutSavePPMub( const char* file, unsigned char *data,
|
||||||
unsigned int w, unsigned int h);
|
unsigned int w, unsigned int h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Save PPM image file (with unsigned char as data element type, padded to
|
//! Save PPM image file (with unsigned char as data element type, padded to
|
||||||
//! 4 bytes)
|
//! 4 bytes)
|
||||||
//! @param file name of the image file
|
//! @param file name of the image file
|
||||||
//! @param data handle to the data read
|
//! @param data handle to the data read
|
||||||
@ -424,7 +424,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutSavePPM4ub( const char* file, unsigned char *data,
|
cutSavePPM4ub( const char* file, unsigned char *data,
|
||||||
unsigned int w, unsigned int h);
|
unsigned int w, unsigned int h);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -465,15 +465,15 @@ extern "C" {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Command line arguments: General notes
|
// Command line arguments: General notes
|
||||||
// * All command line arguments begin with '--' followed by the token;
|
// * All command line arguments begin with '--' followed by the token;
|
||||||
// token and value are separated by '='; example --samples=50
|
// token and value are separated by '='; example --samples=50
|
||||||
// * Arrays have the form --model=[one.obj,two.obj,three.obj]
|
// * Arrays have the form --model=[one.obj,two.obj,three.obj]
|
||||||
// (without whitespaces)
|
// (without whitespaces)
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Check if command line argument \a flag-name is given
|
//! Check if command line argument \a flag-name is given
|
||||||
//! @return CUTTrue if command line argument \a flag_name has been given,
|
//! @return CUTTrue if command line argument \a flag_name has been given,
|
||||||
//! otherwise 0
|
//! otherwise 0
|
||||||
//! @param argc argc as passed to main()
|
//! @param argc argc as passed to main()
|
||||||
//! @param argv argv as passed to main()
|
//! @param argv argv as passed to main()
|
||||||
@ -481,7 +481,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutCheckCmdLineFlag( const int argc, const char** argv,
|
cutCheckCmdLineFlag( const int argc, const char** argv,
|
||||||
const char* flag_name);
|
const char* flag_name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -495,7 +495,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutGetCmdLineArgumenti( const int argc, const char** argv,
|
cutGetCmdLineArgumenti( const int argc, const char** argv,
|
||||||
const char* arg_name, int* val);
|
const char* arg_name, int* val);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -509,7 +509,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutGetCmdLineArgumentf( const int argc, const char** argv,
|
cutGetCmdLineArgumentf( const int argc, const char** argv,
|
||||||
const char* arg_name, float* val);
|
const char* arg_name, float* val);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -523,7 +523,7 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutGetCmdLineArgumentstr( const int argc, const char** argv,
|
cutGetCmdLineArgumentstr( const int argc, const char** argv,
|
||||||
const char* arg_name, char** val);
|
const char* arg_name, char** val);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -538,8 +538,8 @@ extern "C" {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutGetCmdLineArgumentListstr( const int argc, const char** argv,
|
cutGetCmdLineArgumentListstr( const int argc, const char** argv,
|
||||||
const char* arg_name, char** val,
|
const char* arg_name, char** val,
|
||||||
unsigned int* len);
|
unsigned int* len);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -556,46 +556,46 @@ extern "C" {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two float arrays
|
//! Compare two float arrays
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
//! @param len number of elements in reference and data
|
//! @param len number of elements in reference and data
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutComparef( const float* reference, const float* data,
|
cutComparef( const float* reference, const float* data,
|
||||||
const unsigned int len);
|
const unsigned int len);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two integer arrays
|
//! Compare two integer arrays
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
//! @param len number of elements in reference and data
|
//! @param len number of elements in reference and data
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutComparei( const int* reference, const int* data,
|
cutComparei( const int* reference, const int* data,
|
||||||
const unsigned int len );
|
const unsigned int len );
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two unsigned char arrays
|
//! Compare two unsigned char arrays
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
//! @param len number of elements in reference and data
|
//! @param len number of elements in reference and data
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutCompareub( const unsigned char* reference, const unsigned char* data,
|
cutCompareub( const unsigned char* reference, const unsigned char* data,
|
||||||
const unsigned int len );
|
const unsigned int len );
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two integer arrays witha n epsilon tolerance for equality
|
//! Compare two integer arrays witha n epsilon tolerance for equality
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
@ -609,7 +609,7 @@ extern "C" {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two float arrays with an epsilon tolerance for equality
|
//! Compare two float arrays with an epsilon tolerance for equality
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
@ -617,14 +617,14 @@ extern "C" {
|
|||||||
//! @param epsilon epsilon to use for the comparison
|
//! @param epsilon epsilon to use for the comparison
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutComparefe( const float* reference, const float* data,
|
cutComparefe( const float* reference, const float* data,
|
||||||
const unsigned int len, const float epsilon );
|
const unsigned int len, const float epsilon );
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Compare two float arrays using L2-norm with an epsilon tolerance for
|
//! Compare two float arrays using L2-norm with an epsilon tolerance for
|
||||||
//! equality
|
//! equality
|
||||||
//! @return CUTTrue if \a reference and \a data are identical,
|
//! @return CUTTrue if \a reference and \a data are identical,
|
||||||
//! otherwise CUTFalse
|
//! otherwise CUTFalse
|
||||||
//! @param reference handle to the reference data / gold image
|
//! @param reference handle to the reference data / gold image
|
||||||
//! @param data handle to the computed data
|
//! @param data handle to the computed data
|
||||||
@ -632,7 +632,7 @@ extern "C" {
|
|||||||
//! @param epsilon epsilon to use for the comparison
|
//! @param epsilon epsilon to use for the comparison
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutCompareL2fe( const float* reference, const float* data,
|
cutCompareL2fe( const float* reference, const float* data,
|
||||||
const unsigned int len, const float epsilon );
|
const unsigned int len, const float epsilon );
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ extern "C" {
|
|||||||
//! @param name of the new timer, 0 if the creation failed
|
//! @param name of the new timer, 0 if the creation failed
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutCreateTimer( unsigned int* name);
|
cutCreateTimer( unsigned int* name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -654,7 +654,7 @@ extern "C" {
|
|||||||
//! @param name of the timer to delete
|
//! @param name of the timer to delete
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutDeleteTimer( unsigned int name);
|
cutDeleteTimer( unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -662,7 +662,7 @@ extern "C" {
|
|||||||
//! @param name name of the timer to start
|
//! @param name name of the timer to start
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutStartTimer( const unsigned int name);
|
cutStartTimer( const unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -670,7 +670,7 @@ extern "C" {
|
|||||||
//! @param name name of the timer to stop
|
//! @param name name of the timer to stop
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutStopTimer( const unsigned int name);
|
cutStopTimer( const unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -678,27 +678,27 @@ extern "C" {
|
|||||||
//! @param name name of the timer to reset.
|
//! @param name name of the timer to reset.
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
CUTBoolean CUTIL_API
|
CUTBoolean CUTIL_API
|
||||||
cutResetTimer( const unsigned int name);
|
cutResetTimer( const unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Returns total execution time in milliseconds for the timer over all
|
//! Returns total execution time in milliseconds for the timer over all
|
||||||
//! runs since the last reset or timer creation.
|
//! runs since the last reset or timer creation.
|
||||||
//! @param name name of the timer to return the time of
|
//! @param name name of the timer to return the time of
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
float CUTIL_API
|
float CUTIL_API
|
||||||
cutGetTimerValue( const unsigned int name);
|
cutGetTimerValue( const unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//! Return the average time in milliseconds for timer execution as the
|
//! Return the average time in milliseconds for timer execution as the
|
||||||
//! total time for the timer dividied by the number of completed (stopped)
|
//! total time for the timer dividied by the number of completed (stopped)
|
||||||
//! runs the timer has made.
|
//! runs the timer has made.
|
||||||
//! Excludes the current running time if the timer is currently running.
|
//! Excludes the current running time if the timer is currently running.
|
||||||
//! @param name name of the timer to return the time of
|
//! @param name name of the timer to return the time of
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
DLL_MAPPING
|
DLL_MAPPING
|
||||||
float CUTIL_API
|
float CUTIL_API
|
||||||
cutGetAverageTimerValue( const unsigned int name);
|
cutGetAverageTimerValue( const unsigned int name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -764,7 +764,7 @@ extern "C" {
|
|||||||
fprintf(stderr, "Cut error in file '%s' in line %i.\n", \
|
fprintf(stderr, "Cut error in file '%s' in line %i.\n", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
exit(EXIT_FAILURE); \
|
exit(EXIT_FAILURE); \
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check for CUDA error
|
//! Check for CUDA error
|
||||||
# define CUT_CHECK_ERROR(errorMessage) do { \
|
# define CUT_CHECK_ERROR(errorMessage) do { \
|
||||||
@ -802,7 +802,7 @@ extern "C" {
|
|||||||
// void macros for performance reasons
|
// void macros for performance reasons
|
||||||
# define CUT_CHECK_ERROR(errorMessage)
|
# define CUT_CHECK_ERROR(errorMessage)
|
||||||
# define CUT_CHECK_ERROR_GL()
|
# define CUT_CHECK_ERROR_GL()
|
||||||
# define CUT_CONDITION( val)
|
# define CUT_CONDITION( val)
|
||||||
# define CU_SAFE_CALL_NO_SYNC( call) call
|
# define CU_SAFE_CALL_NO_SYNC( call) call
|
||||||
# define CU_SAFE_CALL( call) call
|
# define CU_SAFE_CALL( call) call
|
||||||
# define CUDA_SAFE_CALL_NO_SYNC( call) call
|
# define CUDA_SAFE_CALL_NO_SYNC( call) call
|
||||||
|
|||||||
@ -44,28 +44,28 @@ static void MPI_Init(int *, char ***) {}
|
|||||||
static MPI_Comm MPI_Comm_f2c(MPI_Comm world) {return world;}
|
static MPI_Comm MPI_Comm_f2c(MPI_Comm world) {return world;}
|
||||||
static void MPI_Comm_rank(MPI_Comm, int *) {}
|
static void MPI_Comm_rank(MPI_Comm, int *) {}
|
||||||
static void MPI_Comm_size(MPI_Comm, int *) {}
|
static void MPI_Comm_size(MPI_Comm, int *) {}
|
||||||
|
|
||||||
static void MPI_Open_port(MPI_Info, char *) {}
|
static void MPI_Open_port(MPI_Info, char *) {}
|
||||||
static void MPI_Close_port(const char *) {}
|
static void MPI_Close_port(const char *) {}
|
||||||
static void MPI_Comm_accept(const char *, MPI_Info, int,
|
static void MPI_Comm_accept(const char *, MPI_Info, int,
|
||||||
MPI_Comm, MPI_Comm *) {}
|
MPI_Comm, MPI_Comm *) {}
|
||||||
static void MPI_Comm_connect(const char *, MPI_Info, int,
|
static void MPI_Comm_connect(const char *, MPI_Info, int,
|
||||||
MPI_Comm, MPI_Comm *) {}
|
MPI_Comm, MPI_Comm *) {}
|
||||||
|
|
||||||
static void MPI_Comm_split(MPI_Comm, int, int, MPI_Comm *) {}
|
static void MPI_Comm_split(MPI_Comm, int, int, MPI_Comm *) {}
|
||||||
static void MPI_Comm_free(MPI_Comm *) {}
|
static void MPI_Comm_free(MPI_Comm *) {}
|
||||||
|
|
||||||
static void MPI_Send(const void *, int, MPI_Datatype, int, int, MPI_Comm) {}
|
static void MPI_Send(const void *, int, MPI_Datatype, int, int, MPI_Comm) {}
|
||||||
static void MPI_Recv(void *, int, MPI_Datatype, int, int,
|
static void MPI_Recv(void *, int, MPI_Datatype, int, int,
|
||||||
MPI_Comm, MPI_Status *) {}
|
MPI_Comm, MPI_Status *) {}
|
||||||
|
|
||||||
static void MPI_Allreduce(const void *in, void *out, int, MPI_Datatype type,
|
static void MPI_Allreduce(const void *in, void *out, int, MPI_Datatype type,
|
||||||
MPI_Op op, MPI_Comm)
|
MPI_Op op, MPI_Comm)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,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: PoemsChain.h *
|
* FILE NAME: PoemsChain.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -3,7 +3,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: SystemProcessor.h *
|
* FILE NAME: SystemProcessor.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
*_________________________________________________________________________*
|
*_________________________________________________________________________*
|
||||||
* 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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: colmatrix.h *
|
* FILE NAME: colmatrix.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
*_________________________________________________________________________*
|
*_________________________________________________________________________*
|
||||||
* 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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: joint.h *
|
* FILE NAME: joint.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ enum JointType {
|
|||||||
PRISMATICJOINT = 3,
|
PRISMATICJOINT = 3,
|
||||||
SPHERICALJOINT = 4,
|
SPHERICALJOINT = 4,
|
||||||
BODY23JOINT = 5,
|
BODY23JOINT = 5,
|
||||||
MIXEDJOINT = 6
|
MIXEDJOINT = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
class Body;
|
class Body;
|
||||||
@ -51,7 +51,7 @@ protected:
|
|||||||
ColMatrix qdot; // generalized coordinate derivatives
|
ColMatrix qdot; // generalized coordinate derivatives
|
||||||
ColMatrix udot; // generalized speed derivatives
|
ColMatrix udot; // generalized speed derivatives
|
||||||
ColMatrix qdotdot;
|
ColMatrix qdotdot;
|
||||||
|
|
||||||
Mat3x3 pk_C_ko; // transformation relationship for q = 0
|
Mat3x3 pk_C_ko; // transformation relationship for q = 0
|
||||||
|
|
||||||
Mat3x3 pk_C_k; // local transform
|
Mat3x3 pk_C_k; // local transform
|
||||||
@ -94,14 +94,14 @@ public:
|
|||||||
Mat3x3* Get_pkCk();
|
Mat3x3* Get_pkCk();
|
||||||
Mat3x3* Get_kCpk();
|
Mat3x3* Get_kCpk();
|
||||||
|
|
||||||
//void SetInitialState(VirtualMatrix& q, VirtualMatrix& u);
|
//void SetInitialState(VirtualMatrix& q, VirtualMatrix& u);
|
||||||
void SetInitialState(ColMatrix& q, ColMatrix& u);
|
void SetInitialState(ColMatrix& q, ColMatrix& u);
|
||||||
void SetZeroOrientation(VirtualMatrix& C);
|
void SetZeroOrientation(VirtualMatrix& C);
|
||||||
void ResetQdot();
|
void ResetQdot();
|
||||||
void ResetQ();
|
void ResetQ();
|
||||||
bool ReadIn(std::istream& in);
|
bool ReadIn(std::istream& in);
|
||||||
void WriteOut(std::ostream& out);
|
void WriteOut(std::ostream& out);
|
||||||
|
|
||||||
virtual void WriteOutJointData(std::ostream& out) = 0;
|
virtual void WriteOutJointData(std::ostream& out) = 0;
|
||||||
virtual bool ReadInJointData(std::istream& in) = 0;
|
virtual bool ReadInJointData(std::istream& in) = 0;
|
||||||
virtual Matrix GetForward_sP();
|
virtual Matrix GetForward_sP();
|
||||||
|
|||||||
@ -3,7 +3,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: matrixfun.h *
|
* FILE NAME: matrixfun.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,10 +11,10 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
#ifndef MATRIXFUN_H
|
#ifndef MATRIXFUN_H
|
||||||
#define MATRIXFUN_H
|
#define MATRIXFUN_H
|
||||||
|
|
||||||
@ -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);
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
*_________________________________________________________________________*
|
*_________________________________________________________________________*
|
||||||
* 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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -26,10 +26,10 @@ class MixedJoint : public Joint{
|
|||||||
int numrots;
|
int numrots;
|
||||||
int numtrans;
|
int numtrans;
|
||||||
Vect6 dofs;
|
Vect6 dofs;
|
||||||
public:
|
public:
|
||||||
MixedJoint();
|
MixedJoint();
|
||||||
~MixedJoint();
|
~MixedJoint();
|
||||||
|
|
||||||
JointType GetType();
|
JointType GetType();
|
||||||
bool ReadInJointData(std::istream& in);
|
bool ReadInJointData(std::istream& in);
|
||||||
void WriteOutJointData(std::ostream& out);
|
void WriteOutJointData(std::ostream& out);
|
||||||
|
|||||||
@ -3,7 +3,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: onbody.h *
|
* FILE NAME: onbody.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class OnBody {
|
|||||||
Vect3* gamma; // pointer to gamma vector
|
Vect3* gamma; // pointer to gamma vector
|
||||||
Mat3x3* pk_C_k; // pointer to transformation
|
Mat3x3* pk_C_k; // pointer to transformation
|
||||||
|
|
||||||
|
|
||||||
Mat6x6 sI; // spatial inertias
|
Mat6x6 sI; // spatial inertias
|
||||||
Mat6x6 sIhat; // recursive spatial inertias
|
Mat6x6 sIhat; // recursive spatial inertias
|
||||||
Mat6x6 sSC; // spatial shift
|
Mat6x6 sSC; // spatial shift
|
||||||
@ -68,16 +68,16 @@ class OnBody {
|
|||||||
ColMatrix* qdot;
|
ColMatrix* qdot;
|
||||||
ColMatrix* udot;
|
ColMatrix* udot;
|
||||||
ColMatrix* qdotdot;
|
ColMatrix* qdotdot;
|
||||||
|
|
||||||
ColMatrix* r;
|
ColMatrix* r;
|
||||||
ColMatrix* acc;
|
ColMatrix* acc;
|
||||||
ColMatrix* ang;
|
ColMatrix* ang;
|
||||||
|
|
||||||
// friend classes
|
// friend classes
|
||||||
friend class OnSolver;
|
friend class OnSolver;
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
public:
|
||||||
OnBody();
|
OnBody();
|
||||||
~OnBody();
|
~OnBody();
|
||||||
int RecursiveSetup(InertialFrame* basebody);
|
int RecursiveSetup(InertialFrame* basebody);
|
||||||
@ -88,11 +88,11 @@ public:
|
|||||||
Mat3x3 GetN_C_K();
|
Mat3x3 GetN_C_K();
|
||||||
Vect3 LocalCart();
|
Vect3 LocalCart();
|
||||||
int GetBodyID();
|
int GetBodyID();
|
||||||
void CalculateAcceleration();
|
void CalculateAcceleration();
|
||||||
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: onsolver.h *
|
* FILE NAME: onsolver.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -24,28 +24,28 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OnSolver : public Solver {
|
class OnSolver : public Solver {
|
||||||
OnBody inertialframe;
|
OnBody inertialframe;
|
||||||
int numbodies;
|
int numbodies;
|
||||||
OnBody** bodyarray;
|
OnBody** bodyarray;
|
||||||
ColMatrix** q;
|
ColMatrix** q;
|
||||||
ColMatrix** qdot;
|
ColMatrix** qdot;
|
||||||
ColMatrix** qdotdot;
|
ColMatrix** qdotdot;
|
||||||
ColMatrix** u;
|
ColMatrix** u;
|
||||||
ColMatrix** udot;
|
ColMatrix** udot;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
||||||
void CreateModel();
|
void CreateModel();
|
||||||
void Solve(double time, Matrix& FF);
|
void Solve(double time, Matrix& FF);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -3,7 +3,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: poemslist.h *
|
* FILE NAME: poemslist.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
S* operator()(int id);
|
S* operator()(int id);
|
||||||
void Append(List<S> * listToAppend);
|
void Append(List<S> * listToAppend);
|
||||||
void DeleteValues();
|
void DeleteValues();
|
||||||
void RemoveElementAndDeleteValue(ListElement<S>* ele);
|
void RemoveElementAndDeleteValue(ListElement<S>* ele);
|
||||||
void PrintList();
|
void PrintList();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -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,16 +145,16 @@ 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;
|
||||||
}
|
}
|
||||||
@ -193,12 +193,12 @@ template<class S> S* List<S>::operator()(int id){
|
|||||||
cerr << "ERROR: subscript out of bounds" << endl;
|
cerr << "ERROR: subscript out of bounds" << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement<S>* ele = head;
|
ListElement<S>* ele = head;
|
||||||
for(int i=0;i<id;i++){
|
for(int i=0;i<id;i++){
|
||||||
ele = ele->next;
|
ele = ele->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ele->value;
|
return ele->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: poemsnodelib.h *
|
* FILE NAME: poemsnodelib.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -23,7 +23,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
TreeNode *GetTreeNode(int item,TreeNode *lptr = NULL,TreeNode *rptr =NULL);
|
TreeNode *GetTreeNode(int item,TreeNode *lptr = NULL,TreeNode *rptr =NULL);
|
||||||
|
|
||||||
void FreeTreeNode(TreeNode *p);
|
void FreeTreeNode(TreeNode *p);
|
||||||
|
|
||||||
@ -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,61 +102,61 @@ 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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// the function uses the postorder scan. it computes the
|
// the function uses the postorder scan. it computes the
|
||||||
// depth of the left and right subtrees of a node and
|
// depth of the left and right subtrees of a node and
|
||||||
// returns the depth as 1 + max(depthLeft,depthRight).
|
// returns the depth as 1 + max(depthLeft,depthRight).
|
||||||
// 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
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: poemstree.h *
|
* FILE NAME: poemstree.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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
|
|
||||||
if (np->balanceFactor == rightheavy)
|
|
||||||
{
|
|
||||||
p->balanceFactor = balanced;
|
|
||||||
lc->balanceFactor = rightheavy;
|
|
||||||
}
|
|
||||||
else if (np->balanceFactor == balanced)
|
|
||||||
{
|
|
||||||
p->balanceFactor = balanced;
|
|
||||||
lc->balanceFactor = balanced;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p->balanceFactor = rightheavy;
|
|
||||||
lc->balanceFactor = balanced;
|
|
||||||
}
|
|
||||||
np->balanceFactor = balanced;
|
|
||||||
|
|
||||||
// before np replaces the parent p, take care of subtrees
|
// update balance factors for p, lc, and np
|
||||||
// detach old children and attach new children
|
if (np->balanceFactor == rightheavy)
|
||||||
lc->right = np->Left();
|
{
|
||||||
np->left = lc;
|
p->balanceFactor = balanced;
|
||||||
p->left = np->Right();
|
lc->balanceFactor = rightheavy;
|
||||||
np->right = p;
|
}
|
||||||
p = np;
|
else if (np->balanceFactor == balanced)
|
||||||
|
{
|
||||||
|
p->balanceFactor = balanced;
|
||||||
|
lc->balanceFactor = balanced;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->balanceFactor = rightheavy;
|
||||||
|
lc->balanceFactor = balanced;
|
||||||
|
}
|
||||||
|
np->balanceFactor = balanced;
|
||||||
|
|
||||||
|
// before np replaces the parent p, take care of subtrees
|
||||||
|
// detach old children and attach new children
|
||||||
|
lc->right = np->Left();
|
||||||
|
np->left = lc;
|
||||||
|
p->left = np->Right();
|
||||||
|
np->right = p;
|
||||||
|
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
|
|
||||||
if (np->balanceFactor == leftheavy)
|
|
||||||
{
|
|
||||||
p->balanceFactor = balanced;
|
|
||||||
lc->balanceFactor = leftheavy;
|
|
||||||
}
|
|
||||||
else if (np->balanceFactor == balanced)
|
|
||||||
{
|
|
||||||
p->balanceFactor = balanced;
|
|
||||||
lc->balanceFactor = balanced;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p->balanceFactor = leftheavy;
|
|
||||||
lc->balanceFactor = balanced;
|
|
||||||
}
|
|
||||||
np->balanceFactor = balanced;
|
|
||||||
|
|
||||||
// before np replaces the parent p, take care of subtrees
|
// update balance factors for p, lc, and np
|
||||||
// detach old children and attach new children
|
if (np->balanceFactor == leftheavy)
|
||||||
lc->left = np->Right();
|
{
|
||||||
np->right = lc;
|
p->balanceFactor = balanced;
|
||||||
p->right = np->Left();
|
lc->balanceFactor = leftheavy;
|
||||||
np->left = p;
|
}
|
||||||
p = np;
|
else if (np->balanceFactor == balanced)
|
||||||
|
{
|
||||||
|
p->balanceFactor = balanced;
|
||||||
|
lc->balanceFactor = balanced;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->balanceFactor = leftheavy;
|
||||||
|
lc->balanceFactor = balanced;
|
||||||
|
}
|
||||||
|
np->balanceFactor = balanced;
|
||||||
|
|
||||||
|
// before np replaces the parent p, take care of subtrees
|
||||||
|
// detach old children and attach new children
|
||||||
|
lc->left = np->Right();
|
||||||
|
np->right = lc;
|
||||||
|
p->right = np->Left();
|
||||||
|
np->left = p;
|
||||||
|
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
|
||||||
|
|||||||
@ -3,7 +3,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: poemstreenode.h *
|
* FILE NAME: poemstreenode.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
*_________________________________________________________________________*
|
*_________________________________________________________________________*
|
||||||
* 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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: system.h *
|
* FILE NAME: system.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -22,8 +22,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "poemslist.h"
|
#include "poemslist.h"
|
||||||
#include "matrices.h"
|
#include "matrices.h"
|
||||||
@ -47,42 +47,42 @@
|
|||||||
class Joint;
|
class Joint;
|
||||||
|
|
||||||
class System{
|
class System{
|
||||||
private:
|
private:
|
||||||
int * mappings;
|
int * mappings;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double time;
|
double time;
|
||||||
List<Body> bodies;
|
List<Body> bodies;
|
||||||
List<Joint> joints;
|
List<Joint> joints;
|
||||||
|
|
||||||
System();
|
System();
|
||||||
~System();
|
~System();
|
||||||
void Delete();
|
void Delete();
|
||||||
|
|
||||||
int GetNumBodies();
|
int GetNumBodies();
|
||||||
|
|
||||||
int * GetMappings();
|
int * GetMappings();
|
||||||
|
|
||||||
void AddBody(Body* body);
|
void AddBody(Body* body);
|
||||||
|
|
||||||
void AddJoint(Joint* joint);
|
void AddJoint(Joint* joint);
|
||||||
|
|
||||||
void SetTime(double t);
|
void SetTime(double t);
|
||||||
|
|
||||||
double GetTime();
|
double GetTime();
|
||||||
|
|
||||||
void ComputeForces();
|
void ComputeForces();
|
||||||
|
|
||||||
bool ReadIn(std::istream& in);
|
bool ReadIn(std::istream& in);
|
||||||
|
|
||||||
void WriteOut(std::ostream& out);
|
void WriteOut(std::ostream& out);
|
||||||
|
|
||||||
void ClearBodyIDs();
|
void ClearBodyIDs();
|
||||||
|
|
||||||
void ClearJointIDs();
|
void ClearJointIDs();
|
||||||
|
|
||||||
void Create_System_LAMMPS(int numbodies, double *mass,double **inertia, double ** xcm, double ** xjoint,double **vh1,double **omega,double **ex_space, double **ey_space, double **ez_space, int b, int * mapping, int count);
|
void Create_System_LAMMPS(int numbodies, double *mass,double **inertia, double ** xcm, double ** xjoint,double **vh1,double **omega,double **ex_space, double **ey_space, double **ez_space, int b, int * mapping, int count);
|
||||||
|
|
||||||
void Create_DegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space);
|
void Create_DegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,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: virtualcolmatrix.h *
|
* FILE NAME: virtualcolmatrix.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -23,22 +23,22 @@
|
|||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: virtualmatrix.h *
|
* FILE NAME: virtualmatrix.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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: workspace.h *
|
* FILE NAME: workspace.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 *
|
||||||
* LICENSE: Please see License Agreement *
|
* LICENSE: Please see License Agreement *
|
||||||
@ -11,7 +11,7 @@
|
|||||||
* ADMINISTRATOR: Prof. Kurt Anderson *
|
* ADMINISTRATOR: Prof. Kurt Anderson *
|
||||||
* Computational Dynamics Lab *
|
* Computational Dynamics Lab *
|
||||||
* Rensselaer Polytechnic Institute *
|
* Rensselaer Polytechnic Institute *
|
||||||
* 110 8th St. Troy NY 12180 *
|
* 110 8th St. Troy NY 12180 *
|
||||||
* CONTACT: anderk5@rpi.edu *
|
* CONTACT: anderk5@rpi.edu *
|
||||||
*_________________________________________________________________________*/
|
*_________________________________________________________________________*/
|
||||||
|
|
||||||
@ -23,8 +23,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -32,57 +32,57 @@ 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();
|
||||||
~Workspace();
|
~Workspace();
|
||||||
|
|
||||||
double Thalf;
|
double Thalf;
|
||||||
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);
|
||||||
|
|
||||||
bool SaveFile(char* filename, int index = -1);
|
bool SaveFile(char* filename, int index = -1);
|
||||||
|
|
||||||
System* GetSystem(int index = -1);
|
System* GetSystem(int index = -1);
|
||||||
|
|
||||||
void AddSolver(Solver* s, int index = -1);
|
|
||||||
|
|
||||||
|
|
||||||
void LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space);
|
void AddSolver(Solver* s, int index = -1);
|
||||||
|
|
||||||
void LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm);
|
|
||||||
|
void LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space);
|
||||||
|
|
||||||
|
void LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm);
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user