00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SCIMATH_MATRIXMATHLA_H
00029 #define SCIMATH_MATRIXMATHLA_H
00030
00031
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/Arrays/Vector.h>
00034 #include <casacore/casa/Arrays/Matrix.h>
00035 #include <casacore/casa/BasicSL/Complex.h>
00036
00037
00038 namespace casacore {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 template<class T> void invert(Matrix<T> & out, T& determinate,
00065 const Matrix<T> &in);
00066 template<class T> Matrix<T> invert(const Matrix<T> &in);
00067 template<class T> T determinate(const Matrix<T> &in);
00068
00069
00070
00071
00072
00073
00074
00075
00076 template<class T> void invertSymPosDef(Matrix<T> & out, T& determinate,
00077 const Matrix<T> &in);
00078 template<class T> Matrix<T> invertSymPosDef(const Matrix<T> &in);
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 template<class T> void CholeskyDecomp(Matrix<T> &A, Vector<T> &diag);
00091
00092
00093
00094
00095
00096 template<class T> void CholeskySolve(Matrix<T> &A, Vector<T> &diag,
00097 Vector<T> &b, Vector<T> &x);
00098
00099
00100
00101
00102
00103 #if !defined(NEED_FORTRAN_UNDERSCORES)
00104 #define NEED_FORTRAN_UNDERSCORES 1
00105 #endif
00106
00107 #if NEED_FORTRAN_UNDERSCORES
00108 #define sgetrf sgetrf_
00109 #define dgetrf dgetrf_
00110 #define cgetrf cgetrf_
00111 #define zgetrf zgetrf_
00112 #define sgetri sgetri_
00113 #define dgetri dgetri_
00114 #define cgetri cgetri_
00115 #define zgetri zgetri_
00116 #define sposv sposv_
00117 #define dposv dposv_
00118 #define cposv cposv_
00119 #define zposv zposv_
00120 #define spotri spotri_
00121 #define dpotri dpotri_
00122 #define cpotri cpotri_
00123 #define zpotri zpotri_
00124 #endif
00125
00126 extern "C" {
00127 void sgetrf(const int *m, const int *n, float *a, const int *lda,
00128 int *ipiv, int *info);
00129 void dgetrf(const int *m, const int *n, double *a, const int *lda,
00130 int *ipiv, int *info);
00131 void cgetrf(const int *m, const int *n, Complex *a, const int *lda,
00132 int *ipiv, int *info);
00133 void zgetrf(const int *m, const int *n, DComplex *a, const int *lda,
00134 int *ipiv, int *info);
00135 void sgetri(const int *m, float *a, const int *lda, const int *ipiv,
00136 float *work, const int *lwork, int *info);
00137 void dgetri(const int *m, double *a, const int *lda, const int *ipiv,
00138 double *work, const int *lwork, int *info);
00139 void cgetri(const int *m, Complex *a, const int *lda, const int *ipiv,
00140 Complex *work, const int *lwork, int *info);
00141 void zgetri(const int *m, DComplex *a, const int *lda, const int *ipiv,
00142 DComplex *work, const int *lwork, int *info);
00143
00144
00145 void sposv(const char *uplo, const int *n, const int* nrhs, float *a,
00146 const int *lda, float *b, const int *ldb, int *info);
00147 void dposv(const char *uplo, const int *n, const int* nrhs, double *a,
00148 const int *lda, double *b, const int *ldb, int *info);
00149 void cposv(const char *uplo, const int *n, const int* nrhs, Complex *a,
00150 const int *lda, Complex *b, const int *ldb, int *info);
00151 void zposv(const char *uplo, const int *n, const int* nrhs, DComplex *a,
00152 const int *lda, DComplex *b, const int *ldb, int *info);
00153
00154
00155 void spotri(const char *uplo, const int *n, float *a,
00156 const int *lda, int *info);
00157 void dpotri(const char *uplo, const int *n, double *a,
00158 const int *lda, int *info);
00159 void cpotri(const char *uplo, const int *n, Complex *a,
00160 const int *lda, int *info);
00161 void zpotri(const char *uplo, const int *n, DComplex *a,
00162 const int *lda, int *info);
00163
00164 }
00165
00166
00167 inline void getrf(const int *m, const int *n, float *a, const int *lda,
00168 int *ipiv, int *info)
00169 { sgetrf(m, n, a, lda, ipiv, info); }
00170 inline void getrf(const int *m, const int *n, double *a, const int *lda,
00171 int *ipiv, int *info)
00172 { dgetrf(m, n, a, lda, ipiv, info); }
00173 inline void getrf(const int *m, const int *n, Complex *a, const int *lda,
00174 int *ipiv, int *info)
00175 { cgetrf(m, n, a, lda, ipiv, info); }
00176 inline void getrf(const int *m, const int *n, DComplex *a, const int *lda,
00177 int *ipiv, int *info)
00178 { zgetrf(m, n, a, lda, ipiv, info); }
00179 inline void getri(const int *m, float *a, const int *lda, const int *ipiv,
00180 float *work, const int *lwork, int *info)
00181 { sgetri(m, a, lda, ipiv, work, lwork, info); }
00182 inline void getri(const int *m, double *a, const int *lda, const int *ipiv,
00183 double *work, const int *lwork, int *info)
00184 { dgetri(m, a, lda, ipiv, work, lwork, info); }
00185 inline void getri(const int *m, Complex *a, const int *lda, const int *ipiv,
00186 Complex *work, const int *lwork, int *info)
00187 { cgetri(m, a, lda, ipiv, work, lwork, info); }
00188 inline void getri(const int *m, DComplex *a, const int *lda, const int *ipiv,
00189 DComplex *work, const int *lwork, int *info)
00190 { zgetri(m, a, lda, ipiv, work, lwork, info); }
00191
00192 inline void posv(const char *uplo, const int *n, const int* nrhs, float *a,
00193 const int *lda, float *b, const int *ldb, int *info)
00194 { sposv(uplo, n, nrhs, a, lda, b, ldb, info); }
00195 inline void posv(const char *uplo, const int *n, const int* nrhs, double *a,
00196 const int *lda, double *b, const int *ldb, int *info)
00197 { dposv(uplo, n, nrhs, a, lda, b, ldb, info); }
00198 inline void posv(const char *uplo, const int *n, const int* nrhs, Complex *a,
00199 const int *lda, Complex *b, const int *ldb, int *info)
00200 { cposv(uplo, n, nrhs, a, lda, b, ldb, info); }
00201 inline void posv(const char *uplo, const int *n, const int* nrhs, DComplex *a,
00202 const int *lda, DComplex *b, const int *ldb, int *info)
00203 { zposv(uplo, n, nrhs, a, lda, b, ldb, info); }
00204
00205 inline void potri(const char *uplo, const int *n, float *a,
00206 const int *lda, int *info)
00207 { spotri(uplo, n, a, lda, info); }
00208 inline void potri(const char *uplo, const int *n, double *a,
00209 const int *lda, int *info)
00210 { dpotri(uplo, n, a, lda, info); }
00211 inline void potri(const char *uplo, const int *n, Complex *a,
00212 const int *lda, int *info)
00213 { cpotri(uplo, n, a, lda, info); }
00214 inline void potri(const char *uplo, const int *n, DComplex *a,
00215 const int *lda, int *info)
00216 { zpotri(uplo, n, a, lda, info); }
00217
00218
00219
00220 }
00221
00222 #ifndef CASACORE_NO_AUTO_TEMPLATES
00223 #include <casacore/scimath/Mathematics/MatrixMathLA.tcc>
00224 #endif //# CASACORE_NO_AUTO_TEMPLATES
00225 #endif