All Classes Namespaces Functions Typedefs Enumerations Pages
linear_algebra_double.h
1 /* Copyright (C) 2003-2005 Martin Förg
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * martin.o.foerg@googlemail.com
19  *
20  */
21 
22 #ifndef linear_algebrad_h
23 #define linear_algebrad_h
24 
25 #include "square_matrix.h"
26 #include "vector.h"
27 #include "row_vector.h"
28 #include "diagonal_matrix.h"
29 #include "symmetric_matrix.h"
30 #include "band_matrix.h"
31 #include <complex>
32 
33 //-------------------------------------
34 // Matrix operations
35 //-------------------------------------
36 
37 namespace fmatvec {
41 int svd(Matrix<General, Ref, Ref, double> &A, Matrix<General, Ref, Ref, double> &S, SquareMatrix<Ref, double> &U, SquareMatrix<Ref, double> &VT, int Rueckgabe);
42 
49  Vector<Ref, std::complex<double> > eigval(const SquareMatrix<Ref, double> &A);
50 
59  int eigvec(const SquareMatrix<Ref, double> &A, SquareMatrix<Ref, std::complex<double> > &eigenvectors, Vector<Ref, std::complex<double> > &eigenvalues);
60 
71  int eigvec(const Matrix<Symmetric, Ref, Ref, double> &A, const Matrix<Symmetric, Ref, Ref, double> &B, SquareMatrix<Ref, double> &eigenvectors, Vector<Ref, double> &eigenvalues);
72 
79  Vector<Ref, double> eigval(const Matrix<Symmetric, Ref, Ref, double> &A);
80 
92  Vector<Ref, double> eigvalSel(const Matrix<Symmetric, Ref, Ref, double> &A, int il, int iu, double abstol = 0);
93 
115  int Doolittle_LU_with_Pivoting_Solve(double *A, double B[], int pivot[], double x[], int n);
116 
126  Matrix<General, Ref, Ref, double> slvLU(const SquareMatrix<Ref, double> &A, const Matrix<General, Ref, Ref, double> &B);
127  Matrix<General, Var, Var, double> slvLU(const SquareMatrix<Var, double> &A, const Matrix<General, Var, Var, double> &B, int & info);
128 
138  Vector<Ref, double> slvLU(const SquareMatrix<Ref, double> &A, const Vector<Ref, double> &b);
139 
150  Vector<Ref, double> slvLU(const SquareMatrix<Ref, double> &A, const Vector<Ref, double> &x, int & info);
151  Vector<Var, double> slvLU(const SquareMatrix<Var, double> &A, const Vector<Var, double> &b, int & info);
152 
163  Matrix<General, Ref, Ref, double> slvLUFac(const SquareMatrix<Ref, double> &A, const Matrix<General, Ref, Ref, double> &B, const Vector<Ref, int> &ipiv);
164  Matrix<General, Var, Var, double> slvLUFac(const SquareMatrix<Var, double> &ALU, const Matrix<General, Var, Var, double> &B, const Vector<Var, int> &ipiv);
165 
176  Vector<Ref, double> slvLUFac(const SquareMatrix<Ref, double> &A, const Vector<Ref, double> &b, const Vector<Ref, int> &ipiv);
177  Vector<Var, double> slvLUFac(const SquareMatrix<Var, double> &ALU, const Vector<Var, double> &b, const Vector<Var, int> &ipiv);
178 
188  Matrix<General, Ref, Ref, double> slvLL(const Matrix<Symmetric, Ref, Ref, double> &A, const Matrix<General, Ref, Ref, double> &B);
189 
199  Vector<Ref, double> slvLL(const Matrix<Symmetric, Ref, Ref, double> &A, const Vector<Ref, double> &b);
200 
210  Matrix<General, Ref, Ref, double> slvQR(const SquareMatrix<Ref, double> &A, const Matrix<General, Ref, Ref, double> &B);
211 
221  Vector<Ref, double> slvQR(const SquareMatrix<Ref, double> &A, const Vector<Ref, double> &b);
222 
230  SquareMatrix<Ref, double> inv(const SquareMatrix<Ref, double> &A);
231 
239  Matrix<Symmetric, Ref, Ref, double> inv(const Matrix<Symmetric, Ref, Ref, double> &A);
240 
248  Matrix<Diagonal, Ref, Ref, double> inv(const Matrix<Diagonal, Ref, Ref, double> &A);
249 
258  Matrix<General, Ref, Ref, double> facLU(const Matrix<General, Ref, Ref, double> &A, Vector<Ref, int> &ipiv);
259 
268  SquareMatrix<Ref, double> facLU(const SquareMatrix<Ref, double> &A, Vector<Ref, int> &ipiv);
269 
270  SquareMatrix<Var, double> facLU(const SquareMatrix<Var, double> &A, Vector<Var, int> &ipiv);
271 
283  int facLU(double *A, int pivot[], int n);
284 
292  Matrix<Symmetric, Ref, Ref, double> facLL(const Matrix<Symmetric, Ref, Ref, double> &A);
293 
300  double nrm1(const Vector<Ref, double> &x);
301 
308  double nrm2(const Vector<Ref, double> &x);
309 
316  double nrmInf(const Vector<Ref, double> &x);
317 
325  double nrm1(const Matrix<General, Ref, Ref, double> &A);
326 
333  double nrm2(const Matrix<General, Ref, Ref, double> &A);
334 
342  double nrmInf(const Matrix<General, Ref, Ref, double> &A);
343 
351  double nrmInf(const Matrix<Symmetric, Ref, Ref, double> &A);
352 
359  double nrmFro(const Matrix<General, Ref, Ref, double> &A);
360 
367  double rho(const SquareMatrix<Ref, double> &A);
368 
375  double rho(const Matrix<Symmetric, Ref, Ref, double> &A);
376 
377  Vector<Ref, double> slvLLFac(const Matrix<Symmetric, Ref, Ref, double> &A, const Vector<Ref, double> &x);
378 
379  Matrix<General, Ref, Ref, double> slvLLFac(const Matrix<Symmetric, Ref, Ref, double> &A, const Matrix<General, Ref, Ref, double> &X);
380 
381  Matrix<General, Ref, Ref, double> slvLS(const Matrix<General, Ref, Ref, double> &A, const Matrix<General, Ref, Ref, double> &B, double rcond = -1);
382 
383  Vector<Ref, double> slvLS(const Matrix<General, Ref, Ref, double> &A, const Vector<Ref, double> &b, double rcond = -1);
384 
385 //Matrix<General,Ref,Ref,double> slvLU(CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_DIAG unit, const SquareMatrix<Ref,double> &A, const Matrix<General,Ref,Ref,double> &X, const Vector<Ref,int> &ipiv );
386 
394 //Matrix<General,Ref,Ref,double> swap(const Matrix<General,Ref,Ref,double> &A, const Vector<Ref,int> &ipiv );
395 
406  template <int size>
407  Vector<Fixed<size>, double> slvLU(const SquareMatrix<Fixed<size>, double> &A, const Vector<Fixed<size>, double> &b, int & info) {
408 
409 #ifndef FMATVEC_NO_VOID_CHECK
410  if (size == 0)
411  return b;
412 #endif
413 
414  int ipiv[size];
415 
416  SquareMatrix<Fixed<size>, double> LU = A;
417 
418  info = facLU(LU(), ipiv, size);
419 
420  Vector<Fixed<size>, double> x = b;
421  Vector<Fixed<size>, double> y = b;
422 
423  info = Doolittle_LU_with_Pivoting_Solve(LU(), y(), ipiv, x(), size);
424 
425  return x;
426 
427  }
428 
429 }
430 
431 #endif
double rho(const SquareMatrix< Ref, double > &A)
Spectral radius.
Definition: linear_algebra_double.cc:876
Matrix< Symmetric, Ref, Ref, double > facLL(const Matrix< Symmetric, Ref, Ref, double > &A)
LL decomposition.
Definition: linear_algebra_double.cc:571
Definition: types.h:68
Vector< Ref, std::complex< double > > eigval(const SquareMatrix< Ref, double > &A)
Eigenvalues.
Definition: linear_algebra_double.cc:731
Matrix< General, Ref, Ref, double > slvLUFac(const SquareMatrix< Ref, double > &A, const Matrix< General, Ref, Ref, double > &X, const Vector< Ref, int > &ipiv)
Systems of linear equations.
Definition: linear_algebra_double.cc:119
int eigvec(const SquareMatrix< Ref, double > &A, SquareMatrix< Ref, std::complex< double > > &V, Vector< Ref, std::complex< double > > &w)
Eigenvectors and Eigenvalues.
Definition: linear_algebra_double.cc:751
Matrix< General, Ref, Ref, double > facLU(const Matrix< General, Ref, Ref, double > &A, Vector< Ref, int > &ipiv)
LU decomposition.
Definition: linear_algebra_double.cc:451
Vector< Ref, double > eigvalSel(const Matrix< Symmetric, Ref, Ref, double > &A, int il, int iu, double abstol)
Eigenvalues.
Definition: linear_algebra_double.cc:856
double nrmFro(const Matrix< General, Ref, Ref, double > &A)
Frobenius-norm.
Definition: linear_algebra_double.cc:938
Matrix< General, Ref, Ref, double > slvQR(const SquareMatrix< Ref, double > &A, const Matrix< General, Ref, Ref, double > &X)
Systems of linear equations.
Definition: linear_algebra_double.cc:173
Definition: matrix.h:212
Definition: matrix.h:215
SquareMatrix< Ref, double > inv(const SquareMatrix< Ref, double > &A)
Inverse.
Definition: linear_algebra_double.cc:386
int Doolittle_LU_with_Pivoting_Solve(double *A, double B[], int pivot[], double x[], int n)
solve linear system with LU decomposed matrix
Definition: linear_algebra_double.cc:196
Vector< Ref, std::complex< double > > slvLU(const SquareMatrix< Ref, std::complex< double > > &A, const Vector< Ref, std::complex< double > > &x)
System of linear equations.
Definition: linear_algebra_complex.cc:61
Vector< Ref, double > slvLL(const Matrix< Symmetric, Ref, Ref, double > &A, const Vector< Ref, double > &x)
System of linear equations.
Definition: linear_algebra_double.cc:623
int svd(Matrix< General, Ref, Ref, double > &A, Matrix< General, Ref, Ref, double > &S, SquareMatrix< Ref, double > &U, SquareMatrix< Ref, double > &VT, int Rueckgabe)
Definition: linear_algebra_double.cc:815
double nrm1(const Vector< Ref, double > &x)
1-norm
Definition: linear_algebra_double.cc:592

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML