![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2006 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: dyad.h,v $ $Revision: 1.10 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00009 #ifndef dyad_H_ 00010 #define dyad_H_ 00011 00012 #include "geometry/geometryDefines.h" 00013 #include <matrix/LibMatrix.h> 00014 00015 class DtMVector; 00016 00017 enum DtMatrixFlag 00018 { 00019 IncompatibleMatrixSizes = 1 00020 }; 00021 00022 // The static variables allow for different offsets for the 00023 // Matrix indexing. All instantiations of the matrix will 00024 // use the same indexing. 00025 // 00026 class DT_DLL_geometry DtMatrix 00027 { 00028 friend class DtMVector; 00029 friend class DtLinearSystem; 00030 00031 friend DtMatrix * DtMatrixMultiply(DtMatrix * m1,DtMatrix * m2, char * s=0,generic_mm_multflag f=TRANSPOSE_NONE); 00032 friend DtMatrix * DtMatrixMultiply(DtMatrix * m,DtMVector * v, char * s=0,generic_mm_multflag f=TRANSPOSE_NONE); 00033 friend DtMatrix * DtMatrixMergeVertically(DtMatrix * myMatT, DtMatrix * myMatB); 00034 friend DtMatrix * DtMatrixMergeHorizontallyWithTranspose(DtMatrix * matL,DtMatrix * matR); 00035 friend DtMatrix * DtMatrixMergeHorizontally(DtMatrix * matL, DtMatrix * matR); 00036 friend DtMatrix * DtMatrixScale(DtMatrix * m,double s); 00037 00038 friend bool DtIntersectionUniqueSolution(const DtVector& loc1, 00039 const DtVector& loc2, 00040 const DtDcm& m1, 00041 const DtDcm& m2); 00042 00043 friend DtMatrix * DtMAdd(DtMatrix * myMatA,DtMatrix * myMatB); 00044 friend DtMatrix * DtMSubtract(DtMatrix * myMatA,DtMatrix * myMatB); 00045 friend DtMatrix * DtMSum(DtMatrix * myMatA,DtMatrix * B,double s); 00046 friend void LinearSystem(DtMatrix * myMatA, DtMatrix * myMatB, DtMatrix * myMatC, DtMatrix * myMatD, DtMVector * myMatX, DtMVector * myMatU, DtMVector * myMatY); 00047 public: 00048 DtMatrix(); 00049 DtMatrix(int a, int b, bool init = true, int c=-1, int r=-1); 00050 DtMatrix(DtMatrix* matM, bool copy = false); 00051 00052 double** Init(int a, int b, bool init, int c=-1, int r=-1); 00053 double** Init(DtMatrix* matM, bool copy = false); 00054 00055 void UnInit(); 00056 virtual ~DtMatrix(); 00057 00058 DtMatrix* next; 00059 00060 int rows(){return myRows;} 00061 int columns(){return myColumns;} 00062 00063 double get(int i,int j); 00064 bool set(int i, int j, double val); 00065 00066 static int rstart; // Initial r index. 00067 static int cstart; // Initial c index. 00068 00069 double** data ; // Uses flexible array indexing. 00070 00071 void print( char * str); 00072 00073 void setRows(int nR) 00074 { 00075 if(!myMaxRows) 00076 { 00077 myMaxRows=myRows; 00078 myRows=nR; 00079 } 00080 } 00081 00082 void setColumns(int nC) 00083 { 00084 if(!myMaxColumns) 00085 { 00086 myMaxColumns=myColumns; 00087 myColumns=nC; 00088 } 00089 } 00090 00091 00092 void restoreRows() 00093 { 00094 if(myMaxRows) 00095 { 00096 myRows=myMaxRows; 00097 myMaxRows=0; 00098 } 00099 } 00100 void restoreColumns() 00101 { 00102 if(myMaxColumns) 00103 { 00104 myColumns=myMaxColumns; 00105 myMaxColumns=0; 00106 } 00107 } 00108 00109 void identity(bool clear=false); 00110 void all(double val); 00111 00112 void AXB(DtMatrix* myMatB, DtMatrix* result);//Mike 00113 DtMatrix* AXB(DtMatrix* myMatB); 00114 DtMatrix* AXBT(DtMatrix* myMatB); 00115 00116 bool UXB(DtMatrix* myMatB); 00117 bool LXB(DtMatrix* myMatB); 00118 00119 DtMatrix* UnMergeHorizontally(int c, DtMatrix* matR); 00120 DtMatrix* UnMergeVertically(int r, DtMatrix* myMatB); 00121 00122 DtMVector* House(int rs, int nc); 00123 DtMVector* HouseT(int rs, int nc); 00124 00125 bool RHouse(DtMVector* house, int rs, int cs); 00126 bool CHouse(DtMVector* house, int rs, int cs); 00127 00128 DtMatrix* QR(DtMatrix* matQ = 0); 00129 DtMatrix* LQ(DtMatrix* matQ = 0); 00130 00131 DtMatrix* SQRT(DtMatrix* matDiag); 00132 DtMatrix* LDU(DtMatrix*, DtMatrix*, DtMatrix*); 00133 00134 void Scale(double s); 00135 void Accumulate(DtMatrix* myMatB, double s); 00136 00137 void SetIndexes(int i, int j); 00138 DtMVector* LinProg(DtMVector* myMatB, DtMVector* max); 00139 00140 void IntersectionInit(); 00141 protected: 00142 int Status(DtMatrixFlag); 00143 00144 private: 00145 int myRows; 00146 int myColumns; 00147 int myMaxRows; 00148 int myMaxColumns; 00149 double** myData; 00150 double** myVData; 00151 bool myUsed; 00152 00153 // Experimental switch submatrix on the fly. 00154 double** Data; 00155 double** Data_data; 00156 double** DataInit(int r,int c); 00157 }; 00158 00159 00160 // The internal representation of 00161 // vectors are potentially different. To facilitate 00162 // the common notion of a DtVector some changes are made; 00163 // these changes are transparent to the proper use of 00164 // DtMatrix Routines. data[i][j] will still work. 00165 // We can now also use vec[k]; 00166 // 00167 class DT_DLL_geometry DtMVector : public DtMatrix 00168 { 00169 friend class DtMatrix; 00170 friend class DtLinearSystem; 00171 friend DtMatrix* DtMatrixMultiply(DtMatrix* m, DtMVector* v, char* s, generic_mm_multflag f); 00172 00173 friend bool DtIntersectionUniqueSolution(const DtVector& loc1, 00174 const DtVector& loc2, 00175 const DtDcm& m1, 00176 const DtDcm& m2); 00177 00178 friend DtMatrix* DtMAdd(DtMVector* myMatA, DtMVector* myMatB); 00179 friend DtMatrix* DtMSubtract(DtMVector* A, DtMVector* myMatB); 00180 friend DtMatrix* DtMSum(DtMVector* myMatA, DtMVector * myMatB, double s); 00181 friend void LinearSystem(DtMatrix* myMatA, DtMatrix* myMatB, DtMatrix* myMatC, DtMatrix* myMatD, DtMVector* myMatX, DtMVector* myMatU, DtMVector* myMatY); 00182 friend bool DtIntersection2(const DtVector& loc1, const DtVector& loc2, const DtDcm& m1, const DtDcm& m2, DtVector& l1, DtVector& l2); 00183 00184 public: 00185 DtMVector(int a, int bcolumnvector, bool initialize = true, int p = -1); 00186 DtMVector(DtMVector* V, bool copy = false); 00187 00188 virtual ~DtMVector(); 00189 double get(int i); 00190 bool set(int i, double val); 00191 DtMatrix* GenerateN(DtMatrix* mata); 00192 void Accumulate(DtMVector* myMatB, double s, DtMatrix* myMatA); 00193 int size(){return mySize;} 00194 void unit(int i); 00195 double* vec; 00196 private: 00197 double* myVec; 00198 int mySize; 00199 }; 00200 00201 00202 class DT_DLL_geometry DtLinearSystem 00203 { 00204 public: 00205 DtLinearSystem(int _dim_X, int _dim_U, int _dim_Y, bool init=true,int c=-1,int r=-1); 00206 DtMatrix myMatA; 00207 DtMatrix myMatB; 00208 DtMatrix myMatC; 00209 DtMatrix myMatD; 00210 DtMatrix myMatX; 00211 DtMatrix myMatU; 00212 DtMatrix myMatY; 00213 int myDimX; 00214 int myDimU; 00215 int myDimY; 00216 00217 private: 00218 DtMatrix myMatZ; 00219 DtMatrix myMatT; 00220 00221 }; 00222 00223 00224 00225 void simplx(double ** a, int m,int n,int m1,int m2, int m3, int * icase, int * izrov, int * ipposv); 00226 void simp1(double ** a, int mm, int * ll, int nll, int iabf, int * kp, double * bmax) ; 00227 void simp2(double ** a, int n, int * l2, int nl2,int * ip, int kp,double * q1); 00228 void simp3(double ** a,int i1, int k1, int ip, int kp); 00229 void print(double ** a,int r, int c,char *str); 00230 00231 #endif //_DYAD_H_ 00232