$search
00001 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) 00002 // Copyright (C) 2008-2011 Conrad Sanderson 00003 // Copyright (C) 2009 Edmund Highcock 00004 // Copyright (C) 2011 James Sanders 00005 // 00006 // This file is part of the Armadillo C++ library. 00007 // It is provided without any warranty of fitness 00008 // for any purpose. You can redistribute this file 00009 // and/or modify it under the terms of the GNU 00010 // Lesser General Public License (LGPL) as published 00011 // by the Free Software Foundation, either version 3 00012 // of the License or (at your option) any later version. 00013 // (see http://www.opensource.org/licenses for more info) 00014 00015 00018 00019 00021 class auxlib 00022 { 00023 public: 00024 00025 00026 template<const uword row, const uword col> 00027 struct pos 00028 { 00029 static const uword n2 = row + col*2; 00030 static const uword n3 = row + col*3; 00031 static const uword n4 = row + col*4; 00032 }; 00033 00034 00035 // 00036 // inv 00037 00038 template<typename eT, typename T1> 00039 inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slow = false); 00040 00041 template<typename eT> 00042 inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false); 00043 00044 template<typename eT> 00045 inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const uword N); 00046 00047 template<typename eT> 00048 inline static bool inv_inplace_tinymat(Mat<eT>& out, const uword N); 00049 00050 template<typename eT> 00051 inline static bool inv_inplace_lapack(Mat<eT>& out); 00052 00053 00054 // 00055 // inv_tr 00056 00057 template<typename eT, typename T1> 00058 inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout); 00059 00060 00061 // 00062 // inv_sym 00063 00064 template<typename eT, typename T1> 00065 inline static bool inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const uword layout); 00066 00067 00068 // 00069 // inv_sympd 00070 00071 template<typename eT, typename T1> 00072 inline static bool inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uword layout); 00073 00074 00075 // 00076 // det 00077 00078 template<typename eT, typename T1> 00079 inline static eT det(const Base<eT,T1>& X, const bool slow = false); 00080 00081 template<typename eT> 00082 inline static eT det_tinymat(const Mat<eT>& X, const uword N); 00083 00084 template<typename eT> 00085 inline static eT det_lapack(const Mat<eT>& X, const bool make_copy); 00086 00087 00088 // 00089 // log_det 00090 00091 template<typename eT, typename T1> 00092 inline static bool log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, const Base<eT,T1>& X); 00093 00094 00095 // 00096 // lu 00097 00098 template<typename eT, typename T1> 00099 inline static bool lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT,T1>& X); 00100 00101 template<typename eT, typename T1> 00102 inline static bool lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X); 00103 00104 template<typename eT, typename T1> 00105 inline static bool lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X); 00106 00107 00108 // 00109 // eig 00110 00111 template<typename eT, typename T1> 00112 inline static bool eig_sym(Col<eT>& eigval, const Base<eT,T1>& X); 00113 00114 template<typename T, typename T1> 00115 inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X); 00116 00117 template<typename eT, typename T1> 00118 inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X); 00119 00120 template<typename T, typename T1> 00121 inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base<std::complex<T>,T1>& X); 00122 00123 template<typename T, typename T1> 00124 inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat<T>& l_eigvec, Mat<T>& r_eigvec, const Base<T,T1>& X, const char side); 00125 00126 template<typename T, typename T1> 00127 inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat< std::complex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::complex<T>, T1 >& X, const char side); 00128 00129 00130 // 00131 // chol 00132 00133 template<typename eT, typename T1> 00134 inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X); 00135 00136 00137 // 00138 // qr 00139 00140 template<typename eT, typename T1> 00141 inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X); 00142 00143 00144 // 00145 // svd 00146 00147 template<typename eT, typename T1> 00148 inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows, uword& n_cols); 00149 00150 template<typename T, typename T1> 00151 inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uword& n_rows, uword& n_cols); 00152 00153 template<typename eT, typename T1> 00154 inline static bool svd(Col<eT>& S, const Base<eT,T1>& X); 00155 00156 template<typename T, typename T1> 00157 inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X); 00158 00159 template<typename eT, typename T1> 00160 inline static bool svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X); 00161 00162 template<typename T, typename T1> 00163 inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X); 00164 00165 template<typename eT, typename T1> 00166 inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode); 00167 00168 template<typename T, typename T1> 00169 inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode); 00170 00171 00172 // 00173 // solve 00174 00175 template<typename eT> 00176 inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow = false); 00177 00178 template<typename eT> 00179 inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); 00180 00181 template<typename eT> 00182 inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B); 00183 00184 00185 // 00186 // solve_tr 00187 00188 template<typename eT> 00189 inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const uword layout); 00190 00191 00192 // 00193 // Schur decomposition 00194 00195 template<typename eT> 00196 inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A); 00197 00198 template<typename cT> 00199 inline static bool schur_dec(Mat<std::complex<cT> >& Z, Mat<std::complex<cT> >& T, const Mat<std::complex<cT> >& A); 00200 00201 00202 // 00203 // syl (solution of the Sylvester equation AX + XB = C) 00204 00205 template<typename eT> 00206 inline static bool syl(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& B, const Mat<eT>& C); 00207 00208 00209 // 00210 // lyap (solution of the continuous Lyapunov equation AX + XA^H + Q = 0) 00211 00212 template<typename eT> 00213 inline static bool lyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q); 00214 00215 00216 // 00217 // dlyap (solution of the discrete Lyapunov equation AXA^H - X + Q = 0) 00218 00219 template<typename eT> 00220 inline static bool dlyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q); 00221 }; 00222 00223