KrisLibrary  1.0.0
DiagonalMatrix.h
1 #ifndef MATH_DIAGONAL_MATRIX_TEMPLATE_H
2 #define MATH_DIAGONAL_MATRIX_TEMPLATE_H
3 
4 #include "VectorTemplate.h"
5 #include "MatrixTemplate.h"
6 
7 namespace Math {
8 
13 template <class T>
15 {
16 public:
17  typedef class DiagonalMatrixTemplate<T> MyT;
18  typedef class VectorTemplate<T> BaseT;
19  typedef class VectorIterator<T> ItT;
20  typedef class MatrixTemplate<T> MatrixT;
21  typedef class VectorTemplate<T> VectorT;
22 
24  DiagonalMatrixTemplate(const BaseT&);
25  DiagonalMatrixTemplate(int m);
26  DiagonalMatrixTemplate(int m, T diagVal);
27  DiagonalMatrixTemplate(int m, const T* diagVals);
28 
29  inline int numCols() const { return this->n; }
30  inline int numRows() const { return this->n; }
31 
32  inline const MyT& operator = (const MyT& m) { BaseT::operator = (m); return *this; }
33 
34  inline void operator += (const MyT& m) { BaseT::operator +=(m); }
35  inline void operator -= (const MyT& m) { BaseT::operator -=(m); }
36  void operator *= (const MyT&);
37  inline void operator *= (T c) { BaseT::operator *=(c); }
38  inline void operator /= (T c) { BaseT::operator /=(c); }
39 
40  void copyDiagonal(const MatrixT& m);
41  void mulMatrix(const MyT& a, const MyT& b); //m=a*b
42  void mulVector(const VectorT&, VectorT&) const; //out=m*in
43  void mulInverse(const VectorT&, VectorT&) const; //out=m^-1*in
44  void mulPseudoInverse(const VectorT&, VectorT&) const;
45  void preMultiply(const MatrixT& a,MatrixT& x) const; //x=m*a
46  void postMultiply(const MatrixT& a,MatrixT& x) const; //x=a*m
47  void preMultiplyTranspose(const MatrixT& a,MatrixT& x) const; //x=m*at
48  void postMultiplyTranspose(const MatrixT& a,MatrixT& x) const; //x=at*m
49  void preMultiplyInverse(const MatrixT& a,MatrixT& x) const; //x=m^-1*a
50  void postMultiplyInverse(const MatrixT& a,MatrixT& x) const; //x=a*m^-1
51 
52  void setIdentity();
53  void setInverse(const MyT&);
54  void setPseudoInverse(const MyT&);
55 
56  void inplaceInverse();
57  void inplacePseudoInverse();
58 
59  bool isZero(T eps=Zero) const;
60  bool isIdentity(T eps=Zero) const;
61  bool isInvertible(T eps=Zero) const;
62  T determinant() const;
63  T trace() const;
64 };
65 
66  class Complex;
71 
72 }
73 
74 #endif
Complex number class (x + iy).
Definition: complex.h:17
An iterator through VectorTemplate elements.
Definition: VectorTemplate.h:19
A matrix over the field T.
Definition: function.h:10
Contains all definitions in the Math package.
Definition: WorkspaceBound.h:12
A vector over the field T.
Definition: function.h:9
A templated diagonal matrix, represented by a vector of the entries on the diagonal.
Definition: DiagonalMatrix.h:14