21 template <
class T,
unsigned SX,
unsigned SY=SX>
class Matrix {
29 Column(
const Column &r) : x_(r.x_), m_(r.m_) { }
31 const T &
operator[](
unsigned y)
const {
return m_.get(x_,y); }
33 T &
operator[](
unsigned y) {
return m_.get(x_,y); }
40 template <
unsigned SZ,
unsigned I,
unsigned J,
unsigned K>
44 return l.t_[SX-I][SY-K]*m.t_[SY-K][SZ-J] + innerLoop<SZ,I,J,K-1>::execute(l,m);
47 template <
unsigned SZ,
unsigned I,
unsigned J>
48 class innerLoop<SZ,I,J,1> {
51 return l.t_[SX-I][SY-1]*m.t_[SY-1][SZ-J];
54 template <
unsigned I,
unsigned K>
55 class innerLoop<1,I,1,K> {
58 return l.t_[SX-I][SY-K]*m.t_[SY-K] + innerLoop<1,I,1,K-1>::execute(l,m);
62 class innerLoop<1,I,1,1> {
65 return l.t_[SX-I][SY-1]*m.t_[SY-1];
69 template <
unsigned SZ,
unsigned I,
unsigned J>
73 ret.t_[SX-I][SZ-J] = innerLoop<SZ,I,J,SY>::execute(l,m);
74 loop2Multiply<SZ,I,J-1>::execute(l,m,ret);
77 template <
unsigned SZ,
unsigned I>
78 class loop2Multiply<SZ,I,1> {
81 ret.t_[SX-I][SZ-1] = innerLoop<SZ,I,1,SY>::execute(l,m);
85 class loop2Multiply<1,I,1> {
88 ret.t_[SX-I] = innerLoop<1,I,1,SY>::execute(l,m);
92 template <
unsigned SZ,
unsigned I>
96 loop2Multiply<SZ,I,SZ>::execute(l,m,ret);
97 loopMultiply<SZ,I-1>::execute(l,m,ret);
100 template <
unsigned SZ>
101 class loopMultiply<SZ,1> {
104 loop2Multiply<SZ,1,SZ>::execute(l,m,ret);
113 #pragma warning(push) 114 #pragma warning(disable:26495) // Uninitialize warning 126 const T &
get(
unsigned x,
unsigned y)
const { assert(x<SX); assert(y<SY);
return t_[x][y]; }
128 T &
get(
unsigned x,
unsigned y) { assert(x<SX); assert(y<SY);
return t_[x][y]; }
130 const Column
operator[](
unsigned y)
const {
return Column(y,*
this); }
156 template <
unsigned SZ>
168 loopMultiply<SZ,SX>::execute(*
this,m,ret);
188 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
190 addGenBlock<BX,BY,SX2,SY2>(m,iSrc*BX,jSrc*BY,iDst*BX,jDst*BY);
193 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
195 for (
unsigned i=iSrc,
id=iDst;i<(iSrc+BX);i++,
id++)
196 for (
unsigned j=jSrc,jd=jDst;j<(jSrc+BY);j++,jd++)
197 get(
id,jd) += m(i,j);
201 T
maxNorm()
const { T ret(0);
for (
unsigned i=0;i<SX;++i)
for (
unsigned j=0;j<SY;++j) ret = std::max(ret,std::abs(t_[i][j]));
return ret; }
205 T
trace()
const { T tt = t_[0][0];
unsigned len = std::min(SX,SY);
for (
unsigned i=1; i<len; ++i) tt += t_[i][i];
return tt; }
207 void set(
const T &t=T()) {
for (
unsigned i=0;i<SX;++i)
for (
unsigned j=0;j<SY;++j) t_[i][j] = t; }
217 template <
class T,
unsigned SX>
class Matrix<T,SX,1> {
233 const T &
get(
unsigned x,
unsigned y)
const { assert(x<SX); assert(!y); y;
return t_[x]; }
235 const T &
get(
unsigned x)
const { assert(x<SX);
return t_[x]; }
237 T &
get(
unsigned x,
unsigned y) { assert(x<SX); assert(!y); y;
return t_[x]; }
239 T &
get(
unsigned x) { assert(x<SX);
return t_[x]; }
269 for (
unsigned i=0;i<SX;++i)
270 for (
unsigned j=0;j<SZ;++j)
277 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
void addBlock(
const Matrix<T,SX2,SY2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
278 addGenBlock<BX,BY,SX2,SY2>(m,iSrc*BX,jSrc*BY,iDst*BX,jDst*BY);
282 addGenBlock<BX,SX2>(m,iSrc*BX,iDst*BX);
285 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
void addGenBlock(
const Matrix<T,SX2,SY2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
286 for (
unsigned i=iSrc,
id=iDst;i<(iSrc+BX);i++,
id++)
287 for (
unsigned j=jSrc,jd=jDst;j<(jSrc+BY);j++,jd++)
288 get(
id,jd) += m(i,j);
292 for (
unsigned i=iSrc,
id=iDst;i<(iSrc+BX);i++,
id++)
297 T
maxNorm()
const { T ret(0);
for (
unsigned i=0;i<SX;++i) ret = std::max(ret,std::abs(t_[i]));
return ret; }
301 void set(
const T &t=T()) {
for (
unsigned i=0;i<SX;++i) t_[i] = t; }
320 Column(
const Column &r) : x_(r.x_), m_(r.m_) { }
322 const T &
operator[](
unsigned y)
const {
return m_.get(x_,y); }
324 T &
operator[](
unsigned y) {
return m_.get(x_,y); }
331 template <
unsigned SZ,
unsigned I,
unsigned J,
unsigned K>
335 return l.t_[index(SX-I,SX-K)]*m.t_[SX-K][SZ-J] + innerLoop<SZ,I,J,K-1>::execute(l,m);
338 template <
unsigned SZ,
unsigned I,
unsigned J>
339 class innerLoop<SZ,I,J,1> {
342 return l.t_[index(SX-I,SX-1)]*m.t_[SX-1][SZ-J];
345 template <
unsigned I,
unsigned K>
346 class innerLoop<1,I,1,K> {
349 return l.t_[index(SX-I,SX-K)]*m.t_[SX-K] + innerLoop<1,I,1,K-1>::execute(l,m);
352 template <
unsigned I>
353 class innerLoop<1,I,1,1> {
356 return l.t_[index(SX-I,SX-1)]*m.t_[SX-1];
360 template <
unsigned SZ,
unsigned I,
unsigned J>
361 class loop2Multiply {
364 ret.t_[SX-I][SZ-J] = innerLoop<SZ,I,J,SX>::execute(l,m);
365 loop2Multiply<SZ,I,J-1>::execute(l,m,ret);
368 template <
unsigned SZ,
unsigned I>
369 class loop2Multiply<SZ,I,1> {
372 ret.t_[SX-I][SZ-1] = innerLoop<SZ,I,1,SX>::execute(l,m);
375 template <
unsigned I>
376 class loop2Multiply<1,I,1> {
379 ret.t_[SX-I] = innerLoop<1,I,1,SX>::execute(l,m);
383 template <
unsigned SZ,
unsigned I>
387 loop2Multiply<SZ,I,SZ>::execute(l,m,ret);
388 loopMultiply<SZ,I-1>::execute(l,m,ret);
391 template <
unsigned SZ>
392 class loopMultiply<SZ,1> {
395 loop2Multiply<SZ,1,SZ>::execute(l,m,ret);
401 template <
unsigned I,
unsigned J,
unsigned K>
405 return l.t_[index(SX-I,SX-K)]*m.t_[index(SX-K,SX-J)] + innerLoopS<I,J,K-1>::execute(l,m);
409 template <
unsigned I,
unsigned J>
410 class innerLoopS<I,J,1> {
413 return l.t_[index(SX-I,SX-1)]*m.t_[index(SX-1,SX-J)];
419 template <
unsigned I,
unsigned J>
420 class loop2MultiplyS {
423 ret.t_[SX-I][SX-J] = innerLoopS<I,J,SX>::execute(l,m);
424 loop2MultiplyS<I,J-1>::execute(l,m,ret);
427 template <
unsigned I>
428 class loop2MultiplyS<I,1> {
431 ret.t_[SX-I][SX-1] = innerLoopS<I,1,SX>::execute(l,m);
435 template <
unsigned I>
436 class loopMultiplyS {
439 loop2MultiplyS<I,SX>::execute(l,m,ret);
440 loopMultiplyS<I-1>::execute(l,m,ret);
445 class loopMultiplyS<1> {
448 loop2MultiplyS<1,SX>::execute(l,m,ret);
468 const T &
get(
unsigned x,
unsigned y)
const {
return t_[index(x,y)]; }
470 T &
get(
unsigned x,
unsigned y) {
return t_[index(x,y)]; }
472 const Column
operator[](
unsigned y)
const {
return Column(y,*
this); }
505 loopMultiplyS<SX>::execute(*
this,m,ret);
519 loopMultiply<SZ,SX>::execute(*
this,m,ret);
544 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
void addBlock(
const Matrix<T,SX2,SY2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
545 addGenBlock<BX,BY,SX2,SY2>(m,iSrc*BX,jSrc*BY,iDst*BX,jDst*BY);
548 template <
unsigned BX,
unsigned BY,
unsigned SX2>
void addBlock(
const SymMatrix<T,SX2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
549 addGenBlock<BX,BY,SX2>(m,iSrc*BX,jSrc*BY,iDst*BX,jDst*BY);
552 template <
unsigned BX,
unsigned BY,
unsigned SX2,
unsigned SY2>
void addGenBlock(
const Matrix<T,SX2,SY2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
553 for (
unsigned i=iSrc,
id=iDst;i<(iSrc+BX);i++,
id++) {
554 for (
unsigned j=jSrc,jd=jDst;j<(jSrc+BY);j++,jd++) {
556 get(
id,jd) += m(i,j);
561 template <
unsigned BX,
unsigned BY,
unsigned SX2>
void addGenBlock(
const SymMatrix<T,SX2> &m,
unsigned iSrc,
unsigned jSrc,
unsigned iDst,
unsigned jDst) {
562 for (
unsigned i=iSrc,
id=iDst;i<(iSrc+BX);i++,
id++) {
563 for (
unsigned j=jSrc,jd=jDst;j<(jSrc+BY);j++,jd++) {
565 get(
id,jd) += m(i,j);
571 T
maxNorm()
const { T ret(0);
for (
unsigned i=0;i<len_;++i) ret = std::max(std::abs(t_[i]),ret);
return ret; }
575 T
trace()
const { T tt = t_[0];
for (
unsigned i=1; i<SX; ++i) tt +=
get(i,i);
return tt; }
577 void set(
const T &t=T()) {
for (
unsigned i=0;i<len_;++i) t_[i] = t; }
589 for (
unsigned i=0;i<SX;++i) {
591 for (
unsigned j=i+1;j<SX;++j) {
592 ret(i,j) = (m(i,j) + m(j,i)) * 0.5;
594 maxdif = std::max(std::abs(ret(i,j) - m(i,j)),maxdif);
604 static constexpr
unsigned len_ = (SX*SX + SX) / 2;
605 static constexpr
unsigned indexConst_ = 1 + 2*SX;
606 static constexpr
unsigned index(
unsigned x,
unsigned y) {
607 unsigned x2 = x > y ? y : x;
608 unsigned y2 = x > y ? x : y;
609 unsigned i = (((indexConst_-x2)*x2)/2) + (y2-x2);
620 template <
class T,
unsigned SX,
unsigned SY,
unsigned I,
unsigned J,
unsigned K>
627 template <
class T,
unsigned SX,
unsigned SY,
unsigned I,
unsigned J>
631 return l.t_[SX-I][SY-1]*m.t_[m.index(SY-1,SY-J)];
635 template <
class T,
unsigned SX,
unsigned SY,
unsigned I,
unsigned J>
643 template <
class T,
unsigned SX,
unsigned SY,
unsigned I>
651 template <
class T,
unsigned SX,
unsigned SY,
unsigned I>
659 template <
class T,
unsigned SX,
unsigned SY>
667 template <
class T,
unsigned SX,
unsigned SY>
719 template <
unsigned SX,
unsigned SY=SX>
class DMatrix :
public Matrix<double,SX,SY> {
772 template <
class T,
unsigned S>
775 for (
UInt i=0;i<S;++i)
782 for (
UInt i=0;i<S;++i) {
783 for (
UInt j=0;j<S;++j)
784 ret(i,j) = v1(i) * v2(j);
794 ret.
get(0,0) = v1.
x() * v2.
x();
795 ret.
get(0,1) = v1.
x() * v2.
y();
796 ret.
get(0,2) = v1.
x() * v2.
z();
797 ret.
get(1,0) = v1.
y() * v2.
x();
798 ret.
get(1,1) = v1.
y() * v2.
y();
799 ret.
get(1,2) = v1.
y() * v2.
z();
800 ret.
get(2,0) = v1.
z() * v2.
x();
801 ret.
get(2,1) = v1.
z() * v2.
y();
802 ret.
get(2,2) = v1.
z() * v2.
z();
811 ret.
get(0,0) = v1.
x() * v2.
x();
812 ret.
get(0,1) = v1.
x() * v2.
y();
813 ret.
get(1,0) = v1.
y() * v2.
x();
814 ret.
get(1,1) = v1.
y() * v2.
y();
823 T t = mat.
get(0,0) * (mat.
get(1,1) * mat.
get(2,2) - mat.
get(2,1) * mat.
get(1,2));
824 t -= mat.
get(1,0) * (mat.
get(0,1) * mat.
get(2,2) - mat.
get(2,1) * mat.
get(0,2));
825 t += mat.
get(2,0) * (mat.
get(0,1) * mat.
get(1,2) - mat.
get(1,1) * mat.
get(0,2));
833 return mat.
get(0,0) * mat.
get(1,1) - mat.
get(0,1) * mat.
get(1,0);
842 T a11 = mat.
get(0,0), a21 = mat.
get(1,0), a31 = mat.
get(2,0);
843 T a12 = mat.
get(0,1), a22 = mat.
get(1,1), a32 = mat.
get(2,1);
844 T a13 = mat.
get(0,2), a23 = mat.
get(1,2), a33 = mat.
get(2,2);
847 rm.
get(0,0) = a22*a33 - a32*a23;
848 rm.
get(1,0) = -a21*a33 + a31*a23;
849 rm.
get(2,0) = a21*a32 - a31*a22;
850 rm.
get(0,1) = -a12*a33 + a32*a13;
851 rm.
get(1,1) = a11*a33 - a31*a13;
852 rm.
get(2,1) = -a11*a32 + a31*a12;
853 rm.
get(0,2) = a12*a23 - a22*a13;
854 rm.
get(1,2) = -a11*a23 + a21*a13;
855 rm.
get(2,2) = a11*a22 - a21*a12;
882 ret.
get(start) = v.
x();
883 ret.
get(start+1) = v.
y();
884 ret.
get(start+2) = v.
z();
896 v.
x()*m.
get(1,0) + v.
y()*m.
get(1,1));
904 v.
x()*m.
get(1,0) + v.
y()*m.
get(1,1));
913 v.
x()*m.
get(2,0) + v.
y()*m.
get(2,1) + v.
z()*m.
get(2,2));
922 v.
x()*m.
get(2,0) + v.
y()*m.
get(2,1) + v.
z()*m.
get(2,2));
941 (m.
get(0,1)+m.
get(1,0))*0.5,
942 (m.
get(0,2)+m.
get(2,0))*0.5,
943 (m.
get(1,2)+m.
get(2,1))*0.5);
951 (m.
get(0,1)+m.
get(1,0))*0.5,
986 template <
class T,
unsigned SY>
987 void vectorToColumn(
Matrix<T,2,SY> &m,
const DVect2 &v,
unsigned col) { m(0,col) = v.x(); m(1,col) = v.y(); }
989 template <
class T,
unsigned SY>
990 void vectorToColumn(
Matrix<T,3,SY> &m,
const DVect3 &v,
unsigned col) { m(0,col) = v.x(); m(1,col) = v.y(); m(2,col) = v.z(); }
992 template <
class T,
unsigned SX>
993 void vectorToRow(
Matrix<T,SX,2> &m,
const DVect2 &v,
unsigned row) { m(row,0) = v.x(); m(row,1) = v.y(); }
995 template <
class T,
unsigned SX>
996 void vectorToRow(
Matrix<T,SX,3> &m,
const DVect3 &v,
unsigned row) { m(row,0) = v.x(); m(row,1) = v.y(); m(row,2) = v.z(); }
998 template <
class T,
unsigned SX,
unsigned SY>
1001 for (
unsigned i=0;i<SX;++i)
A Symmetric 2nd order tensor.
A 1-Dimensional version of Matrix, to represent a vector.
Definition: matrix.h:687
const DVMatrix< S > & operator=(const Matrix< double, S, 1 > &m)
Equality operator, for matrix class.
Definition: matrix.h:769
T & operator()(unsigned x, unsigned y)
() operator access to get(x,y)
Definition: matrix.h:136
const Matrix< T, SX, SY > & operator/=(const T &t)
In-place division by a scalar.
Definition: matrix.h:145
Column operator[](unsigned y)
Array access operator returns a Column helper class, which has it's own [] operator to access a colum...
Definition: matrix.h:132
VMatrix()
Default constructor - no data initialization.
Definition: matrix.h:690
Matrix< T, SX, SY > operator/(const T &t) const
Binary scalar division operator.
Definition: matrix.h:154
Matrix< T, 2, 2 > outerProduct(const Vector2< T > &v1, const Vector2< T > &v2)
Creates a 2X2 Matrix from the outer product of two Vector2 types.
Definition: matrix.h:809
const Matrix< T, SX, 1 > & operator-=(const Matrix< T, SX, 1 > &m)
In-place matrix subtraction.
Definition: matrix.h:252
DVMatrix()
Default constructor, no data initialization.
Definition: matrix.h:759
void addBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from block indices (iSrc,...
Definition: matrix.h:277
const Matrix< T, SX, 1 > & operator+=(const Matrix< T, SX, 1 > &m)
In-place matrix addition.
Definition: matrix.h:250
T & get(unsigned x, unsigned y)
Retrieve value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:470
VMatrix(const Matrix< T, S, 1 > &m)
Copy contructor, works on Matrix if SY is 1.
Definition: matrix.h:696
DMatrix is a Matrix that defaults to type double...
Definition: matrix.h:719
Matrix()
Default constructor, does nothing and no initialization.
Definition: matrix.h:115
T & operator[](unsigned x)
1D version of array operator, which currently unfortunately eliminates [x][0] syntax on VMatrix (may ...
Definition: matrix.h:709
VMatrix< T, SX > toVMatrix(const Vector3< T > &v, unsigned start=0)
Converts a Vector3 into a VMatrix of arbitrary size, at an arbitrary starting index.
Definition: matrix.h:880
const T & operator()(unsigned x, unsigned y) const
() operator access to get(x,y)
Definition: matrix.h:476
void addGenBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from normal not block indices...
Definition: matrix.h:285
DMatrix(const double &t)
Explicit contructor, initializes all elements to t.
Definition: matrix.h:724
A specialization of the Matrix class for the case when SY=1.
Definition: matrix.h:217
T trace() const
Return the trace of the matrix or the sum of the diagonal components. Works also if the matrix is not...
Definition: matrix.h:575
SymMatrix< T, SX > transpose() const
Return the transpose of the matrix.
Definition: matrix.h:573
Matrix< T, SX, SX > toMatrix() const
Returns its copy.
Definition: matrix.h:579
T maxNorm() const
Returns the infinity norm of the matrix, or the maximum absolute magnitude of any element.
Definition: matrix.h:571
Vector2< T > toVector(const VMatrix< T, 2 > &m)
Converts a VMatrix to a Vector3, using three elements starting at index start.
Definition: matrix.h:972
const Matrix< T, SX, 1 > & operator/=(const T &t)
In-place division by a scalar.
Definition: matrix.h:256
const Matrix< T, SX, SY > & operator=(const Matrix< T, SX, SY > &m)
Equality operator.
Definition: matrix.h:123
const T & operator()(unsigned x) const
() operator access to const get(x)
Definition: matrix.h:243
Vector2< T > operator *(const Matrix< T, 2, 2 > &m, const Vector2< T > &v)
Definition: matrix.h:894
SymTensor toSymTensor(const DMatrix< 3, 3 > &m)
Definition: matrix.h:937
Matrix< T, SX, SY > operator *(const T &t) const
Binary scalar multiplication operator.
Definition: matrix.h:152
Matrix< T, SY, SX > transpose() const
Return the transpose of the matrix.
Definition: matrix.h:203
DVMatrix(const double &d)
Explicit contructor, initializes all elements to t.
Definition: matrix.h:761
const Column operator[](unsigned y) const
Array access operator returns a Column helper class, which has it's own [] operator to access a colum...
Definition: matrix.h:472
Matrix< T, SX, SX > operator+(const Matrix< T, SX, SX > &m) const
Binary addition operator.
Definition: matrix.h:492
Vector2< T > rowToVector(const Matrix< T, SX, 2 > &m, unsigned row)
returns in a Vector2<t> the row row from matrix Matrix<T,SX,2>
Definition: matrix.h:982
Matrix< T, SX, 1 > operator-(const Matrix< T, SX, 1 > &m) const
Binary subtraction operator.
Definition: matrix.h:261
Vector2< T > toVector2(const VMatrix< T, SX > &m, unsigned start=0)
Converts a VMatrix to a Vector2, using two elements starting at index start.
Definition: matrix.h:966
const T & get(unsigned x, unsigned y) const
Retrieve value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:126
const SymMatrix< T, SX > & operator *=(const T &t)
In-place multiplication by a scalar.
Definition: matrix.h:485
const DMatrix< SX, SY > & operator=(const Matrix< double, SX, SY > &m)
Equality operator, for Matrix.
Definition: matrix.h:732
DVMatrix(const Matrix< double, S, 1 > &m)
Copy constructor, for Matrix class.
Definition: matrix.h:765
debug checked shorthand for std::numeric_limits<T>::
Definition: limit.h:25
unsigned int UInt
unsigned 32 bit
Definition: basedef.h:31
const DMatrix< SX, SY > & operator=(const DMatrix< SX, SY > &m)
Equality operator.
Definition: matrix.h:730
SymMatrix< T, SX > operator/(const T &t) const
Binary scalar division operator for a symetric matrix.
Definition: matrix.h:501
void addBlock(const SymMatrix< T, SX2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from block indices (iSrc,...
Definition: matrix.h:548
Matrix< T, 1, SX > transpose() const
returns the transposed matrix of this matrix
Definition: matrix.h:299
void addBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from block indices (iSrc,...
Definition: matrix.h:189
const T & operator()(unsigned x, unsigned y) const
() operator access to get(x,y)
Definition: matrix.h:134
T maxNorm() const
Returns the infinity norm of the matrix, or the maximum absolute magnitude of any element.
Definition: matrix.h:201
T maxNorm() const
Returns the infinity norm of the matrix, or the maximum absolute magnitude of any element.
Definition: matrix.h:297
SymTensor toSymTensor(const DSymMatrix< 3 > &m)
Definition: matrix.h:959
#define BASE_EXPORT
Definition: basedef.h:21
const DSymMatrix< SX > & operator=(const SymMatrix< double, SX > &m)
Equality operator, for Matrix.
Definition: matrix.h:751
DSymMatrix(const SymMatrix< double, SX > &m)
Copy constructor, for SymMatrix.
Definition: matrix.h:747
void addBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from block indices (iSrc,...
Definition: matrix.h:544
A symmetric 2nd order tensor.
Definition: symtensor.h:19
DSymMatrix(const double &t)
Explicit contructor, initializes all elements to t.
Definition: matrix.h:743
const T & y() const
Y component access.
Definition: vect.h:56
const SymMatrix< T, SX > & operator-=(const SymMatrix< T, SX > &m)
In-place matrix subtraction.
Definition: matrix.h:483
DVMatrix< SX > toDVMatrix(const DVect3 &v, unsigned start=0)
Definition: matrix.h:890
const T & get(unsigned x, unsigned y) const
Retrieve constant value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:233
void addGenBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from normal not block indices...
Definition: matrix.h:194
Matrix< T, SX, SX > operator-(const Matrix< T, SX, SX > &m) const
Binary subtraction operator.
Definition: matrix.h:496
Matrix()
Default constructor, does nothing and no initialization.
Definition: matrix.h:223
Matrix< T, 3, 3 > inverse(const Matrix< T, 3, 3 > &mat)
Returns the inverse of a 3X3 Matrix.
Definition: matrix.h:840
void set(const T &t=T())
Sets all matrix elemnts to T.
Definition: matrix.h:301
static SymMatrix< T, SX > fromMatrix(const Matrix< T, SX, SX > &m)
Assign from full matrix.
Definition: matrix.h:584
2D vector utility class.
Definition: vect.h:31
const DSymMatrix< SX > & operator=(const DSymMatrix< SX > &m)
Equality operator.
Definition: matrix.h:749
T determinant(const Matrix< T, 3, 3 > &mat)
Returns the determinant of a 3X3 Matrix.
Definition: matrix.h:822
DSymMatrix(const DSymMatrix< SX > &m)
Copy constructor.
Definition: matrix.h:745
void set(const T &t=T())
Set all entries in the matrix to t.
Definition: matrix.h:207
const Matrix< T, SX, SY > & operator+=(const Matrix< T, SX, SY > &m)
In-place matrix addition.
Definition: matrix.h:139
const T & operator[](unsigned x) const
1D version of array operator, which currently unfortunately eliminates [x][0] syntax on VMatrix (may ...
Definition: matrix.h:707
const T & z() const
The z-component of the vector.
Definition: vect.h:186
SymMatrix()
Default constructor, does nothing and no initialization.
Definition: matrix.h:458
T & operator()(unsigned x, unsigned y)
() operator access to get(x,y)
Definition: matrix.h:245
Vector2< T > columnToVector(const Matrix< T, 2, SY > &m, unsigned col)
returns in a Vector2<t> the column col from matrix Matrix<T,SX,2>
Definition: matrix.h:978
void addGenBlock(const Matrix< T, SX2, 1 > &m, unsigned iSrc, unsigned iDst)
Adds a block to this matrix from matrix m using the block size BX from normal non block indice iSrc t...
Definition: matrix.h:291
Matrix(const Matrix< T, SX, SY > &m)
Copy constructor.
Definition: matrix.h:121
SymMatrix< T, SX > operator-(const SymMatrix< T, SX > &m) const
Binary subtraction operator for a symetric matrix.
Definition: matrix.h:494
const VMatrix< T, S > & operator=(const VMatrix< T, S > &m)
Equality operator.
Definition: matrix.h:698
const T & get(unsigned x, unsigned y) const
Retrieve value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:468
VMatrix(const VMatrix< T, S > &m)
Copy constructor.
Definition: matrix.h:694
SymMatrix(const SymMatrix< T, SX > &m)
Copy constructor.
Definition: matrix.h:463
T determinant(const Matrix< T, 2, 2 > &mat)
Returns the determinant of a 2X2 Matrix.
Definition: matrix.h:832
Matrix< T, SX, SY > operator+(const Matrix< T, SX, SY > &m) const
Binary addition operator.
Definition: matrix.h:148
VMatrix< T, 3 > toMatrix(const Vector3< T > &v)
Definition: matrix.h:871
DSymMatrix is a SymMatrix that defaults to type double...
Definition: matrix.h:738
DMatrix()
Default constructor, no data initialization.
Definition: matrix.h:722
A template-based matrix class, size fixed at compile time. Defaults to symmetric sized matrix.
Definition: matrix.h:21
const Matrix< T, SX, SY > & operator-=(const Matrix< T, SX, SY > &m)
In-place matrix subtraction.
Definition: matrix.h:141
DVMatrix(const DVMatrix< S > &m)
Copy constructor.
Definition: matrix.h:763
T & operator()(unsigned x)
() operator access to get(x)
Definition: matrix.h:247
VMatrix< T, 2 > toMatrix(const Vector2< T > &v)
Definition: matrix.h:862
const Matrix< T, SX, 1 > & operator=(const Matrix< T, SX, 1 > &m)
Equality operator.
Definition: matrix.h:230
VMatrix(const T &t)
Explicit constructor, all elements initialzed to t.
Definition: matrix.h:692
SymMatrix< T, SX > operator+(const SymMatrix< T, SX > &m) const
Binary addition operator for a symetric matris.
Definition: matrix.h:490
Matrix< T, SX, 1 > operator+(const Matrix< T, SX, 1 > &m) const
Binary addition operator.
Definition: matrix.h:259
A template-based symmetric matrix class, size fixed at compile time. This primitive template-based ma...
Definition: matrix.h:312
Matrix< T, 3, 3 > outerProduct(const Vector3< T > &v1, const Vector3< T > &v2)
Creates a 3X3 Matrix from the outer product of two Vector3 types.
Definition: matrix.h:792
Column operator[](unsigned y)
Array access operator returns a Column helper class, which has it's own [] operator to access a colum...
Definition: matrix.h:474
const Column operator[](unsigned y) const
Array access operator returns a Column helper class, which has it's own [] operator to access a colum...
Definition: matrix.h:130
3D vector utility class.
Definition: vect.h:161
const Matrix< T, SX, SY > & operator *=(const T &t)
In-place multiplication by a scalar.
Definition: matrix.h:143
Matrix< T, SX, 1 > operator/(const T &t) const
Binary scalar division operator.
Definition: matrix.h:265
T & operator()(unsigned x, unsigned y)
() operator access to get(x,y)
Definition: matrix.h:478
const DVMatrix< S > & operator=(const DVMatrix< S > &m)
Equality operator.
Definition: matrix.h:767
BASE_EXPORT DSymMatrix< 3 > toSymMatrix(const SymTensor &s)
Definition: matrix.cpp:16
DVMatrix is a double version of VMatrix.
Definition: matrix.h:756
T trace() const
Return the trace of the matrix or the sum of the diagonal components. Works also if the matrix is not...
Definition: matrix.h:205
T & get(unsigned x, unsigned y)
Retrieve value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:237
Vector3< Double > DVect3
Definition: vect.h:289
const T & x() const
X component access.
Definition: vect.h:54
void addGenBlock(const Matrix< T, SX2, SY2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from normal not block indices...
Definition: matrix.h:552
Vector2< Double > DVect2
Definition: vect.h:282
DMatrix(const Matrix< double, SX, SY > &m)
Copy constructor, for Matrix.
Definition: matrix.h:728
Matrix(const Matrix< T, SX, 1 > &m)
Copy constructor.
Definition: matrix.h:228
void addGenBlock(const SymMatrix< T, SX2 > &m, unsigned iSrc, unsigned jSrc, unsigned iDst, unsigned jDst)
Adds a block to this matrix from matrix m using the block size (BX,BY), from normal not block indices...
Definition: matrix.h:561
static Matrix< T, SX, 1 > identity()
Returns an identity matrix (or as close as you can get if not diagonal).
Definition: matrix.h:304
const SymMatrix< T, SX > & operator+=(const SymMatrix< T, SX > &m)
In-place matrix addition.
Definition: matrix.h:481
Vector3< T > toVector3(const VMatrix< T, SX > &m, unsigned start=0)
Converts a VMatrix to a Vector3, using three elements starting at index start.
Definition: matrix.h:969
const T & get(unsigned x) const
Retrieve constant value at row x. Bounds checking is done in a debug compile.
Definition: matrix.h:235
void set(const T &t=T())
Sets all matrix elements to t.
Definition: matrix.h:577
void addBlock(const Matrix< T, SX2, 1 > &m, unsigned iSrc, unsigned iDst)
Adds a block to this matrix from matrix m using the block size BX from block indice iSrc to indice iD...
Definition: matrix.h:281
DMatrix(const DMatrix< SX, SY > &m)
Copy constructor.
Definition: matrix.h:726
Matrix< T, SX, SY > operator-(const Matrix< T, SX, SY > &m) const
Binary subtraction operator.
Definition: matrix.h:150
static SymMatrix< T, SX > identity()
Returns an identity matrix (or as close as you can get if not diagonal).
Definition: matrix.h:582
T & get(unsigned x, unsigned y)
Retrieve value at row x column y. Bounds checking is done in a debug compile.
Definition: matrix.h:128
static Matrix< T, SX, SY > identity()
Returns an identity matrix (or as close as you can get if not diagonal).
Definition: matrix.h:210
const SymMatrix< T, SX > & operator=(const SymMatrix< T, SX > &m)
Equality operator.
Definition: matrix.h:465
DSymMatrix()
Default constructor, no data initialization.
Definition: matrix.h:741
T & get(unsigned x)
Retrieve value at row x. Bounds checking is done in a debug compile.
Definition: matrix.h:239
const T & y() const
The y-component of the vector.
Definition: vect.h:184
SymMatrix< T, SX > operator *(const T &t) const
Binary scalar multiplication operator for a symetric matrix.
Definition: matrix.h:499
const T & operator()(unsigned x, unsigned y) const
() operator access to const get(x,y)
Definition: matrix.h:241
const T & x() const
The x-component of the vector.
Definition: vect.h:182
const SymMatrix< T, SX > & operator/=(const T &t)
In-place division by a scalar.
Definition: matrix.h:487
const VMatrix< T, S > & operator=(const Matrix< T, S, 1 > &m)
Equality operator, works on Matrix is SY is 1.
Definition: matrix.h:700