Changeset 33 for bdm/math

Show
Ignore:
Timestamp:
03/05/08 16:01:56 (16 years ago)
Author:
smidl
Message:

Oprava PF a MPF + jejich implementace pro pmsm system

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/math/libDC.h

    r32 r33  
    8686                sqmat(const int dim0): dim(dim0){}; 
    8787        protected: 
     88                //! dimension of the square matrix 
    8889                int dim; 
    8990}; 
     
    9798{ 
    9899        protected: 
     100                //! Full matrix on which the operations are performed 
    99101                mat M; 
    100102        public: 
     
    103105                void mult_sym ( const mat &C); 
    104106                void mult_sym_t ( const mat &C); 
     107                //! store result of \c mult_sym in external matrix $U$ 
    105108                void mult_sym ( const mat &C, fsqmat &U) const; 
     109                //! store result of \c mult_sym_t in external matrix $U$ 
    106110                void mult_sym_t ( const mat &C, fsqmat &U) const; 
    107111                void clear(); 
     
    129133                vec sqrt_mult (const vec &v ) const {it_error ( "not implemented" );return v;}; 
    130134 
     135                //! add another fsqmat matrix 
    131136                fsqmat& operator += ( const fsqmat &A ) {M+=A.M;return *this;}; 
     137                //! subtrack another fsqmat matrix 
    132138                fsqmat& operator -= ( const fsqmat &A ) {M-=A.M;return *this;}; 
     139                //! multiply by a scalar 
    133140                fsqmat& operator *= ( double x ) {M*=x;return *this;}; 
    134141//              fsqmat& operator = ( const fsqmat &A) {M=A.M; return *this;}; 
    135  
     142                //! print full matrix 
    136143                friend std::ostream &operator<< ( std::ostream &os, const fsqmat &sq ); 
    137144 
    138145}; 
    139146 
     147/*! \brief Matrix stored in LD form, (typically known as UD)  
     148 
     149Matrix is decomposed as follows: \f[M = L'DL\f] where only $L$ and $D$ matrices are stored. 
     150All inplace operations modifies only these and the need to compose and decompose the matrix is avoided. 
     151*/ 
    140152class ldmat: sqmat 
    141153{ 
     
    162174                void mult_sym ( const mat &C); 
    163175                void mult_sym_t ( const mat &C); 
     176                //! Add another matrix in LD form with weight w 
    164177                void add ( const ldmat &ld2, double w=1.0 ); 
    165178                double logdet() const; 
     
    172185 
    173186                /*! \brief Matrix inversion preserving the chosen form. 
    174  
    175187                @param Inv a space where the inverse is stored. 
    176  
    177188                */ 
    178189                virtual void inv ( ldmat &Inv ) const; 
    179190 
    180191                /*! \brief Symmetric multiplication of $U$ by a general matrix $C$, result of which is stored in the current class. 
    181  
     192                @param C matrix to multiply with 
    182193                @param U a space where the inverse is stored. 
    183  
    184194                */ 
    185195                void mult_sym ( const mat &C, ldmat &U) const; 
    186196 
    187197                /*! \brief Symmetric multiplication of $U$ by a transpose of a general matrix $C$, result of which is stored in the current class. 
    188  
     198                @param C matrix to multiply with 
    189199                @param U a space where the inverse is stored. 
    190  
    191200                */ 
    192201                void mult_sym_t ( const mat &C, ldmat &U) const; 
     
    196205 
    197206                The new decomposition fullfills: $A'*diag(D)*A = self.L'*diag(self.D)*self.L$ 
    198  
    199207                @param A general matrix 
    200208                @param D0 general vector 
    201  
    202209                */ 
    203210                void ldform (const mat &A,const vec &D0 ); 
     
    205212                //! Access functions 
    206213                void setD (const vec &nD){D=nD;} 
     214                //! Access functions 
     215                void setD (const vec &nD, int i){D.replace_mid(i,nD);} //Fixme can be more general 
     216                //! Access functions 
    207217                void setL (const vec &nL){L=nL;} 
    208218 
     219                //! add another ldmat matrix 
    209220                ldmat& operator += ( const ldmat &ldA ); 
     221                //! subtract another ldmat matrix 
    210222                ldmat& operator -= ( const ldmat &ldA ); 
     223                //! multiply by a scalar 
    211224                ldmat& operator *= ( double x ); 
    212225 
     226                //! print both \c L and \c D 
    213227                friend std::ostream &operator<< ( std::ostream &os, const ldmat &sq ); 
    214228 
    215229 
    216230        protected: 
     231                //! Positive vector $D$ 
    217232                vec D; 
     233                //! Lower-triangular matrix $L$ 
    218234                mat L; 
    219235 
     
    221237 
    222238//////// Operations: 
    223  
     239//!mapping of add operation to operators 
    224240inline ldmat& ldmat::operator += ( const ldmat &ldA )  {this->add ( ldA );return *this;} 
     241//!mapping of negative add operation to operators 
    225242inline ldmat& ldmat::operator -= ( const ldmat &ldA )  {this->add ( ldA,-1.0 );return *this;} 
     243//!access function 
    226244inline int ldmat::cols() const {return dim;} 
     245//!access function 
    227246inline int ldmat::rows() const {return dim;} 
    228247