36#ifndef __YTLIB_MATRIX_H
37#define __YTLIB_MATRIX_H
40extern int ytMatrix_INT_ONE;
41extern int ytMatrix_INT_ZERO;
42extern double ytMatrix_DOUBLE_ONE;
43extern double ytMatrix_DOUBLE_ZERO;
44extern double ytMatrix_DOUBLE_MINUS_ONE;
48void ytMatrix_dsyaxpy(
const int n,
double alpha,
double * X,
double * Y);
50int ytMatrix_dsyev_work_size(
int n);
51void ytMatrix_print(FILE * fp,
const double * X,
int m,
int n,
int N);
53void ytMatrix_vprint(FILE * fp,
const double * X,
int n,
int N);
58#if defined(USE_MACOSX_VECLIB)
60#include <Accelerate/Accelerate.h>
62typedef __CLPK_integer ytMatrix_int;
63typedef __CLPK_doublereal ytMatrix_double;
65#ifndef USE_CBLAS_ROUTINES
66#define USE_CBLAS_ROUTINES
70extern char * ytMatrix_LU;
71extern char * ytMatrix_LL;
72extern char * ytMatrix_LN;
73extern char * ytMatrix_LV;
76extern char * ytMatrix_LA;
77extern char * ytMatrix_LO;
79#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,LW,IF) dsytrf_(UL,N,A,LA,IP,W,LW,IF)
80#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) dsytri_(UL,N,A,LA,IP,W,IF)
81#define ytMatrix_dsytrs(UL,N,M,A,LA,IP,B,LB,IF) dsytrs_(UL,N,M,A,LA,IP,B,LB,IF)
82#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) dsyev_(JB,UL,N,A,LA,W,WO,LW,IF)
83#define ytMatrix_dgesv(N,M,A,LDA,IP,B,LDB,IF) dgesv_(N,M,A,LDA,IP,B,LDB,IF)
84#define ytMatrix_dgetrf(M,N,A,LA,IP,IF) dgetrf_(M,N,A,LA,IP,IF)
85#define ytMatrix_dgetri(N,A,LA,IP,W,LW,IF) dgetri_(N,A,LA,IP,W,LW,IF)
86#define ytMatrix_dgetrs(TA,N,M,A,LA,IP,B,LB,IF) dgetrs_(TA,N,M,A,LA,IP,B,LB,IF)
87#define ytMatrix_dgesvd(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF) \
88 dgesvd_(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF)
95#elif defined(USE_INTEL_MKL)
98#include <mkl_lapack.h>
99#include <mkl_lapacke.h>
101typedef MKL_INT ytMatrix_int;
102typedef double ytMatrix_double;
104extern char * ytMatrix_T;
105extern char * ytMatrix_N;
106extern char * ytMatrix_C;
107extern char * ytMatrix_NO_TRANS;
108extern char * ytMatrix_TRANS;
109extern char * ytMatrix_U;
110extern char * ytMatrix_L;
114#define ytMatrix_dscal(N,ALPHA,X,IX) dscal(N,ALPHA,X,IX)
115#define ytMatrix_dcopy(N,X,IX,Y,IY) dcopy(N,X,IX,Y,IY)
116#define ytMatrix_daxpy(N,ALPHA,X,IX,Y,IY) daxpy(N,ALPHA,X,IX,Y,IY)
117#define ytMatrix_ddot(N,X,IX,Y,IY) ddot(N,X,IX,Y,IY)
118#define ytMatrix_dnrm2(N,X,IX) dnrm2(N,X,IX)
119#define ytMatrix_dasum(N,X,IX) dasum(N,X,IX)
122#define ytMatrix_dgemv(T,M,N,ALPHA,A,LDA,X,IX,BETA,Y,IY)\
123 dgemv(T,M,N,ALPHA,A,LDA,X,IX,BETA,Y,IY)
124#define ytMatrix_dsymv(UL,N,ALPHA,A,LA,X,IX,BETA,Y,IY)\
125 dsymv(UL,N,ALPHA,A,LA,X,IX,BETA,Y,IY)
126#define ytMatrix_dger(M,N,ALPHA,X,IX,Y,IY,A,LDA)\
127 dger(M,N,ALPHA,X,IX,Y,IY,A,LDA)
130#define ytMatrix_dgemm(TA,TB,M,N,K,ALPHA,A,LA,B,LB,BETA,C,LC) \
131 dgemm(TA,TB,M,N,K,ALPHA,A,LA,B,LB,BETA,C,LC)
132#define ytMatrix_dsyrk(UL,T,N,K,ALPHA,A,LDA,BETA,C,LC) \
133 dsyrk(UL,T,N,K,ALPHA,A,LDA,BETA,C,LC)
136extern char * ytMatrix_LU;
137extern char * ytMatrix_LL;
138extern char * ytMatrix_LN;
139extern char * ytMatrix_LV;
142extern char * ytMatrix_LA;
143extern char * ytMatrix_LO;
145#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,LW,IF) \
146 LAPACKE_dsytrf(LAPACK_COL_MAJOR, *(UL), *(N), A, *(LA), IP)
147#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) \
148 LAPACKE_dsytri(LAPACK_COL_MAJOR, *(UL), *(N), A, *(LA), IP)
152#define ytMatrix_dsytrs(UL,N,M,A,LA,IP,B,LB,IF) \
153 LAPACKE_dsytrs(LAPACK_COL_MAJOR,*(UL),*(N),*(M),A,*(LA),IP,B,*(LB))
154#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) \
155 LAPACKE_dsyev(LAPACK_COL_MAJOR,*(JB),*(UL),*(N),A,*(LA),W)
156#define ytMatrix_dgesv(N,M,A,LDA,IP,B,LDB,IF) dgesv_(N,M,A,LDA,IP,B,LDB,IF)
157#define ytMatrix_dgetrf(M,N,A,LA,IP,IF) dgetrf_(M,N,A,LA,IP,IF)
158#define ytMatrix_dgetri(N,A,LA,IP,W,LW,IF) dgetri_(N,A,LA,IP,W,LW,IF)
159#define ytMatrix_dgetrs(TA,N,M,A,LA,IP,B,LB,IF) dgetrs_(TA,N,M,A,LA,IP,B,LB,IF)
160#define ytMatrix_dgesvd(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF) \
161 dgesvd_(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF)
167#elif defined(USE_FUJITSU_FCC_SSL)
169#include <fj_lapack.h>
171typedef int ytMatrix_int;
172typedef double ytMatrix_double;
174extern char * ytMatrix_T;
175extern char * ytMatrix_N;
176extern char * ytMatrix_C;
177extern char * ytMatrix_NO_TRANS;
178extern char * ytMatrix_TRANS;
179extern char * ytMatrix_U;
180extern char * ytMatrix_L;
181extern char * ytMatrix_LEFT;
182extern char * ytMatrix_RIGHT;
186#define ytMatrix_dscal(N,ALPHA,X,IX) dscal_(N,ALPHA,X,IX)
187#define ytMatrix_dcopy(N,X,IX,Y,IY) dcopy_(N,X,IX,Y,IY)
188#define ytMatrix_daxpy(N,ALPHA,X,IX,Y,IY) daxpy_(N,ALPHA,X,IX,Y,IY)
189#define ytMatrix_ddot(N,X,IX,Y,IY) ddot_(N,X,IX,Y,IY)
190#define ytMatrix_dnrm2(N,X,IX) dnrm2_(N,X,IX)
191#define ytMatrix_dasum(N,X,IX) dasum_(N,X,IX)
194#define ytMatrix_dgemv(T,M,N,ALPHA,A,LDA,X,IX,BETA,Y,IY)\
195 dgemv_(T,M,N,ALPHA,A,LDA,X,IX,BETA,Y,IY,1)
196#define ytMatrix_dsymv(UL,N,ALPHA,A,LA,X,IX,BETA,Y,IY)\
197 dsymv_(UL,N,ALPHA,A,LA,X,IX,BETA,Y,IY,1)
198#define ytMatrix_dger(M,N,ALPHA,X,IX,Y,IY,A,LDA)\
199 dger_(M,N,ALPHA,X,IX,Y,IY,A,LDA)
203#define ytMatrix_dgemm(TA,TB,M,N,K,ALPHA,A,LA,B,LB,BETA,C,LC) \
204 dgemm_(TA,TB,M,N,K,ALPHA,A,LA,B,LB,BETA,C,LC,1,1)
205#define ytMatrix_dsymm(LR,UL,M,N,ALPHA,A,LA,B,LB,BETA,C,LC) \
206 dsymm_(LR,UL,M,N,ALPHA,A,LA,B,LB,BETA,C,LC,1,1)
207#define ytMatrix_dsyrk(UL,T,N,K,ALPHA,A,LDA,BETA,C,LC) \
208 dsyrk_(UL,T,N,K,ALPHA,A,LDA,BETA,C,LC,1,1)
211extern char * ytMatrix_LU;
212extern char * ytMatrix_LL;
213extern char * ytMatrix_LN;
214extern char * ytMatrix_LV;
217extern char * ytMatrix_LA;
218extern char * ytMatrix_LO;
220#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,IW,IF) dsytrf_(UL,N,A,LA,IP,W,IW,IF,1)
221#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) dsytri_(UL,N,A,LA,IP,W,IF,1)
222#define ytMatrix_dsytrs(UL,N,M,A,LA,IP,B,LB,IF) dsytrs_(UL,N,M,A,LA,IP,B,LB,IF,1)
223#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) dsyev_(JB,UL,N,A,LA,W,WO,LW,IF,1,1)
224#define ytMatrix_dgesv(N,M,A,LDA,IP,B,LDB,IF) dgesv_(N,M,A,LDA,IP,B,LDB,IF)
225#define ytMatrix_dgetrf(M,N,A,LA,IP,IF) dgetrf_(M,N,A,LA,IP,IF)
226#define ytMatrix_dgetri(N,A,LA,IP,W,LW,IF) dgetri_(N,A,LA,IP,W,LW,IF)
227#define ytMatrix_dgetrs(TA,N,M,A,LA,IP,B,LB,IF) dgetrs_(TA,N,M,A,LA,IP,B,LB,IF,1)
228#define ytMatrix_dgesvd(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF) \
229 dgesvd_(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF,1,1)
237#if defined(USE_ARMPL)
243extern char * ytMatrix_LU;
244extern char * ytMatrix_LL;
245extern char * ytMatrix_LN;
246extern char * ytMatrix_LV;
249extern char * ytMatrix_LA;
250extern char * ytMatrix_LO;
252#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,LW,IF) dsytrf_(UL,N,A,LA,IP,W,LW,IF)
253#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) dsytri_(UL,N,A,LA,IP,W,IF)
254#define ytMatrix_dsytrs(UL,N,M,A,LA,IP,B,LB,IF) dsytrs_(UL,N,M,A,LA,IP,B,LB,IF)
255#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) dsyev_(JB,UL,N,A,LA,W,WO,LW,IF)
256#define ytMatrix_dgesv(N,M,A,LDA,IP,B,LDB,IF) dgesv_(N,M,A,LDA,IP,B,LDB,IF)
257#define ytMatrix_dgetrf(M,N,A,LA,IP,IF) dgetrf_(M,N,A,LA,IP,IF)
258#define ytMatrix_dgetri(N,A,LA,IP,W,LW,IF) dgetri_(N,A,LA,IP,W,LW,IF)
259#define ytMatrix_dgetrs(TA,N,M,A,LA,IP,B,LB,IF) dgetrs_(TA,N,M,A,LA,IP,B,LB,IF)
260#define ytMatrix_dgesvd(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF) \
261 dgesvd_(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF)
266#if defined(USE_CBLAS)
268#ifndef USE_CBLAS_ROUTINES
269#define USE_CBLAS_ROUTINES
273#if defined(USE_CBLAS_ROUTINES)
275#define ytMatrix_T CblasTrans
276#define ytMatrix_N CblasNoTrans
277#define ytMatrix_C CblasConjTrans
279#define ytMatrix_NO_TRANS CblasNoTrans
280#define ytMatrix_TRANS CblasTrans
282#define ytMatrix_U CblasUpper
283#define ytMatrix_L CblasLower
285#define ytMatrix_LEFT CblasLeft
286#define ytMatrix_RIGHT CblasRight
288#define ytMatrix_dscal(N,ALPHA,X,IX) cblas_dscal(*N,*ALPHA,X,*IX)
289#define ytMatrix_dcopy(N,X,IX,Y,IY) cblas_dcopy(*N,X,*IX,Y,*IY)
290#define ytMatrix_daxpy(N,ALPHA,X,IX,Y,IY) cblas_daxpy(*N,*ALPHA,X,*IX,Y,*IY)
291#define ytMatrix_ddot(N,X,IX,Y,IY) cblas_ddot(*N,X,*IX,Y,*IY)
292#define ytMatrix_dnrm2(N,X,IX) cblas_dnrm2(*N,X,*IX)
293#define ytMatrix_dasum(N,X,IX) cblas_dasum(*N,X,*IX)
296#define ytMatrix_dgemv(T,M,N,ALPHA,A,LDA,X,IX,BETA,Y,IY)\
297 cblas_dgemv(CblasColMajor,T,*M,*N,*ALPHA,A,*LDA,X,*IX,*BETA,Y,*IY)
298#define ytMatrix_dsymv(UL,N,ALPHA,A,LA,X,IX,BETA,Y,IY)\
299 cblas_dsymv(CblasColMajor,UL,*N,*ALPHA,A,*LA,X,*IX,*BETA,Y,*IY)
300#define ytMatrix_dger(M,N,ALPHA,X,IX,Y,IY,A,LDA)\
301 cblas_dger(CblasColMajor,*M,*N,*ALPHA,X,*IX,Y,*IY,A,*LDA)
304#define ytMatrix_dgemm(TA,TB,M,N,K,ALPHA,A,LA,B,LB,BETA,C,LC) \
305 cblas_dgemm(CblasColMajor,TA,TB,*M,*N,*K,*ALPHA,A,*LA,B,*LB,*BETA,C,*LC)
306#define ytMatrix_dsymm(LR,UL,M,N,ALPHA,A,LA,B,LB,BETA,C,LC) \
307 cblas_dsymm(CblasColMajor,LR,UL,*M,*N,*ALPHA,A,*LA,B,*LB,*BETA,C,*LC)
308#define ytMatrix_dsyrk(UL,T,N,K,ALPHA,A,LDA,BETA,C,LC) \
309 cblas_dsyrk(CblasColMajor,UL,T,*N,*K,*ALPHA,A,*LDA,*BETA,C,*LC)
316extern char * ytMatrix_LU;
317extern char * ytMatrix_LL;
318extern char * ytMatrix_LN;
319extern char * ytMatrix_LV;
322extern char * ytMatrix_LA;
323extern char * ytMatrix_LO;
326#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,LW,IF) \
327 LAPACKE_dsytrf(LAPACK_COL_MAJOR, *(UL), *(N), A, *(LA), IP)
328#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) \
329 LAPACKE_dsytri(LAPACK_COL_MAJOR, *(UL), *(N), A, *(LA), IP)
330#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) \
331 LAPACKE_dsyev(LAPACK_COL_MAJOR,*(JB),*(UL),*(N),A,*(LA),W)
338extern char * ytMatrix_LU;
339extern char * ytMatrix_LL;
340extern char * ytMatrix_LN;
341extern char * ytMatrix_LV;
344extern char * ytMatrix_LA;
345extern char * ytMatrix_LO;
347void dsytrf_(
char * UL,
int * N,
double * A,
int * ldA,
int * IP,
double * WORK,
int * LWORK,
int * info);
348void dsytri_(
char * UL,
int * N,
double * A,
int * ldA,
int * IP,
double * W,
int * info);
349void dsyev_(
char * JB,
char * UL,
int * N,
double * A,
int * ldA,
double * W,
350 double * WORK,
int * LWORK,
int * info);
351void dgesv_(
int * N,
int * M,
double * A,
int * ldA,
int * IP,
double * B,
int * ldB,
int * info);
352void dgetrf_(
int * M,
int * N,
double * A,
int * ldA,
int * IP,
int * info);
353void dgetri_(
int * N,
double * A,
int * ldA,
int * IP,
double * WORK,
int * LWORK,
int * info);
354void dgetrs_(
char * TA,
int * N,
int * M,
double * A,
int * ldA,
int * IP,
355 double * B,
int * ldB,
int * info);
356void dgesvd_(
char * JU,
char * JV,
int * M,
int * N,
double * A,
int * ldA,
double * S,
357 double * U,
int * ldU,
double * VT,
int * ldVT,
double * WORK,
int * LWORK,
int * info);
359#define ytMatrix_dsytrf(UL,N,A,LA,IP,W,LW,IF) dsytrf_(UL,N,A,LA,IP,W,LW,IF)
360#define ytMatrix_dsytri(UL,N,A,LA,IP,W,IF) dsytri_(UL,N,A,LA,IP,W,IF)
361#define ytMatrix_dsytrs(UL,N,M,A,LA,IP,B,LB,IF) dsytrs_(UL,N,M,A,LA,IP,B,LB,IF)
362#define ytMatrix_dsyev(JB,UL,N,A,LA,W,WO,LW,IF) dsyev_(JB,UL,N,A,LA,W,WO,LW,IF)
363#define ytMatrix_dgesv(N,M,A,LDA,IP,B,LDB,IF) dgesv_(N,M,A,LDA,IP,B,LDB,IF)
364#define ytMatrix_dgetrf(M,N,A,LA,IP,IF) dgetrf_(M,N,A,LA,IP,IF)
365#define ytMatrix_dgetri(N,A,LA,IP,W,LW,IF) dgetri_(N,A,LA,IP,W,LW,IF)
366#define ytMatrix_dgetrs(TA,N,M,A,LA,IP,B,LB,IF) dgetrs_(TA,N,M,A,LA,IP,B,LB,IF)
367#define ytMatrix_dgesvd(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF) \
368 dgesvd_(JU,JV,M,N,A,LA,S,U,LU,VT,LVT,W,LW,IF)
int ytMatrix_dsytrf_work_size(int n)
Returns the optimal working memory size for dsytrf routine.
Definition ytMatrix.c:117
void ytMatrix_print(FILE *fp, const double *X, int m, int n, int N)
Prints the matrix.
Definition ytMatrix.c:162
void ytMatrix_printTrans(FILE *fp, const double *X, int m, int n, int N)
Prints the transposed or row-major matrix.
Definition ytMatrix.c:179
@ ytMatrix_L_NO_TRANS
No transpose.
Definition ytMatrix.c:90
@ ytMatrix_L_TRANS
Transpose.
Definition ytMatrix.c:93