Introduction
The c++ (cpp) typenamematrixtype example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: C++ (Cpp)
Class/type: typenameMatrixType
Example#1File:
low_rank.hppProject:
fanxiaochen/BloomingFlowers
void k_extract(const typename EigenType<T, D>::EigenvalueType& eigen_values,
const typename EigenType<T, D>::EigenvectorsType& eigen_vectors,
TMatrix& Q, TMatrix& S, int K)
{
size_t eigen_num = eigen_values.rows();
typename std::vector<typename EigenValue<T> > ev;
for (size_t i = 0; i < eigen_num; i ++)
{
typename std::complex<T> cv = eigen_values(i);
typename EigenValue<T> i_ev(cv.real(), i);
ev.push_back(i_ev);
}
std::sort(ev.begin(), ev.end(), EigenValue<T>());
int gm = eigen_vectors.rows();
Q.resize(gm, K);
TVector s(K);
for (size_t i = 0; i < K; i ++)
{
s(i) = ev[i]._value;
typename MatrixType<std::complex<T>, D>::Matrix q_ci = eigen_vectors.col(ev[i]._idx);
for (size_t j = 0, j_end = q_ci.rows(); j < j_end; j ++)
{
Q(j, i) = q_ci(j).real();
}
}
S = s.asDiagonal();
}
Example#2File:
fgt_wrapper.hppProject:
LegendGraphics/cpd
TMatrix fgt(const TMatrix& x, const TMatrix& y, const TMatrix& q, T h,
T epsilon = 1e-3,
int evalMethod = FIGTREE_EVAL_AUTO,
int ifgtParamMethod = FIGTREE_PARAM_NON_UNIFORM,
int ifgtTruncMethod = FIGTREE_TRUNC_CLUSTER,
int verbose = 0)
{
// very strange usage...
typename MatrixType<double, D>::MatrixD x_r = x.template cast<double>();
typename MatrixType<double, D>::MatrixD y_r = y.template cast<double>();
typename MatrixType<double, D>::Matrix q_r = q.template cast<double>().transpose();
int d = D;
int N = x_r.rows();
int M = y_r.rows();
int W = q_r.rows();
double *X, *Y, *Q;
X = x_r.data();
Y = y_r.data();
Q = q_r.data();
typename MatrixType<double, D>::Matrix G(W, M);
figtree(d, N, M, W, X, h, Q, Y, epsilon, G.data(), evalMethod, ifgtParamMethod, ifgtTruncMethod, verbose);
TMatrix g = G.template cast<T>().transpose();
return g;
}