22 #ifdef _LA_VECTOR_DOUBLE_H_ 24 inline LaVectorDouble operator*(
const LaVectorDouble &x,
double a)
29 for (
int i=0; i<N; i++)
37 inline LaVectorDouble operator*(
double a,
const LaVectorDouble &x)
39 return operator*(x,a);
42 inline double operator*(
const LaVectorDouble &dx,
43 const LaVectorDouble &dy)
45 assert(dx.size()==dy.size());
46 integer incx = dx.inc(), incy = dy.inc(), n = dx.size();
48 return F77NAME(
ddot)(&n, &dx(0), &incx, &dy(0), &incy);
51 inline LaVectorDouble operator+(
const LaVectorDouble &dx,
52 const LaVectorDouble &dy)
54 assert(dx.size()==dy.size());
55 integer incx = dx.inc(), incy = dx.inc(), n = dx.size();
58 LaVectorDouble tmp((
int) n);
65 inline LaVectorDouble operator-(
const LaVectorDouble &dx,
66 const LaVectorDouble &dy)
68 assert(dx.size()==dy.size());
69 integer incx = dx.inc(), incy = dy.inc(), n = dx.size();
72 LaVectorDouble tmp(n);
83 #ifdef _LA_GEN_MAT_DOUBLE_H_ 84 inline LaVectorDouble operator*(
const LaGenMatDouble &A,
85 const LaVectorDouble &dx)
88 double alpha = 1.0, beta = 0.0;
89 integer M = A.size(0), N = A.size(1), lda = A.gdim(0);
97 F77NAME(
dgemv)(&trans, &M, &N, &alpha, &A(0,0), &lda, &dx(0), &incx,
98 &beta, &dy(0), &incy);
104 #ifdef _LA_BAND_MAT_DOUBLE_H_ 105 inline LaVectorDouble operator*(
const LaBandMatDouble &A,
106 const LaVectorDouble &dx)
109 double alpha = 1.0, beta = 0.0;
110 integer M = A.size(0), N = A.size(1), lda = A.gdim(0),
111 kl = A.subdiags(), ku = A.superdiags();
113 LaVectorDouble dy(N);
114 integer incx = dx.inc(), incy = dy.inc();
116 F77NAME(
dgbmv)(&trans, &M, &N, &kl, &ku, &alpha, &A(0,0), &lda,
117 &dx(0), &incx, &beta, &dy(0), &incy);
122 #ifdef _LA_SYMM_MAT_DOUBLE_H_ 123 inline LaVectorDouble operator*(
const LaSymmMatDouble &A,
124 const LaVectorDouble &dx)
127 double alpha = 1.0, beta = 0.0;
128 integer N = A.size(1), lda = A.gdim(0);
130 LaVectorDouble dy(N);
131 integer incx = dx.inc(), incy = dy.inc();
133 F77NAME(
dsymv)(&uplo, &N, &alpha, &A(0,0), &lda, &dx(0), &incx,
134 &beta, &dy(0), &incy);
139 #ifdef _LA_SYMM_BAND_MAT_DOUBLE_H_ 140 inline LaVectorDouble operator*(
const LaSymmBandMatDouble &A,
141 const LaVectorDouble &dx)
144 double alpha = 1.0, beta = 0.0;
145 integer N = A.size(1), lda = A.gdim(0), k = A.subdiags();
147 LaVectorDouble dy(N);
148 integer incx = dx.inc(), incy = dy.inc();
150 F77NAME(
dsbmv)(&uplo, &N, &k, &alpha, &A(0,0), &lda, &dx(0), &incx,
151 &beta, &dy(0), &incy);
158 #ifdef _LA_SPD_MAT_DOUBLE_H_ 159 inline LaVectorDouble operator*(
const LaSpdMatDouble &AP,
160 const LaVectorDouble &dx)
163 double alpha = 1.0, beta = 0.0;
164 integer N = AP.size(1), incx = dx.inc();
167 LaVectorDouble dy(N);
170 F77NAME(
dsymv)(&uplo, &N, &alpha, &AP(0,0), &lda, &dx(0), &incx, &beta,
176 #ifdef _LA_LOWER_TRIANG_MAT_DOUBLE_H_ 177 inline LaVectorDouble operator*(
const LaLowerTriangMatDouble &A,
178 const LaVectorDouble &dx)
180 char uplo =
'L', trans =
'N', diag =
'N';
181 integer N = A.size(1), lda = A.gdim(0),
184 LaVectorDouble dy(dx);
186 F77NAME(
dtrmv)(&uplo, &trans, &diag, &N, &A(0,0), &lda, &dy(0), &incx);
192 #ifdef _LA_UPPER_TRIANG_MAT_DOUBLE_H_ 193 inline LaVectorDouble operator*(
const LaUpperTriangMatDouble &A,
194 const LaVectorDouble &dx)
196 char uplo =
'U', trans =
'N', diag =
'N';
197 integer N = A.size(1), lda = A.gdim(0),
200 LaVectorDouble dy(dx);
202 F77NAME(
dtrmv)(&uplo, &trans, &diag, &N, &A(0,0), &lda, &dy(0), &incx);
208 #ifdef _LA_UNIT_LOWER_TRIANG_MAT_DOUBLE_H_ 209 inline LaVectorDouble operator*(
const LaUnitLowerTriangMatDouble &A,
210 const LaVectorDouble &dx)
212 char uplo =
'L', trans =
'N', diag =
'U';
213 integer N = A.size(1), lda = A.gdim(0),
216 LaVectorDouble dy(dx);
218 F77NAME(
dtrmv)(&uplo, &trans, &diag, &N, &A(0,0), &lda, &dy(0), &incx);
225 #ifdef _LA_UNIT_UPPER_TRIANG_MAT_DOUBLE_H_ 226 inline LaVectorDouble operator*(
const LaUnitUpperTriangMatDouble &A,
227 const LaVectorDouble &dx)
229 char uplo =
'U', trans =
'N', diag =
'U';
230 integer N = A.size(1), lda = A.gdim(0),
233 LaVectorDouble dy(dx);
235 F77NAME(
dtrmv)(&uplo, &trans, &diag, &N, &A(0,0), &lda, &dy(0), &incx);
246 inline LaGenMatDouble operator*(
const LaGenMatDouble &A,
247 const LaGenMatDouble &B)
250 integer m = A.size(0), k = A.size(1), n = B.size(1);
251 integer lda = A.gdim(0), ldb = B.gdim(0);
252 double alpha = 1.0, beta = 1.0;
254 LaGenMatDouble C(m,n);
259 F77NAME(
dgemm)(&t, &t, &m, &n, &k, &alpha, &A(0,0), &lda, &B(0,0), &ldb,
260 &beta, &C(0,0), &ldc);
265 #ifdef _LA_UNIT_LOWER_TRIANG_MAT_DOUBLE_H_ 266 inline LaGenMatDouble operator*(
const LaUnitLowerTriangMatDouble &A,
267 const LaGenMatDouble &B)
269 char side =
'L', uplo =
'L', transa =
'N', diag =
'U';
271 integer m = B.size(0), n = B.size(1),
272 lda = A.gdim(0), ldb = B.gdim(0);
276 F77NAME(
dtrmm)(&side, &uplo, &transa, &diag, &m, &n, &alpha,
277 &A(0,0), &lda, &C(0,0), &ldb);
283 #ifdef _LA_UNIT_UPPER_TRIANG_MAT_DOUBLE_H_ 284 inline LaGenMatDouble operator*(
const LaUnitUpperTriangMatDouble &A,
285 const LaGenMatDouble &B)
287 char side =
'L', uplo =
'U', transa =
'N', diag =
'U';
289 integer m = B.size(0), n = B.size(1),
290 lda = A.gdim(0), ldb = B.gdim(0);
294 F77NAME(
dtrmm)(&side, &uplo, &transa, &diag, &m, &n, &alpha,
295 &A(0,0), &lda, &C(0,0), &ldb);
301 #ifdef _LA_LOWER_TRIANG_MAT_DOUBLE_H_ 302 inline LaGenMatDouble operator*(
const LaLowerTriangMatDouble &A,
303 const LaGenMatDouble &B)
305 char side =
'L', uplo =
'L', transa =
'N', diag =
'N';
307 integer m = B.size(0), n = B.size(1),
308 lda = A.gdim(0), ldb = B.gdim(0);
312 F77NAME(
dtrmm)(&side, &uplo, &transa, &diag, &m, &n, &alpha,
313 &A(0,0), &lda, &C(0,0), &ldb);
319 #ifdef _LA_UPPER_TRIANG_MAT_DOUBLE_H_ 320 inline LaGenMatDouble operator*(
const LaUpperTriangMatDouble &A,
321 const LaGenMatDouble &B)
323 char side =
'L', uplo =
'U', transa =
'N', diag =
'N';
325 integer m = B.size(0), n = B.size(1),
326 lda = A.gdim(0), ldb = B.gdim(0);
330 F77NAME(
dtrmm)(&side, &uplo, &transa, &diag, &m, &n, &alpha,
331 &A(0,0), &lda, &C(0,0), &ldb);
337 #ifdef _LA_SYMM_MAT_DOUBLE_H_ 338 inline LaGenMatDouble operator*(
const LaSymmMatDouble &A,
339 const LaGenMatDouble &B)
341 char side =
'L', uplo =
'L';
342 double alpha = 1.0, beta = 1.0;
343 LaGenMatDouble C(B.size(1),A.size(1));
344 integer m = C.size(0), n = C.size(1), lda = A.gdim(0),
345 ldb = B.gdim(0), ldc = C.gdim(0);
347 F77NAME(
dsymm)(&side, &uplo, &m, &n, &alpha, &A(0,0), &lda,
348 &B(0,0), &ldb, &beta, &C(0,0), &ldc);
354 #ifdef _LA_SYMM_TRIDIAG_MAT_DOUBLE_H_ 355 inline LaVectorDouble operator*(
const LaSymmTridiagMatDouble& A,
356 const LaVectorDouble& X)
362 R(0) = ((A.diag(0)(0) * X(0)) + (A.diag(-1)(0) * X(1)));
364 for (
integer i = 1; i < M-2; i++)
366 R(i) = ((A.diag(-1)(i-1) * X(i-1)) +
367 (A.diag(0)(i) * X(i)) +
368 (A.diag(-1)(i) * X(i+1)));
371 R(M-1) = ((A.diag(0)(M-1) * X(N-1)) + (A.diag(-1)(M-2) * X(N-2)));
377 #ifdef _LA_TRIDIAG_MAT_DOUBLE_H_ 378 inline LaVectorDouble operator*(
const LaTridiagMatDouble& A,
379 const LaVectorDouble& X)
385 R(0) = ((A.diag(0)(0) * X(0)) + (A.diag(-1)(0) * X(1)));
387 for (
integer i = 1; i < M-2; i++)
389 R(i) = ((A.diag(-1)(i-1) * X(i-1)) +
390 (A.diag(0)(i) * X(i)) +
391 (A.diag(1)(i) * X(i+1)));
394 R(M-1) = ((A.diag(0)(M-1) * X(N-1)) + (A.diag(1)(M-2) * X(N-2)));
400 inline LaGenMatDouble operator-(
const LaGenMatDouble &A,
401 const LaGenMatDouble &B)
404 const char fname[] =
"operator+(A,B)";
412 if (M != B.size(0) || N != B.size(1))
414 throw(LaException(fname,
"matrices non-conformant."));
417 LaGenMatDouble C(M,N);
424 C(i,j) = A(i,j) - B(i,j);
429 inline LaGenMatDouble operator+(
const LaGenMatDouble &A,
430 const LaGenMatDouble &B)
433 const char fname[] =
"operator+(A,B)";
441 if (M != B.size(0) || N != B.size(1))
443 throw(LaException(fname,
"matrices non-conformant."));
446 LaGenMatDouble C(M,N);
453 C(i,j) = A(i,j) + B(i,j);
463 inline double Norm_Inf(
const LaVectorDouble &x)
466 integer index = Blas_Index_Max(x);
467 return abs(x(index));
470 inline double Norm_Inf(
const LaGenMatDouble &A)
480 R(i) = Blas_Norm1( A( i, LaIndex() ));
482 index = Blas_Index_Max(R);
486 #ifdef _LA_BAND_MAT_DOUBLE_H_ 487 inline double Norm_Inf(
const LaBandMatDouble &A)
489 integer kl = A.subdiags(), ku = A.superdiags();
509 if (R(i) > max) max=R(i);
515 #ifdef _LA_SYMM_MAT_DOUBLE_H_ 516 inline double Norm_Inf(
const LaSymmMatDouble &S)
537 if (R(i) > max) max=R(i);
543 #ifdef _LA_SPD_MAT_DOUBLE_H_ 544 inline double Norm_Inf(
const LaSpdMatDouble &S)
565 if (R(i) > max) max=R(i);
571 #ifdef _LA_SYMM_TRIDIAG_MAT_DOUBLE_H_ 572 inline double Norm_Inf(
const LaSymmTridiagMatDouble &S)
577 R(0) =
abs(S(0,0)) +
abs(S(0,1));
581 R(i) =
abs(S(i,i-1)) +
abs(S(i,i)) +
abs(S(i,i+1));
584 R(N-1) =
abs(S(N-1,N-2)) +
abs(S(N-1,N-1));
590 #ifdef _LA_TRIDIAG_MAT_DOUBLE_H_ 591 inline double Norm_Inf(
const LaTridiagMatDouble &T)
596 R(0) =
abs(T(0,0)) +
abs(T(0,1));
598 for (
int i=1; i<N-1; i++)
600 R(i) =
abs(T(i,i-1)) +
abs(T(i,i)) +
abs(T(i,i+1));
603 R(N-1) =
abs(T(N-1,N-2)) +
abs(T(N-1,N-1));
void F77NAME() dgemv(char *trans, integer *M, integer *N, double *alpha, const double *A, integer *lda, const double *dx, integer *incx, double *beta, double *dy, integer *incy)
void F77NAME() dtrmm(char *side, char *uplo, char *transa, char *diag, integer *m, integer *n, double *alpha, const double *A, integer *lda, const double *B, integer *ldb)
void F77NAME() daxpy(const integer *n, const double *da, const double *dx, const integer *incx, double *dy, const integer *incy)
void F77NAME() dgemm(char *transa, char *transb, integer *m, integer *n, integer *k, double *alpha, const double *a, integer *lda, const double *b, integer *ldb, double *beta, double *c, integer *ldc)
void F77NAME() dtrmv(char *uplo, char *trans, char *diag, const integer *N, const double *A, integer *lda, const double *dx, integer *incx)
void F77NAME() dsbmv(char *uplo, integer *N, integer *k, double *alpha, const double *A, integer *lda, const double *dx, integer *incx, double *beta, double *dy, integer *incy)
void F77NAME() dsymv(char *uplo, integer *N, double *alpha, const double *A, integer *lda, const double *dx, integer *incx, double *beta, double *dy, integer *incy)
void F77NAME() dgbmv(char *trans, integer *M, integer *N, integer *kl, integer *ku, double *alpha, const double *A, integer *lda, const double *dx, integer *incx, double *beta, double *dy, integer *incy)
void F77NAME() dsymm(char *side, char *uplo, integer *m, integer *n, double *alpha, const double *A, integer *lda, const double *B, integer *ldb, double *beta, double *C, integer *ldc)
double F77NAME() ddot(const integer *n, const double *dx, const integer *incx, const double *dy, const integer *incy)