1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
/*
* Copyright (c) 2002-2006 Samit Basu
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __FMLAPACK_hpp__
#define __FMLAPACK_hpp__
#include <cstring>
// Lapack routines used are declared here
extern "C" {
double dlamch_(char * CMACH);
float slamch_(char * CMACH);
void dgesvx_(char* FACT, char* TRANS, int * N, int * NRHS,
double *A, int * LDA, double * AF, int * LDAF,
int * IPIV, char * EQUED, double * R, double * C,
double * B, int * LDB, double * X, int * LDX,
double * RCOND, double * FERR, double * BERR,
double * WORK, int * IWORK, int * INFO);
void zgesvx_(char* FACT, char* TRANS, int * N, int * NRHS,
double *A, int * LDA, double * AF, int * LDAF,
int * IPIV, char * EQUED, double * R, double * C,
double * B, int * LDB, double * X, int * LDX,
double * RCOND, double * FERR, double * BERR,
double * WORK, double * RWORK, int * INFO);
void sgesvx_(char* FACT, char* TRANS, int * N, int * NRHS,
float *A, int * LDA, float * AF, int * LDAF,
int * IPIV, char * EQUED, float * R, float * C,
float * B, int * LDB, float * X, int * LDX,
float * RCOND, float * FERR, float * BERR,
float * WORK, int * IWORK, int * INFO);
void cgesvx_(char* FACT, char* TRANS, int * N, int * NRHS,
float *A, int * LDA, float * AF, int * LDAF,
int * IPIV, char * EQUED, float * R, float * C,
float * B, int * LDB, float * X, int * LDX,
float * RCOND, float * FERR, float * BERR,
float * WORK, float * RWORK, int * INFO);
void dgelsy_(int* M, int *N, int *NRHS, double* A, int *LDA,
double *B, int *LDB, int *JPVT, double* RCOND,
int *RANK, double *WORK, int* LWORK, int* INFO);
void zgelsy_(int* M, int *N, int *NRHS, double* A, int *LDA,
double *B, int *LDB, int *JPVT, double* RCOND,
int *RANK, double *WORK, int* LWORK, double* RWORK,
int* INFO);
void sgelsy_(int* M, int *N, int *NRHS, float* A, int *LDA,
float *B, int *LDB, int *JPVT, float* RCOND,
int *RANK, float *WORK, int* LWORK, int* INFO);
void cgelsy_(int* M, int *N, int *NRHS, float* A, int *LDA,
float *B, int *LDB, int *JPVT, float* RCOND,
int *RANK, float *WORK, int* LWORK, float* RWORK,
int* INFO);
void sgeevx_(char* BALANC, char* JOBVL, char* JOBVR, char* SENSE,
int* N, float* A, int* LDA, float* WR, float* WI,
float* VL, int *LDVL, float* VR, int *LDVR, int *ILO,
int *IHI, float* SCALE, float* ABNRM, float* RCONDE,
float* RCONDV, float *WORK, int *LWORK, int *IWORK,
int *INFO);
void dgeevx_(char* BALANC, char* JOBVL, char* JOBVR, char* SENSE,
int* N, double* A, int* LDA, double* WR, double* WI,
double* VL, int *LDVL, double* VR, int *LDVR, int *ILO,
int *IHI, double* SCALE, double* ABNRM, double* RCONDE,
double* RCONDV, double *WORK, int *LWORK, int *IWORK,
int *INFO);
void cgeevx_(char* BALANC, char* JOBVL, char* JOBVR, char* SENSE,
int* N, float* A, int* LDA, float* W, float* VL,
int *LDVL, float* VR, int *LDVR, int *ILO,
int *IHI, float* SCALE, float* ABNRM, float* RCONDE,
float* RCONDV, float *WORK, int *LWORK, float *RWORK,
int *INFO);
void zgeevx_(char* BALANC, char* JOBVL, char* JOBVR, char* SENSE,
int* N, double* A, int* LDA, double* W, double* VL,
int *LDVL, double* VR, int *LDVR, int *ILO,
int *IHI, double* SCALE, double* ABNRM, double* RCONDE,
double* RCONDV, double *WORK, int *LWORK, double *RWORK,
int *INFO);
void sgesvd_(char* JOBS, char* JOBVT, int* M, int *N, float* A,
int *LDA, float *S, float *U, int *LDU, float *VT,
int *LDVT, float *WORK, int *LWORK, int *INFO);
void dgesvd_(char* JOBS, char* JOBVT, int* M, int *N, double* A,
int *LDA, double *S, double *U, int *LDU, double *VT,
int *LDVT, double *WORK, int *LWORK, int *INFO);
void cgesvd_(char* JOBS, char* JOBVT, int* M, int *N, float* A,
int *LDA, float *S, float *U, int *LDU, float *VT,
int *LDVT, float *WORK, int *LWORK, float *RWORK, int *INFO);
void zgesvd_(char* JOBS, char* JOBVT, int* M, int *N, double* A,
int *LDA, double *S, double *U, int *LDU, double *VT,
int *LDVT, double *WORK, int *LWORK, double *RWORK, int *INFO);
void sgeqrf_(int *M, int *N, float *A, int *LDA, float *TAU, float *WORK,
int *LWORK, int *INFO);
void sgeqp3_(int *M, int *N, float *A, int *LDA, int *JPVT,
float *TAU, float *WORK, int *LWORK, int *INFO);
void sorgqr_(int *M, int *N, int *K, float *A, int *LDA,
float *TAU, float *WORK, int *LWORK, int *INFO);
void dgeqrf_(int *M, int *N, double *A, int *LDA, double *TAU, double *WORK,
int *LWORK, int *INFO);
void dgeqp3_(int *M, int *N, double *A, int *LDA, int *JPVT,
double *TAU, double *WORK, int *LWORK, int *INFO);
void dorgqr_(int *M, int *N, int *K, double *A, int *LDA,
double *TAU, double *WORK, int *LWORK, int *INFO);
void cgeqrf_(int *M, int *N, float *A, int *LDA, float *TAU, float *WORK,
int *LWORK, int *INFO);
void cgeqp3_(int *M, int *N, float *A, int *LDA, int *JPVT,
float *TAU, float *WORK, int *LWORK, float *RWORK, int *INFO);
void cungqr_(int *M, int *N, int *K, float *A, int *LDA,
float *TAU, float *WORK, int *LWORK, int *INFO);
void zgeqrf_(int *M, int *N, double *A, int *LDA, double *TAU, double *WORK,
int *LWORK, int *INFO);
void zgeqp3_(int *M, int *N, double *A, int *LDA, int *JPVT,
double *TAU, double *WORK, int *LWORK, double *RWORK, int *INFO);
void zungqr_(int *M, int *N, int *K, double *A, int *LDA,
double *TAU, double *WORK, int *LWORK, int *INFO);
void ssyev_(char *JOBZ, char *UPLO, int *N, float *A, int *LDA,
float *W, float *WORK, int *LWORK, int *INFO);
void dsyev_(char *JOBZ, char *UPLO, int *N, double *A, int *LDA,
double *W, double *WORK, int *LWORK, int *INFO);
void cheev_(char *JOBZ, char *UPLO, int *N, float *A, int *LDA,
float *W, float *WORK, int *LWORK, float *RWORK, int *INFO);
void zheev_(char *JOBZ, char *UPLO, int *N, double *A, int *LDA,
double *W, double *WORK, int *LWORK, double *RWORK, int *INFO);
void sggev_(char *JOBVL, char *JOBVR, int *N, float *A, int *LDA,
float *B, int *LDB, float *ALPHAR, float *ALPHAI,
float *BETA, float *VL, int *LDVL, float *VR,
int *LDVR, float *WORK, int *LWORK, int *INFO );
void ssygv_(int *ITYPE, char *JOBZ, char *UPLO, int *N, float *A,
int *LDA, float *B, int *LDB, float *W, float *WORK,
int *LWORK, int *INFO );
void dggev_(char *JOBVL, char *JOBVR, int *N, double *A, int *LDA,
double *B, int *LDB, double *ALPHAR, double *ALPHAI,
double *BETA, double *VL, int *LDVL, double *VR,
int *LDVR, double *WORK, int *LWORK, int *INFO );
void dsygv_(int *ITYPE, char *JOBZ, char *UPLO, int *N, double *A,
int *LDA, double *B, int *LDB, double *W, double *WORK,
int *LWORK, int *INFO );
void cggev_(char *JOBVL, char *JOBVR, int *N, float *A, int *LDA,
float *B, int *LDB, float *ALPHA, float *BETA,
float *VL, int *LDVL, float *VR, int *LDVR,
float *WORK, int *LWORK, float *RWORK, int *INFO );
void chegv_(int *ITYPE, char *JOBZ, char *UPLO, int *N, float *A,
int *LDA, float *B, int *LDB, float *W, float *WORK,
int *LWORK, float *RWORK, int *INFO );
void zggev_(char *JOBVL, char *JOBVR, int *N, double *A, int *LDA,
double *B, int *LDB, double *ALPHA, double *BETA,
double *VL, int *LDVL, double *VR, int *LDVR,
double *WORK, int *LWORK, double *RWORK, int *INFO );
void zhegv_(int *ITYPE, char *JOBZ, char *UPLO, int *N, double *A,
int *LDA, double *B, int *LDB, double *W, double *WORK,
int *LWORK, double *RWORK, int *INFO );
void sgetrf_(int *M, int *N, float *A, int *LDA, int *IPIV, int *INFO);
void cgetrf_(int *M, int *N, float *A, int *LDA, int *IPIV, int *INFO);
void dgetrf_(int *M, int *N, double *A, int *LDA, int *IPIV, int *INFO);
void zgetrf_(int *M, int *N, double *A, int *LDA, int *IPIV, int *INFO);
void sgetri_(int *N, float *A, int *LDA, int *IPIV, float *WORK, int *LWORK, int *INFO);
void cgetri_(int *N, float *A, int *LDA, int *IPIV, float *WORK, int *LWORK, int *INFO);
void dgetri_(int *N, double *A, int *LDA, int *IPIV, double *WORK, int *LWORK, int *INFO);
void zgetri_(int *N, double *A, int *LDA, int *IPIV, double *WORK, int *LWORK, int *INFO);
int xerbla_(char *srname, int *info);
double snrm2_(int *N, float *X, int *INCX);
double dnrm2_(int *N, double *X, int *INCX);
double scnrm2_(int *N, float *X, int *INCX);
double dznrm2_(int *N, double *X, int *INCX);
void dgecon_(char *norm, int *N, double *A, int *LDA, double *Anorm,
double *rcond, double *work, int *iwork, int *info);
void sgecon_(char *norm, int *N, float *A, int *LDA, float *Anorm,
float *rcond, float *work, int *iwork, int *info);
void cgecon_(char *norm, int *N, float *A, int *LDA, float *Anorm,
float *rcond, float *work, float *rwork, int *info);
void zgecon_(char *norm, int *N, double *A, int *LDA, double *Anorm,
double *rcond, double *work, double *rwork, int *info);
double dlange_(char *norm, int *M, int *N, double *A, int *LDA,
double *work);
float slange_(char *norm, int *M, int *N, float *A, int *LDA,
float *work);
float clange_(char *norm, int *M, int *N, float *A, int *LDA,
float *work);
double zlange_(char *norm, int *M, int *N, double *A, int *LDA,
double *work);
}
/**
* Call the LAPACK slamch function to get the $$\epsilon$$ value for
* a floating point number.
*/
double getEPS();
/**
* Call the LAPACK dlamch function to get the $$\epsilon$$ value for
* a double-precision floating point number.
*/
float getFloatEPS();
template <typename T>
T lamch();
/**
* This function effectively pads each column in the source matrix by a
* number of zeros. It actually allows us to change the stride of the
* matrix (amount that must be added to an index to move from one column
* to the next).
*/
template <typename T>
void changeStride(T*dst, int dstStride, T*src, int srcStride,
int rowCount, int colCount) {
for (int i=0;i<colCount;i++)
memcpy(dst + i*dstStride, src + i*srcStride, rowCount*sizeof(T));
}
#endif
|