Changeset 427

Show
Ignore:
Timestamp:
07/24/09 08:53:22 (15 years ago)
Author:
vbarta
Message:

deriving ldmat publically (like all other children of square_mat); more tests

Location:
library
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/math/square_mat.h

    r384 r427  
    3131mat ltuinv( const mat &L ); 
    3232 
    33 /*! \brief Virtual class for representation of double symmetric matrices in square-root form. 
     33/*! \brief Abstract class for representation of double symmetric matrices in square-root form. 
    3434 
    3535All operations defined on this class should be optimized for the chosen decomposition. 
     
    9797                int cols() const {return dim;}; 
    9898 
    99                 //! Reimplementing common functions of mat: cols(). 
     99                //! Reimplementing common functions of mat: rows(). 
    100100                int rows() const {return dim;}; 
    101101 
     
    187187All inplace operations modifies only these and the need to compose and decompose the matrix is avoided. 
    188188*/ 
    189 class ldmat: sqmat 
     189class ldmat: public sqmat 
    190190{ 
    191191        public: 
     
    218218                double invqform (const vec &v ) const; 
    219219                void clear(); 
    220                 int cols() const; 
    221                 int rows() const; 
    222220                vec sqrt_mult ( const vec &v ) const; 
    223221 
     
    284282//!mapping of negative add operation to operators 
    285283inline ldmat& ldmat::operator -= ( const ldmat &ldA )  {this->add ( ldA,-1.0 );return *this;} 
    286 //!access function 
    287 inline int ldmat::cols() const {return dim;} 
    288 //!access function 
    289 inline int ldmat::rows() const {return dim;} 
    290284 
    291285/*! @} */ 
  • library/tests/square_mat_test.cpp

    r426 r427  
    3232 
    3333    TMatrix sqmat(A); 
     34    CHECK_EQUAL(sz, sqmat.rows()); 
     35    CHECK_EQUAL(sz, sqmat.cols()); 
     36 
    3437    mat res = sqmat.to_mat(); 
    3538    CHECK_CLOSE(A, res, epsilon); 
     
    4548    double d = det(A); 
    4649    CHECK_CLOSE(log(d), sqmat.logdet(), epsilon); 
     50 
     51    double q = sqmat.qform(ones(sz)); 
     52    CHECK_CLOSE(sumsum(A), q, epsilon); 
     53 
     54    q = sqmat.qform(v); 
     55    double r = (A * v) * v; 
     56    CHECK_CLOSE(r, q, epsilon); 
     57 
     58    sqmat2 = sqmat; 
     59    sqmat2.clear(); 
     60    CHECK_EQUAL(0, sqmat2.qform(ones(sz))); 
    4761} 
    4862