chmat.h itpp/itbase.h libDC.h ../itpp_ext.h work/git/mixpp/bdm/estim/libKF.h work/git/mixpp/bdm/math/chmat.cpp work/git/mixpp/pmsm/sim_var.cpp work/git/mixpp/tests/chmat_test.cpp work/git/mixpp/tests/rv_test.cpp work/git/mixpp/tests/test0.cpp chmat Matrices in decomposed forms (LDL', LU, UDU', etc). Vaclav Smidl. ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under UncertaintyUsing IT++ for numerical operations ----------------------------------- #ifndefCHMAT_H #defineCHMAT_H #include<itpp/itbase.h> #include"libDC.h" #include"../itpp_ext.h" usingnamespaceitpp; classchmat:publicsqmat{ protected: matCh; public: voidopupdt(constvec&v,doublew); matto_mat(); voidmult_sym(constmat&C); voidmult_sym(constmat&C,chmat&U)const; voidmult_sym_t(constmat&C); voidmult_sym_t(constmat&C,chmat&U)const; doublelogdet()const; vecsqrt_mult(constvec&v)const; doubleqform(constvec&v)const; doubleinvqform(constvec&v)const; voidclear(); voidadd(constchmat&A2,doublew=1.0){}; voidinv(chmat&Inv)const{(Inv.Ch)=itpp::inv(Ch).T();};//Fixme:canbemoreefficient ; //voidinv(mat&Inv); virtual~chmat(){}; chmat(constintdim0):sqmat(dim0),Ch(dim0,dim0){}; chmat(constvec&v):sqmat(v.length()),Ch(diag(sqrt(v))){}; chmat(constchmat&Ch0):sqmat(Ch0.dim),Ch(Ch0.dim,Ch0.dim){Ch=Ch0.Ch;}; chmat(constmat&M):sqmat(M.rows()),Ch(M.rows(),M.cols()){ matQ; it_assert_debug(M.rows()==M.cols(),"chmat::inputmatrixmustbesquare!"); Ch=chol(M); }; mat&_Ch(){returnCh;} voidsetD(constvec&nD){Ch=diag(sqrt(nD));} voidsetD(constvec&nD,inti){for(intj=i;j<nD.length();j++){Ch(j,j)=sqrt(nD(j-i));}}//Fixmecanbemoregeneral chmat&operator += (constchmat&A2); chmat&operator -= (constchmat&A2); }; inlinechmat&chmat::operator += (constchmat&A2){this->add(A2);return*this;} inlinechmat&chmat::operator -= (constchmat&A2){this->add(A2,-1.0);return*this;} #endif//CHMAT_H