libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
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>
46
class
LIBMOLDEO_API
moDMatrix
:
public
moAbstract
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>
143
moDVector<Real>
operator*
(
const
moDVector<Real>
& rkV,
const
moDMatrix<Real>
& rkM);
144
145
#ifndef MO_MACOSX
146
#ifndef MO_RASPBIAN
147
template
class
LIBMOLDEO_API
moDMatrix<MOfloat>
;
148
#endif
149
#endif
150
typedef
moDMatrix<MOfloat>
moDMatrixf
;
151
152
#ifndef MO_MACOSX
153
#ifndef MO_RASPBIAN
154
template
class
LIBMOLDEO_API
moDMatrix<MOdouble>
;
155
#endif
156
#endif
157
typedef
moDMatrix<MOdouble>
moDMatrixd
;
158
159
// moDBandedMatrix class ------------------------------------------------
160
161
template
<
class
Real>
162
class
moDBandedMatrix
:
public
moAbstract
163
{
164
public
:
165
moDBandedMatrix
(
int
iSize,
int
iLBands,
int
iUBands);
166
moDBandedMatrix
(
const
moDBandedMatrix
& rkM);
167
~
moDBandedMatrix
();
168
169
moDBandedMatrix
& operator= (
const
moDBandedMatrix
& rkM);
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
205
template
class
LIBMOLDEO_API
moDBandedMatrix<MOfloat>
;
206
#endif
207
#endif
208
#endif
209
typedef
moDBandedMatrix<MOfloat>
moDBandedMatrixf
;
210
211
#ifndef MO_MACOSX
212
#ifndef MO_RASPBIAN
213
#ifndef MO_WIN32
214
template
class
LIBMOLDEO_API
moDBandedMatrix<MOdouble>
;
215
#endif
216
#endif
217
#endif
218
typedef
moDBandedMatrix<MOdouble>
moDBandedMatrixd
;
219
220
221
222
#endif
223
moDMatrix
Definition:
moMathDMatrix.h:46
moDMatrixd
moDMatrix< MOdouble > moDMatrixd
Definition:
moMathDMatrix.h:157
operator>
bool operator>(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:280
moDMatrixf
moDMatrix< MOfloat > moDMatrixf
Definition:
moMathDMatrix.h:150
operator<
bool operator<(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:274
moMathDVector.h
moDMatrix::m_aafEntry
Real ** m_aafEntry
Definition:
moMathDMatrix.h:134
moAbstract
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition:
moAbstract.h:191
LIBMOLDEO_API
#define LIBMOLDEO_API
Definition:
moTypes.h:180
moDBandedMatrix::m_iUBands
int m_iUBands
Definition:
moMathDMatrix.h:196
moDBandedMatrixf
moDBandedMatrix< MOfloat > moDBandedMatrixf
Definition:
moMathDMatrix.h:209
moDBandedMatrix::m_aafLBand
Real ** m_aafLBand
Definition:
moMathDMatrix.h:198
moDVector
Definition:
moMathDVector.h:44
moDBandedMatrix::m_aafUBand
Real ** m_aafUBand
Definition:
moMathDMatrix.h:199
operator+
LIBMOLDEO_API moText0 operator+(const moText0 &txt1, const moText0 &txt2)
Definition:
moText.cpp:415
operator==
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:269
moDBandedMatrix::m_afDBand
Real * m_afDBand
Definition:
moMathDMatrix.h:197
moDBandedMatrixd
moDBandedMatrix< MOdouble > moDBandedMatrixd
Definition:
moMathDMatrix.h:218
operator>=
bool operator>=(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:282
moDMatrix::m_iRows
int m_iRows
Definition:
moMathDMatrix.h:126
operator!=
bool operator!=(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:279
moDMatrix::m_afData
Real * m_afData
Definition:
moMathDMatrix.h:129
operator*
moDMatrix< Real > operator*(Real fScalar, const moDMatrix< Real > &rkM)
Definition:
moMathDMatrix.cpp:474
operator<=
bool operator<=(const TiXmlString &a, const TiXmlString &b)
Definition:
tinystr.h:281
moDBandedMatrix
Definition:
moMathDMatrix.h:162
libmoldeo
moMathDMatrix.h
Generado el Martes, 10 de Septiembre de 2019 21:27:07 para libmoldeo (Moldeo 1.0 Core) por
1.8.13