Fn_diagmat


Functions

template<typename eT , typename T1 >
const Op< T1, op_diagmatdiagmat (const Base< eT, T1 > &X)
 interpret a mat as a diagonal matrix (i.e. off-diagonal entries are zero)
template<typename eT >
const Op< Mat< eT >
, op_diagmat_vec
diagmat (const Col< eT > &X)
 interpret a colvec as a diagonal matrix
template<typename eT >
const Op< Mat< eT >
, op_diagmat_vec
diagmat (const Row< eT > &X)
 interpret a rowvec as a diagonal matrix
template<typename eT >
Mat< eT > diagmat (const subview_col< eT > &X)
 create a diagonal matrix out of subview_col
template<typename eT >
Mat< eT > diagmat (const subview_row< eT > &X)
 create a diagonal matrix out of subview_row
template<typename eT >
Mat< eT > diagmat (const diagview< eT > &X)
 create a diagonal matrix out of diagview
template<typename T1 >
const Op< T1, op_diagmat > & diagmat (const Op< T1, op_diagmat > &X)
 two consecutive diagmat operations are equivalent to one diagmat operation

Function Documentation

template<typename eT , typename T1 >
const Op<T1, op_diagmat> diagmat ( const Base< eT, T1 > &  X  )  [inline]

interpret a mat as a diagonal matrix (i.e. off-diagonal entries are zero)

Definition at line 24 of file fn_diagmat.hpp.

References Base< elem_type, derived >::get_ref().

00025   {
00026   arma_extra_debug_sigprint();
00027   
00028   return Op<T1, op_diagmat>(X.get_ref());
00029   }

template<typename eT >
const Op<Mat<eT>, op_diagmat_vec> diagmat ( const Col< eT > &  X  )  [inline]

interpret a colvec as a diagonal matrix

Definition at line 37 of file fn_diagmat.hpp.

00038   {
00039   arma_extra_debug_sigprint();
00040   
00041   return Op<Mat<eT>, op_diagmat_vec>(X);
00042   }

template<typename eT >
const Op<Mat<eT>, op_diagmat_vec> diagmat ( const Row< eT > &  X  )  [inline]

interpret a rowvec as a diagonal matrix

Definition at line 50 of file fn_diagmat.hpp.

00051   {
00052   arma_extra_debug_sigprint();
00053   
00054   return Op<Mat<eT>, op_diagmat_vec>(X);
00055   }

template<typename eT >
Mat<eT> diagmat ( const subview_col< eT > &  X  )  [inline]

create a diagonal matrix out of subview_col

Definition at line 63 of file fn_diagmat.hpp.

References Mat< eT >::at(), subview< eT >::n_elem, and Mat< eT >::zeros().

00064   {
00065   arma_extra_debug_sigprint();
00066   
00067   Mat<eT> out;
00068   out.zeros(X.n_elem, X.n_elem);
00069   
00070   for(u32 i=0; i<X.n_elem; ++i)
00071     {
00072     out.at(i,i) = X[i];
00073     }
00074   
00075   return out;
00076   }

template<typename eT >
Mat<eT> diagmat ( const subview_row< eT > &  X  )  [inline]

create a diagonal matrix out of subview_row

Definition at line 84 of file fn_diagmat.hpp.

References Mat< eT >::at(), subview< eT >::n_elem, and Mat< eT >::zeros().

00085   {
00086   arma_extra_debug_sigprint();
00087   
00088   Mat<eT> out;
00089   out.zeros(X.n_elem, X.n_elem);
00090   
00091   for(u32 i=0; i<X.n_elem; ++i)
00092     {
00093     out.at(i,i) = X[i];
00094     }
00095   
00096   return out;
00097   }

template<typename eT >
Mat<eT> diagmat ( const diagview< eT > &  X  )  [inline]

create a diagonal matrix out of diagview

Definition at line 105 of file fn_diagmat.hpp.

References Mat< eT >::at(), diagview< eT >::n_elem, and Mat< eT >::zeros().

00106   {
00107   arma_extra_debug_sigprint();
00108   
00109   Mat<eT> out;
00110   out.zeros(X.n_elem, X.n_elem);
00111   
00112   for(u32 i=0; i<X.n_elem; ++i)
00113     {
00114     out.at(i,i) = X[i];
00115     }
00116   
00117   return out;
00118   }

template<typename T1 >
const Op<T1, op_diagmat>& diagmat ( const Op< T1, op_diagmat > &  X  )  [inline]

two consecutive diagmat operations are equivalent to one diagmat operation

Definition at line 126 of file fn_diagmat.hpp.

00127   {
00128   arma_extra_debug_sigprint();
00129   arma_extra_debug_print("diagmat(): two consecutive diagmat() operations detected");
00130   
00131   return X;
00132   }