Classes | |
class | op_inv |
'invert matrix' operation More... | |
Functions | |
template<typename eT > | |
static void | op_inv::apply (Mat< eT > &out, const Mat< eT > &A) |
immediate inverse of a matrix, storing the result in a dense matrix | |
template<typename T1 > | |
static void | op_inv::apply (Mat< typename T1::elem_type > &out, const Op< T1, op_inv > &in) |
immediate inverse of T1, storing the result in a dense matrix | |
template<typename T1 > | |
static void | op_inv::apply (Mat< typename T1::elem_type > &out, const Op< Op< T1, op_diagmat >, op_inv > &in) |
inverse of diagmat(mat) | |
template<typename eT > | |
static void | op_inv::apply_diagvec (Mat< eT > &out, const Mat< eT > &X) |
template<typename eT > | |
static void | op_inv::apply (Mat< eT > &out, const Op< Op< Mat< eT >, op_diagmat_vec >, op_inv > &in) |
inverse of diagmat(colvec or rowvec) |
void op_inv::apply | ( | Mat< eT > & | out, | |
const Mat< eT > & | A | |||
) | [inline, static, inherited] |
immediate inverse of a matrix, storing the result in a dense matrix
Definition at line 24 of file op_inv_meat.hpp.
References auxlib::inv_inplace(), auxlib::inv_noalias(), and Mat< eT >::is_square().
Referenced by apply(), and operator*().
00025 { 00026 arma_extra_debug_sigprint(); 00027 00028 // no need to check for aliasing, due to: 00029 // - auxlib::inv() copies A to out before inversion 00030 // - for 2x2 and 3x3 matrices the code is alias safe 00031 00032 arma_debug_check( !A.is_square(), "op_inv::apply(): matrix must be square" ); 00033 00034 if(&out != &A) 00035 { 00036 auxlib::inv_noalias(out, A); 00037 } 00038 else 00039 { 00040 auxlib::inv_inplace(out); 00041 } 00042 00043 }
void op_inv::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< T1, op_inv > & | in | |||
) | [inline, static, inherited] |
immediate inverse of T1, storing the result in a dense matrix
Definition at line 51 of file op_inv_meat.hpp.
References apply(), and Op< T1, op_type >::m.
00052 { 00053 arma_extra_debug_sigprint(); 00054 00055 const unwrap<T1> tmp(in.m); 00056 00057 typedef typename T1::elem_type eT; 00058 const Mat<eT>& X = tmp.M; 00059 00060 op_inv::apply(out, X); 00061 }
void op_inv::apply | ( | Mat< typename T1::elem_type > & | out, | |
const Op< Op< T1, op_diagmat >, op_inv > & | in | |||
) | [inline, static, inherited] |
inverse of diagmat(mat)
Definition at line 69 of file op_inv_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), podarray< T1 >::mem, Mat< eT >::n_rows, and Mat< eT >::zeros().
00070 { 00071 arma_extra_debug_sigprint(); 00072 00073 const unwrap<T1> X_tmp(in.m.m); 00074 00075 typedef typename T1::elem_type eT; 00076 const Mat<eT>& X = X_tmp.M; 00077 00078 arma_debug_check( !X.is_square(), "op_inv::apply(): matrix must be square" ); 00079 00080 if(&out != &X) 00081 { 00082 out.zeros(X.n_rows, X.n_rows); 00083 00084 for(u32 i=0; i<X.n_rows; ++i) 00085 { 00086 out.at(i,i) = 1.0 / X.at(i,i); 00087 } 00088 } 00089 else 00090 { 00091 podarray<eT> tmp(X.n_rows); 00092 00093 for(u32 i=0; i<X.n_rows; ++i) 00094 { 00095 tmp[i] = X.at(i,i); 00096 } 00097 00098 out.zeros(X.n_rows, X.n_rows); 00099 00100 for(u32 i=0; i<X.n_rows; ++i) 00101 { 00102 out.at(i,i) = eT(1) / tmp.mem[i]; 00103 } 00104 00105 } 00106 00107 }
void op_inv::apply_diagvec | ( | Mat< eT > & | out, | |
const Mat< eT > & | X | |||
) | [inline, static, inherited] |
Definition at line 114 of file op_inv_meat.hpp.
References Mat< eT >::at(), Mat< eT >::is_vec(), podarray< T1 >::mem, Mat< eT >::mem, Mat< eT >::n_elem, and Mat< eT >::zeros().
Referenced by apply().
00115 { 00116 arma_extra_debug_sigprint(); 00117 00118 arma_debug_check( !X.is_vec(), "op_inv::apply_diagvec(): internal error: can't interpret as a vector"); 00119 00120 if(&out != &X) 00121 { 00122 out.zeros(X.n_elem, X.n_elem); 00123 00124 for(u32 i=0; i<X.n_elem; ++i) 00125 { 00126 out.at(i,i) = eT(1) / X.mem[i]; 00127 } 00128 } 00129 else 00130 { 00131 podarray<eT> tmp(X.n_elem); 00132 00133 for(u32 i=0; i<X.n_elem; ++i) 00134 { 00135 tmp[i] = X.mem[i]; 00136 } 00137 00138 out.zeros(X.n_elem, X.n_elem); 00139 00140 for(u32 i=0; i<X.n_elem; ++i) 00141 { 00142 out.at(i,i) = eT(1) / tmp.mem[i]; 00143 } 00144 00145 } 00146 00147 }
void op_inv::apply | ( | Mat< eT > & | out, | |
const Op< Op< Mat< eT >, op_diagmat_vec >, op_inv > & | in | |||
) | [inline, static, inherited] |
inverse of diagmat(colvec or rowvec)
Definition at line 155 of file op_inv_meat.hpp.
References apply_diagvec().
00156 { 00157 arma_extra_debug_sigprint(); 00158 00159 const Mat<eT>& X = in.m.m; 00160 op_inv::apply_diagvec(out, X); 00161 }