1 #ifndef _DMATRIXLINALG_H_ 2 #define _DMATRIXLINALG_H_ 12 #define DMLA_TAU 0.0000001f 19 Eigen::Map<const typename DMatrix<T>::EMT> mat(&*dmat.
getData().begin(), (int)dmat.
sizeY(), (int)dmat.
sizeX());
37 DMatrix<T> dmat(mat.cols(), mat.rows(), &mat(0));
50 bool m_Verbose =
false;
56 dmat = convert<T>(mat.inverse());
77 using namespace Eigen;
78 bool m_Verbose =
false;
88 JacobiSVD<typename DMatrix<T>::EMT> svd( mat, ComputeThinU | ComputeThinV);
94 DMatrix<T> U = dmutil::convert<T>(svd.matrixU());
95 DMatrix<T> V = dmutil::convert<T>(svd.matrixV());
96 VectorXf sig(svd.singularValues());
99 dword sxy = std::min(S.sizeX(),S.sizeY());
100 std::vector< std::pair<T,dword> > sdiag(sxy);
101 for(
dword i=0; i<sxy; i++) {
103 sdiag[i].first = sig(i);
106 mS = S; mU = U; mV = V;
108 sort(sdiag.begin(), sdiag.end(), std::greater< std::pair<float,T> >());
111 for(
dword i=0; i<sxy; i++) {
112 dword permi = sdiag[i].second;
118 mS.
at(i,i) = S.at(permi,permi);
138 for(
dword i=0; i<sxy; i++)
DMatrix< T > inverse(const DMatrix< T > &dmat)
DMatrix< T > pseudoInv(const DMatrix< T > &dmat)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > EMT
DMatrix< T > & invert(DMatrix< T > &dmat)
DMatrix< T >::EMT convert(const DMatrix< T > &dmat)
bool SVD(const DMatrix< T > &dmat, DMatrix< T > &mU, DMatrix< T > &mS, DMatrix< T > &mV)
MT & resize(dword _sx, dword _sy, const T &inival=T())
MT & setCol(dword col, MT &vec)
MT & getRange(dword ox, dword oy, MT &mat) const
std::vector< T > & getData()
MT mulRight(const MT &rhs) const