max@0
|
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
|
max@0
|
2 // Copyright (C) 2008-2011 Conrad Sanderson
|
max@0
|
3 // Copyright (C) 2009 Edmund Highcock
|
max@0
|
4 // Copyright (C) 2011 James Sanders
|
max@0
|
5 //
|
max@0
|
6 // This file is part of the Armadillo C++ library.
|
max@0
|
7 // It is provided without any warranty of fitness
|
max@0
|
8 // for any purpose. You can redistribute this file
|
max@0
|
9 // and/or modify it under the terms of the GNU
|
max@0
|
10 // Lesser General Public License (LGPL) as published
|
max@0
|
11 // by the Free Software Foundation, either version 3
|
max@0
|
12 // of the License or (at your option) any later version.
|
max@0
|
13 // (see http://www.opensource.org/licenses for more info)
|
max@0
|
14
|
max@0
|
15
|
max@0
|
16 //! \addtogroup auxlib
|
max@0
|
17 //! @{
|
max@0
|
18
|
max@0
|
19
|
max@0
|
20 //! wrapper for accessing external functions defined in ATLAS, LAPACK or BLAS libraries
|
max@0
|
21 class auxlib
|
max@0
|
22 {
|
max@0
|
23 public:
|
max@0
|
24
|
max@0
|
25
|
max@0
|
26 template<const uword row, const uword col>
|
max@0
|
27 struct pos
|
max@0
|
28 {
|
max@0
|
29 static const uword n2 = row + col*2;
|
max@0
|
30 static const uword n3 = row + col*3;
|
max@0
|
31 static const uword n4 = row + col*4;
|
max@0
|
32 };
|
max@0
|
33
|
max@0
|
34
|
max@0
|
35 //
|
max@0
|
36 // inv
|
max@0
|
37
|
max@0
|
38 template<typename eT, typename T1>
|
max@0
|
39 inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slow = false);
|
max@0
|
40
|
max@0
|
41 template<typename eT>
|
max@0
|
42 inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false);
|
max@0
|
43
|
max@0
|
44 template<typename eT>
|
max@0
|
45 inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const uword N);
|
max@0
|
46
|
max@0
|
47 template<typename eT>
|
max@0
|
48 inline static bool inv_inplace_tinymat(Mat<eT>& out, const uword N);
|
max@0
|
49
|
max@0
|
50 template<typename eT>
|
max@0
|
51 inline static bool inv_inplace_lapack(Mat<eT>& out);
|
max@0
|
52
|
max@0
|
53
|
max@0
|
54 //
|
max@0
|
55 // inv_tr
|
max@0
|
56
|
max@0
|
57 template<typename eT, typename T1>
|
max@0
|
58 inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout);
|
max@0
|
59
|
max@0
|
60
|
max@0
|
61 //
|
max@0
|
62 // inv_sym
|
max@0
|
63
|
max@0
|
64 template<typename eT, typename T1>
|
max@0
|
65 inline static bool inv_sym(Mat<eT>& out, const Base<eT,T1>& X, const uword layout);
|
max@0
|
66
|
max@0
|
67
|
max@0
|
68 //
|
max@0
|
69 // inv_sympd
|
max@0
|
70
|
max@0
|
71 template<typename eT, typename T1>
|
max@0
|
72 inline static bool inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uword layout);
|
max@0
|
73
|
max@0
|
74
|
max@0
|
75 //
|
max@0
|
76 // det
|
max@0
|
77
|
max@0
|
78 template<typename eT, typename T1>
|
max@0
|
79 inline static eT det(const Base<eT,T1>& X, const bool slow = false);
|
max@0
|
80
|
max@0
|
81 template<typename eT>
|
max@0
|
82 inline static eT det_tinymat(const Mat<eT>& X, const uword N);
|
max@0
|
83
|
max@0
|
84 template<typename eT>
|
max@0
|
85 inline static eT det_lapack(const Mat<eT>& X, const bool make_copy);
|
max@0
|
86
|
max@0
|
87
|
max@0
|
88 //
|
max@0
|
89 // log_det
|
max@0
|
90
|
max@0
|
91 template<typename eT, typename T1>
|
max@0
|
92 inline static bool log_det(eT& out_val, typename get_pod_type<eT>::result& out_sign, const Base<eT,T1>& X);
|
max@0
|
93
|
max@0
|
94
|
max@0
|
95 //
|
max@0
|
96 // lu
|
max@0
|
97
|
max@0
|
98 template<typename eT, typename T1>
|
max@0
|
99 inline static bool lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, const Base<eT,T1>& X);
|
max@0
|
100
|
max@0
|
101 template<typename eT, typename T1>
|
max@0
|
102 inline static bool lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T1>& X);
|
max@0
|
103
|
max@0
|
104 template<typename eT, typename T1>
|
max@0
|
105 inline static bool lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X);
|
max@0
|
106
|
max@0
|
107
|
max@0
|
108 //
|
max@0
|
109 // eig
|
max@0
|
110
|
max@0
|
111 template<typename eT, typename T1>
|
max@0
|
112 inline static bool eig_sym(Col<eT>& eigval, const Base<eT,T1>& X);
|
max@0
|
113
|
max@0
|
114 template<typename T, typename T1>
|
max@0
|
115 inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1>& X);
|
max@0
|
116
|
max@0
|
117 template<typename eT, typename T1>
|
max@0
|
118 inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<eT,T1>& X);
|
max@0
|
119
|
max@0
|
120 template<typename T, typename T1>
|
max@0
|
121 inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec, const Base<std::complex<T>,T1>& X);
|
max@0
|
122
|
max@0
|
123 template<typename T, typename T1>
|
max@0
|
124 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);
|
max@0
|
125
|
max@0
|
126 template<typename T, typename T1>
|
max@0
|
127 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);
|
max@0
|
128
|
max@0
|
129
|
max@0
|
130 //
|
max@0
|
131 // chol
|
max@0
|
132
|
max@0
|
133 template<typename eT, typename T1>
|
max@0
|
134 inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X);
|
max@0
|
135
|
max@0
|
136
|
max@0
|
137 //
|
max@0
|
138 // qr
|
max@0
|
139
|
max@0
|
140 template<typename eT, typename T1>
|
max@0
|
141 inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X);
|
max@0
|
142
|
max@0
|
143
|
max@0
|
144 //
|
max@0
|
145 // svd
|
max@0
|
146
|
max@0
|
147 template<typename eT, typename T1>
|
max@0
|
148 inline static bool svd(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows, uword& n_cols);
|
max@0
|
149
|
max@0
|
150 template<typename T, typename T1>
|
max@0
|
151 inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X, uword& n_rows, uword& n_cols);
|
max@0
|
152
|
max@0
|
153 template<typename eT, typename T1>
|
max@0
|
154 inline static bool svd(Col<eT>& S, const Base<eT,T1>& X);
|
max@0
|
155
|
max@0
|
156 template<typename T, typename T1>
|
max@0
|
157 inline static bool svd(Col<T>& S, const Base<std::complex<T>, T1>& X);
|
max@0
|
158
|
max@0
|
159 template<typename eT, typename T1>
|
max@0
|
160 inline static bool svd(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X);
|
max@0
|
161
|
max@0
|
162 template<typename T, typename T1>
|
max@0
|
163 inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::complex<T> >& V, const Base< std::complex<T>, T1>& X);
|
max@0
|
164
|
max@0
|
165 template<typename eT, typename T1>
|
max@0
|
166 inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X, const char mode);
|
max@0
|
167
|
max@0
|
168 template<typename T, typename T1>
|
max@0
|
169 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);
|
max@0
|
170
|
max@0
|
171
|
max@0
|
172 //
|
max@0
|
173 // solve
|
max@0
|
174
|
max@0
|
175 template<typename eT>
|
max@0
|
176 inline static bool solve (Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B, const bool slow = false);
|
max@0
|
177
|
max@0
|
178 template<typename eT>
|
max@0
|
179 inline static bool solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
|
max@0
|
180
|
max@0
|
181 template<typename eT>
|
max@0
|
182 inline static bool solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B);
|
max@0
|
183
|
max@0
|
184
|
max@0
|
185 //
|
max@0
|
186 // solve_tr
|
max@0
|
187
|
max@0
|
188 template<typename eT>
|
max@0
|
189 inline static bool solve_tr(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const uword layout);
|
max@0
|
190
|
max@0
|
191
|
max@0
|
192 //
|
max@0
|
193 // Schur decomposition
|
max@0
|
194
|
max@0
|
195 template<typename eT>
|
max@0
|
196 inline static bool schur_dec(Mat<eT>& Z, Mat<eT>& T, const Mat<eT>& A);
|
max@0
|
197
|
max@0
|
198 template<typename cT>
|
max@0
|
199 inline static bool schur_dec(Mat<std::complex<cT> >& Z, Mat<std::complex<cT> >& T, const Mat<std::complex<cT> >& A);
|
max@0
|
200
|
max@0
|
201
|
max@0
|
202 //
|
max@0
|
203 // syl (solution of the Sylvester equation AX + XB = C)
|
max@0
|
204
|
max@0
|
205 template<typename eT>
|
max@0
|
206 inline static bool syl(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& B, const Mat<eT>& C);
|
max@0
|
207
|
max@0
|
208
|
max@0
|
209 //
|
max@0
|
210 // lyap (solution of the continuous Lyapunov equation AX + XA^H + Q = 0)
|
max@0
|
211
|
max@0
|
212 template<typename eT>
|
max@0
|
213 inline static bool lyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q);
|
max@0
|
214
|
max@0
|
215
|
max@0
|
216 //
|
max@0
|
217 // dlyap (solution of the discrete Lyapunov equation AXA^H - X + Q = 0)
|
max@0
|
218
|
max@0
|
219 template<typename eT>
|
max@0
|
220 inline static bool dlyap(Mat<eT>& X, const Mat<eT>& A, const Mat<eT>& Q);
|
max@0
|
221 };
|
max@0
|
222
|
max@0
|
223
|
max@0
|
224 //! @}
|