1 /* 2 *_________________________________________________________________________* 3 * POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE * 4 * DESCRIPTION: SEE READ-ME * 5 * FILE NAME: vect6.cpp * 6 * AUTHORS: See Author List * 7 * GRANTS: See Grants List * 8 * COPYRIGHT: (C) 2005 by Authors as listed in Author's List * 9 * LICENSE: Please see License Agreement * 10 * DOWNLOAD: Free at www.rpi.edu/~anderk5 * 11 * ADMINISTRATOR: Prof. Kurt Anderson * 12 * Computational Dynamics Lab * 13 * Rensselaer Polytechnic Institute * 14 * 110 8th St. Troy NY 12180 * 15 * CONTACT: anderk5@rpi.edu * 16 *_________________________________________________________________________*/ 17 18 #include "vect6.h" 19 #include <cstdlib> 20 21 using namespace std; 22 Vect6()23Vect6::Vect6(){ 24 numrows = 6; numcols = 1; 25 } ~Vect6()26Vect6::~Vect6(){ 27 } 28 Vect6(const Vect6 & A)29Vect6::Vect6(const Vect6& A){ // copy constructor 30 numrows = 6; numcols = 1; 31 32 elements[0] = A.elements[0]; 33 elements[1] = A.elements[1]; 34 elements[2] = A.elements[2]; 35 elements[3] = A.elements[3]; 36 elements[4] = A.elements[4]; 37 elements[5] = A.elements[5]; 38 } 39 Vect6(const VirtualMatrix & A)40Vect6::Vect6(const VirtualMatrix& A){ // copy constructor 41 numrows = 6; numcols = 1; 42 43 // error check 44 if( (A.GetNumRows() != 6) || (A.GetNumCols() != 1) ){ 45 cerr << "illegal matrix size" << endl; 46 exit(0); 47 } 48 49 for(int i=0;i<6;i++) 50 elements[i] = A.BasicGet(i,0); 51 } 52 operator_1int(int i)53double& Vect6::operator_1int (int i){ // array access 54 if(i<1 || i>6){ 55 cerr << "matrix index invalid in operator ()" << endl; 56 exit(1); 57 } 58 return elements[i-1]; 59 } 60 Get_1int(int i) const61double Vect6::Get_1int(int i) const{ 62 return elements[i-1]; 63 } 64 Set_1int(int i,double value)65void Vect6::Set_1int(int i, double value){ 66 elements[i-1] = value; 67 } 68 BasicGet_1int(int i) const69double Vect6::BasicGet_1int(int i) const{ 70 return elements[i]; 71 } 72 BasicSet_1int(int i,double value)73void Vect6::BasicSet_1int(int i, double value){ 74 elements[i] = value; 75 } 76 BasicIncrement_1int(int i,double value)77void Vect6::BasicIncrement_1int(int i, double value){ 78 elements[i] += value; 79 } 80 Const(double value)81void Vect6::Const(double value){ 82 elements[0] = value; 83 elements[1] = value; 84 elements[2] = value; 85 elements[3] = value; 86 elements[4] = value; 87 elements[5] = value; 88 } 89 GetType() const90MatrixType Vect6::GetType() const{ 91 return VECT6; 92 } 93 ReadData(istream & c)94istream& Vect6::ReadData(istream& c){ //input 95 for(int i=0;i<6;i++) 96 c >> elements[i]; 97 return c; 98 } 99 WriteData(ostream & c) const100ostream& Vect6::WriteData(ostream& c) const{ //output 101 for(int i=0;i<6;i++) 102 c << elements[i] << ' '; 103 return c; 104 } 105 AssignVM(const VirtualMatrix & A)106void Vect6::AssignVM(const VirtualMatrix& A){ 107 // error check 108 if( (A.GetNumRows() != 6) || (A.GetNumCols() != 1) ){ 109 cerr << "illegal matrix size" << endl; 110 exit(0); 111 } 112 113 for(int i=0;i<numrows;i++) 114 elements[i] = A.BasicGet(i,0); 115 } 116 operator =(const Vect6 & A)117Vect6& Vect6::operator=(const Vect6& A){ // assignment operator 118 elements[0] = A.elements[0]; 119 elements[1] = A.elements[1]; 120 elements[2] = A.elements[2]; 121 elements[3] = A.elements[3]; 122 elements[4] = A.elements[4]; 123 elements[5] = A.elements[5]; 124 return *this; 125 } 126 operator =(const VirtualMatrix & A)127Vect6& Vect6::operator=(const VirtualMatrix& A){ // overloaded = 128 // error check 129 if( (A.GetNumRows() != 6) || (A.GetNumCols() != 1) ){ 130 cerr << "illegal matrix size" << endl; 131 exit(0); 132 } 133 134 for(int i=0;i<numrows;i++) 135 elements[i] = A.BasicGet(i,0); 136 return *this; 137 } 138 operator *=(double b)139Vect6& Vect6::operator*=(double b){ 140 elements[0] *= b; 141 elements[1] *= b; 142 elements[2] *= b; 143 elements[3] *= b; 144 elements[4] *= b; 145 elements[5] *= b; 146 return *this; 147 } 148 149