//! More...
Classes | |
| class | op_pinv |
Functions | |
| template<typename eT > | |
| static void | op_pinv::direct_pinv (Mat< eT > &out, const Mat< eT > &X, eT tol) |
| template<typename T > | |
| void | op_pinv::direct_pinv (Mat< std::complex< T > > &out, const Mat< std::complex< T > > &A, T tol) |
| template<typename T1 > | |
| static void | op_pinv::apply (Mat< typename T1::pod_type > &out, const Op< T1, op_pinv > &in) |
| template<typename T1 > | |
| static void | op_pinv::apply (Mat< std::complex< typename T1::pod_type > > &out, const Op< T1, op_pinv > &in) |
//!
| void op_pinv::direct_pinv | ( | Mat< eT > & | out, | |
| const Mat< eT > & | X, | |||
| eT | tol | |||
| ) | [inline, static, inherited] |
Definition at line 27 of file op_pinv_meat.hpp.
References Mat< eT >::cols(), diagmat(), eop_aux::direct_eps(), max(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, Col< eT >::rows(), Mat< eT >::set_size(), svd(), trans(), and Mat< eT >::zeros().
Referenced by apply().
{
arma_extra_debug_sigprint();
const u32 n_rows = A.n_rows;
const u32 n_cols = A.n_cols;
// SVD decomposition
Mat<eT> U;
Col<eT> s;
Mat<eT> V;
const bool status = (n_cols > n_rows) ? svd(U,s,V,trans(A)) : svd(U,s,V,A);
if(status == false)
{
out.set_size(0,0);
return;
}
// set tolerance to default if it hasn't been specified as an argument
if(tol == eT(0))
{
tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s));
}
// count non zero valued elements in s
u32 count = 0;
for(u32 i = 0; i < s.n_elem; ++i)
{
if(s[i] > tol)
{
++count;
}
}
if(count != 0)
{
// reduce the length of s in order to contain only the values above tolerance
s = s.rows(0,count-1);
// set the elements of s equal to their reciprocals
s = eT(1) / s;
if(A.n_cols <= A.n_rows)
{
out = V.cols(0,count-1) * diagmat(s) * trans(U.cols(0,count-1));
}
else
{
out = U.cols(0,count-1) * diagmat(s) * trans(V.cols(0,count-1));
}
}
else
{
out.zeros(n_cols, n_rows);
}
}
| void op_pinv::direct_pinv | ( | Mat< std::complex< T > > & | out, | |
| const Mat< std::complex< T > > & | A, | |||
| T | tol | |||
| ) | [inline, inherited] |
Definition at line 92 of file op_pinv_meat.hpp.
References Mat< eT >::cols(), diagmat(), eop_aux::direct_eps(), htrans(), max(), Mat< eT >::n_elem, Col< eT >::rows(), and svd().
{
arma_extra_debug_sigprint();
const u32 n_rows = A.n_rows;
const u32 n_cols = A.n_cols;
typedef typename std::complex<T> eT;
// SVD decomposition
Mat<eT> U;
Col< T> s;
Mat<eT> V;
const bool status = (n_cols > n_rows) ? svd(U,s,V,htrans(A)) : svd(U,s,V,A);
if(status == false)
{
out.set_size(0,0);
return;
}
// set tolerance to default if it hasn't been specified as an argument
if(tol == T(0))
{
tol = (std::max)(n_rows,n_cols) * eop_aux::direct_eps(max(s));
}
// count non zero valued elements in s
u32 count = 0;
for(u32 i = 0; i < s.n_elem; ++i)
{
if(s[i] > tol)
{
++count;
}
}
if(count != 0)
{
// reduce the length of s in order to contain only the values above tolerance
s = s.rows(0,count-1);
// set the elements of s equal to their reciprocals
s = T(1) / s;
if(n_rows >= n_cols)
{
out = V.cols(0,count-1) * diagmat(s) * htrans(U.cols(0,count-1));
}
else
{
out = U.cols(0,count-1) * diagmat(s) * htrans(V.cols(0,count-1));
}
}
else
{
out.zeros(n_cols, n_rows);
}
}
| void op_pinv::apply | ( | Mat< typename T1::pod_type > & | out, | |
| const Op< T1, op_pinv > & | in | |||
| ) | [inline, static, inherited] |
Definition at line 159 of file op_pinv_meat.hpp.
References Op< T1, op_type >::aux, direct_pinv(), unwrap_check< T1 >::M, and Op< T1, op_type >::m.
{
arma_extra_debug_sigprint();
typedef typename T1::pod_type eT;
const eT tol = in.aux;
arma_debug_check((tol < eT(0)), "pinv(): tol must be >= 0");
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
op_pinv::direct_pinv(out, A, tol);
}
| void op_pinv::apply | ( | Mat< std::complex< typename T1::pod_type > > & | out, | |
| const Op< T1, op_pinv > & | in | |||
| ) | [inline, static, inherited] |
Definition at line 180 of file op_pinv_meat.hpp.
References Op< T1, op_type >::aux, direct_pinv(), unwrap_check< T1 >::M, and Op< T1, op_type >::m.
{
arma_extra_debug_sigprint();
typedef typename T1::pod_type T;
typedef typename std::complex<typename T1::pod_type> eT;
const T tol = in.aux.real();
arma_debug_check((tol < T(0)), "pinv(): tol must be >= 0");
const unwrap_check<T1> tmp(in.m, out);
const Mat<eT>& A = tmp.M;
op_pinv::direct_pinv(out, A, tol);
}