libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moMathDMatrix.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moMathDMatrix.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28  Andrés Colubri
29 
30  Portions taken from
31  Wild Magic Source Code
32  David Eberly
33  http://www.geometrictools.com
34  Copyright (c) 1998-2007
35 
36 *******************************************************************************/
37 
38 #include "moMathDVector.h"
39 
40 #ifndef __MO_MATH_DMATRIX_H__
41 #define __MO_MATH_DMATRIX_H__
42 
43 // moDMatrix class ------------------------------------------------
44 
45 template <class Real>
47 {
48 public:
49  // construction and destruction
50  moDMatrix (int iRows = 0, int iCols = 0);
51  moDMatrix (int iRows, int iCols, const Real* afData);
52  moDMatrix (int iRows, int iCols, const Real** aafEntry);
53  moDMatrix (const moDMatrix& rkM);
54  ~moDMatrix ();
55 
56  // member access
57  void SetSize (int iRows, int iCols);
58  void GetSize (int& riRows, int& riCols) const;
59  int GetRows () const;
60  int GetColumns () const;
61  int GetQuantity () const;
62  operator const Real* () const;
63  operator Real* ();
64  const Real* operator[] (int iRow) const;
65  Real* operator[] (int iRow);
66  void SwapRows (int iRow0, int iRow1);
67  Real operator() (int iRow, int iCol) const;
68  Real& operator() (int iRow, int iCol);
69  void SetRow (int iRow, const moDVector<Real>& rkV);
70  moDVector<Real> GetRow (int iRow) const;
71  void SetColumn (int iCol, const moDVector<Real>& rkV);
72  moDVector<Real> GetColumn (int iCol) const;
73  void SetMatrix (int iRows, int iCols, const Real* afEntry);
74  void SetMatrix (int iRows, int iCols, const Real** aafMatrix);
75  void GetColumnMajor (Real* afCMajor) const;
76 
77  // assignment
78  moDMatrix& operator= (const moDMatrix& rkM);
79 
80  // comparison
81  bool operator== (const moDMatrix& rkM) const;
82  bool operator!= (const moDMatrix& rkM) const;
83  bool operator< (const moDMatrix& rkM) const;
84  bool operator<= (const moDMatrix& rkM) const;
85  bool operator> (const moDMatrix& rkM) const;
86  bool operator>= (const moDMatrix& rkM) const;
87 
88  // arithmetic operations
89  moDMatrix operator+ (const moDMatrix& rkM) const;
90  moDMatrix operator- (const moDMatrix& rkM) const;
91  moDMatrix operator* (const moDMatrix& rkM) const;
92  moDMatrix operator* (Real fScalar) const;
93  moDMatrix operator/ (Real fScalar) const;
94  moDMatrix operator- () const;
95 
96  // arithmetic updates
97  moDMatrix& operator+= (const moDMatrix& rkM);
98  moDMatrix& operator-= (const moDMatrix& rkM);
99  moDMatrix& operator*= (Real fScalar);
100  moDMatrix& operator/= (Real fScalar);
101 
102  // matrix products
103  moDMatrix Transpose () const; // M^T
104  moDMatrix TransposeTimes (const moDMatrix& rkM) const; // this^T * M
105  moDMatrix TimesTranspose (const moDMatrix& rkM) const; // this * M^T
106 
107  // matrix-vector operations
108  moDVector<Real> operator* (const moDVector<Real>& rkV) const; // M * v
109  Real QForm (const moDVector<Real>& rkU, const moDVector<Real>& rkV)
110  const; // u^T*M*v
111 
112  // Inversion. The matrix must be square. The function returns true
113  // whenever the matrix is square and invertible.
114  bool GetInverse (moDMatrix<Real>& rkInverse) const;
115 
116 protected:
117  // Support for allocation and deallocation. The allocation call requires
118  // m_iRows, m_iCols, and m_iQuantity to have already been correctly
119  // initialized.
120  void Allocate (bool bSetToZero);
121  void Deallocate ();
122 
123  // support for comparisons
124  int CompareArrays (const moDMatrix& rkM) const;
125 
126  int m_iRows, m_iCols, m_iQuantity;
127 
128  // the matrix is stored in row-major form as a 1-dimensional array
129  Real* m_afData;
130 
131  // An array of pointers to the rows of the matrix. The separation of
132  // row pointers and actual data supports swapping of rows in linear
133  // algebraic algorithms such as solving linear systems of equations.
134  Real** m_aafEntry;
135 };
136 
137 // c * M
138 template <class Real>
139 moDMatrix<Real> operator* (Real fScalar, const moDMatrix<Real>& rkM);
140 
141 // v^T * M
142 template <class Real>
144 
145 #ifndef MO_MACOSX
146 #ifndef MO_RASPBIAN
148 #endif
149 #endif
150 typedef moDMatrix<MOfloat> moDMatrixf;
151 
152 #ifndef MO_MACOSX
153 #ifndef MO_RASPBIAN
155 #endif
156 #endif
157 typedef moDMatrix<MOdouble> moDMatrixd;
158 
159 // moDBandedMatrix class ------------------------------------------------
160 
161 template <class Real>
163 {
164 public:
165  moDBandedMatrix (int iSize, int iLBands, int iUBands);
166  moDBandedMatrix (const moDBandedMatrix& rkM);
167  ~moDBandedMatrix ();
168 
170 
171  int GetSize () const;
172  int GetLBands () const;
173  int GetUBands () const;
174 
175  Real* GetDBand ();
176  const Real* GetDBand () const;
177 
178  int GetLBandMax (int i) const; // LBand(i): 0 <= index < LBandMax
179  Real* GetLBand (int i);
180  const Real* GetLBand (int i) const;
181 
182  int GetUBandMax (int i) const; // UBand(i): 0 <= index < UBandMax
183  Real* GetUBand (int i);
184  const Real* GetUBand (int i) const;
185 
186  Real& operator() (int iRow, int iCol);
187  Real operator() (int iRow, int iCol) const;
188 
189  void SetZero ();
190  void SetIdentity ();
191 
192 private:
193  void Allocate ();
194  void Deallocate ();
195 
196  int m_iSize, m_iLBands, m_iUBands;
197  Real* m_afDBand;
198  Real** m_aafLBand;
199  Real** m_aafUBand;
200 };
201 
202 #ifndef MO_MACOSX
203 #ifndef MO_RASPBIAN
204 #ifndef MO_WIN32
206 #endif
207 #endif
208 #endif
209 typedef moDBandedMatrix<MOfloat> moDBandedMatrixf;
210 
211 #ifndef MO_MACOSX
212 #ifndef MO_RASPBIAN
213 #ifndef MO_WIN32
215 #endif
216 #endif
217 #endif
218 typedef moDBandedMatrix<MOdouble> moDBandedMatrixd;
219 
220 
221 
222 #endif
223 
bool operator<=(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:960
moDMatrix< MOdouble > moDMatrixd
moDMatrix< MOfloat > moDMatrixf
moMatrix3 operator-(const moMatrix3 &rkM) const
moMatrix3 operator/(Real fScalar) const
bool operator>(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:966
Real QForm(const moVector3< Real > &rkU, const moVector3< Real > &rkV) const
Real ** m_aafEntry
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
#define LIBMOLDEO_API
Definition: moTypes.h:180
void SetRow(int iRow, const moVector3< Real > &rkV)
Definition: moMathMatrix.h:895
moDBandedMatrix< MOfloat > moDBandedMatrixf
void GetColumnMajor(Real *afCMajor) const
Definition: moMathMatrix.h:925
moMatrix3 & operator-=(const moMatrix3 &rkM)
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
bool operator==(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:942
void SetColumn(int iCol, const moVector3< Real > &rkV)
Definition: moMathMatrix.h:911
moVector3< Real > GetRow(int iRow) const
Definition: moMathMatrix.h:904
bool operator<(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:954
moVector3< Real > GetColumn(int iCol) const
Definition: moMathMatrix.h:919
moMatrix3 & operator/=(Real fScalar)
moMatrix3< Real > TimesTranspose(const moMatrix3 &rkM) const
moDBandedMatrix< MOdouble > moDBandedMatrixd
bool operator!=(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:948
moMatrix3 & operator*=(Real fScalar)
bool operator>=(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:972
moMatrix3 & operator=(const moMatrix3 &rkM)
Real * m_afData
moMatrix3< Real > Transpose() const
Definition: moMathMatrix.h:978
Real operator()(int iRow, int iCol) const
moDMatrix< Real > operator*(Real fScalar, const moDMatrix< Real > &rkM)
moMatrix3 operator+(const moMatrix3 &rkM) const
moMatrix3 & operator+=(const moMatrix3 &rkM)
moMatrix3< Real > TransposeTimes(const moMatrix3 &rkM) const
Definition: moMathMatrix.h:993
moTypes MOint moText moParamIndex moParamReference int iRow int iRow
Definition: all_f.js:18
const Real * operator[](int iRow) const