VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dyad.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2006 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: dyad.h,v $ $Revision: 1.10 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef dyad_H_
10 #define dyad_H_
11 
13 #include <matrix/LibMatrix.h>
14 
15 class DtMVector;
16 
18 {
20 };
21 
22 // The static variables allow for different offsets for the
23 // Matrix indexing. All instantiations of the matrix will
24 // use the same indexing.
25 //
27 {
28  friend class DtMVector;
29  friend class DtLinearSystem;
30 
31  friend DtMatrix * DtMatrixMultiply(DtMatrix * m1,DtMatrix * m2, char * s=0,generic_mm_multflag f=TRANSPOSE_NONE);
32  friend DtMatrix * DtMatrixMultiply(DtMatrix * m,DtMVector * v, char * s=0,generic_mm_multflag f=TRANSPOSE_NONE);
33  friend DtMatrix * DtMatrixMergeVertically(DtMatrix * myMatT, DtMatrix * myMatB);
34  friend DtMatrix * DtMatrixMergeHorizontallyWithTranspose(DtMatrix * matL,DtMatrix * matR);
35  friend DtMatrix * DtMatrixMergeHorizontally(DtMatrix * matL, DtMatrix * matR);
36  friend DtMatrix * DtMatrixScale(DtMatrix * m,double s);
37 
38  friend bool DtIntersectionUniqueSolution(const DtVector& loc1,
39  const DtVector& loc2,
40  const DtDcm& m1,
41  const DtDcm& m2);
42 
43  friend DtMatrix * DtMAdd(DtMatrix * myMatA,DtMatrix * myMatB);
44  friend DtMatrix * DtMSubtract(DtMatrix * myMatA,DtMatrix * myMatB);
45  friend DtMatrix * DtMSum(DtMatrix * myMatA,DtMatrix * B,double s);
47 public:
48  DtMatrix();
49  DtMatrix(int a, int b, bool init = true, int c=-1, int r=-1);
50  DtMatrix(DtMatrix* matM, bool copy = false);
51 
52  double** Init(int a, int b, bool init, int c=-1, int r=-1);
53  double** Init(DtMatrix* matM, bool copy = false);
54 
55  void UnInit();
56  virtual ~DtMatrix();
57 
59 
60  int rows(){return myRows;}
61  int columns(){return myColumns;}
62 
63  double get(int i,int j);
64  bool set(int i, int j, double val);
65 
66  static int rstart; // Initial r index.
67  static int cstart; // Initial c index.
68 
69  double** data ; // Uses flexible array indexing.
70 
71  void print( char * str);
72 
73  void setRows(int nR)
74  {
75  if(!myMaxRows)
76  {
77  myMaxRows=myRows;
78  myRows=nR;
79  }
80  }
81 
82  void setColumns(int nC)
83  {
84  if(!myMaxColumns)
85  {
86  myMaxColumns=myColumns;
87  myColumns=nC;
88  }
89  }
90 
91 
92  void restoreRows()
93  {
94  if(myMaxRows)
95  {
96  myRows=myMaxRows;
97  myMaxRows=0;
98  }
99  }
100  void restoreColumns()
101  {
102  if(myMaxColumns)
103  {
104  myColumns=myMaxColumns;
105  myMaxColumns=0;
106  }
107  }
108 
109  void identity(bool clear=false);
110  void all(double val);
111 
112  void AXB(DtMatrix* myMatB, DtMatrix* result);//Mike
113  DtMatrix* AXB(DtMatrix* myMatB);
114  DtMatrix* AXBT(DtMatrix* myMatB);
115 
116  bool UXB(DtMatrix* myMatB);
117  bool LXB(DtMatrix* myMatB);
118 
119  DtMatrix* UnMergeHorizontally(int c, DtMatrix* matR);
120  DtMatrix* UnMergeVertically(int r, DtMatrix* myMatB);
121 
122  DtMVector* House(int rs, int nc);
123  DtMVector* HouseT(int rs, int nc);
124 
125  bool RHouse(DtMVector* house, int rs, int cs);
126  bool CHouse(DtMVector* house, int rs, int cs);
127 
128  DtMatrix* QR(DtMatrix* matQ = 0);
129  DtMatrix* LQ(DtMatrix* matQ = 0);
130 
131  DtMatrix* SQRT(DtMatrix* matDiag);
132  DtMatrix* LDU(DtMatrix*, DtMatrix*, DtMatrix*);
133 
134  void Scale(double s);
135  void Accumulate(DtMatrix* myMatB, double s);
136 
137  void SetIndexes(int i, int j);
138  DtMVector* LinProg(DtMVector* myMatB, DtMVector* max);
139 
140  void IntersectionInit();
141 protected:
142  int Status(DtMatrixFlag);
143 
144 private:
145  int myRows;
149  double** myData;
150  double** myVData;
151  bool myUsed;
152 
153  // Experimental switch submatrix on the fly.
154  double** Data;
155  double** Data_data;
156  double** DataInit(int r,int c);
157 };
158 
159 
160 // The internal representation of
161 // vectors are potentially different. To facilitate
162 // the common notion of a DtVector some changes are made;
163 // these changes are transparent to the proper use of
164 // DtMatrix Routines. data[i][j] will still work.
165 // We can now also use vec[k];
166 //
168 {
169  friend class DtMatrix;
170  friend class DtLinearSystem;
171  friend DtMatrix* DtMatrixMultiply(DtMatrix* m, DtMVector* v, char* s, generic_mm_multflag f);
172 
173  friend bool DtIntersectionUniqueSolution(const DtVector& loc1,
174  const DtVector& loc2,
175  const DtDcm& m1,
176  const DtDcm& m2);
177 
180  friend DtMatrix* DtMSum(DtMVector* myMatA, DtMVector * myMatB, double s);
182  friend bool DtIntersection2(const DtVector& loc1, const DtVector& loc2, const DtDcm& m1, const DtDcm& m2, DtVector& l1, DtVector& l2);
183 
184 public:
185  DtMVector(int a, int bcolumnvector, bool initialize = true, int p = -1);
186  DtMVector(DtMVector* V, bool copy = false);
187 
188  virtual ~DtMVector();
189  double get(int i);
190  bool set(int i, double val);
191  DtMatrix* GenerateN(DtMatrix* mata);
192  void Accumulate(DtMVector* myMatB, double s, DtMatrix* myMatA);
193  int size(){return mySize;}
194  void unit(int i);
195  double* vec;
196 private:
197  double* myVec;
198  int mySize;
199 };
200 
201 
203 {
204 public:
205  DtLinearSystem(int _dim_X, int _dim_U, int _dim_Y, bool init=true,int c=-1,int r=-1);
213  int myDimX;
214  int myDimU;
215  int myDimY;
216 
217 private:
220 
221 };
222 
223 
224 
225 void simplx(double ** a, int m,int n,int m1,int m2, int m3, int * icase, int * izrov, int * ipposv);
226 void simp1(double ** a, int mm, int * ll, int nll, int iabf, int * kp, double * bmax) ;
227 void simp2(double ** a, int n, int * l2, int nl2,int * ip, int kp,double * q1);
228 void simp3(double ** a,int i1, int k1, int ip, int kp);
229 void print(double ** a,int r, int c,char *str);
230 
231 #endif //_DYAD_H_
232 

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)