1 // This file is part of Eigen, a lightweight C++ template library
4 // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 /** ZHEMV performs the matrix-vector operation
14 * y := alpha*A*x + beta*y,
16 * where alpha and beta are scalars, x and y are n element vectors and
17 * A is an n by n hermitian matrix.
19 int EIGEN_BLAS_FUNC(hemv
)(char *uplo
, int *n
, RealScalar
*palpha
, RealScalar
*pa
, int *lda
, RealScalar
*px
, int *incx
, RealScalar
*pbeta
, RealScalar
*py
, int *incy
)
21 typedef void (*functype
)(int, const Scalar
*, int, const Scalar
*, int, Scalar
*, Scalar
);
22 static functype func
[2];
24 static bool init
= false;
27 for(int k
=0; k
<2; ++k
)
30 func
[UP
] = (internal::selfadjoint_matrix_vector_product
<Scalar
,int,ColMajor
,Upper
,false,false>::run
);
31 func
[LO
] = (internal::selfadjoint_matrix_vector_product
<Scalar
,int,ColMajor
,Lower
,false,false>::run
);
36 Scalar
* a
= reinterpret_cast<Scalar
*>(pa
);
37 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
38 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
39 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
40 Scalar beta
= *reinterpret_cast<Scalar
*>(pbeta
);
44 if(UPLO(*uplo
)==INVALID
) info
= 1;
45 else if(*n
<0) info
= 2;
46 else if(*lda
<std::max(1,*n
)) info
= 5;
47 else if(*incx
==0) info
= 7;
48 else if(*incy
==0) info
= 10;
50 return xerbla_(SCALAR_SUFFIX_UP
"HEMV ",&info
,6);
55 Scalar
* actual_x
= get_compact_vector(x
,*n
,*incx
);
56 Scalar
* actual_y
= get_compact_vector(y
,*n
,*incy
);
60 if(beta
==Scalar(0)) vector(actual_y
, *n
).setZero();
61 else vector(actual_y
, *n
) *= beta
;
66 int code
= UPLO(*uplo
);
67 if(code
>=2 || func
[code
]==0)
70 func
[code
](*n
, a
, *lda
, actual_x
, 1, actual_y
, alpha
);
73 if(actual_x
!=x
) delete[] actual_x
;
74 if(actual_y
!=y
) delete[] copy_back(actual_y
,y
,*n
,*incy
);
79 /** ZHBMV performs the matrix-vector operation
81 * y := alpha*A*x + beta*y,
83 * where alpha and beta are scalars, x and y are n element vectors and
84 * A is an n by n hermitian band matrix, with k super-diagonals.
86 // int EIGEN_BLAS_FUNC(hbmv)(char *uplo, int *n, int *k, RealScalar *alpha, RealScalar *a, int *lda,
87 // RealScalar *x, int *incx, RealScalar *beta, RealScalar *y, int *incy)
92 /** ZHPMV performs the matrix-vector operation
94 * y := alpha*A*x + beta*y,
96 * where alpha and beta are scalars, x and y are n element vectors and
97 * A is an n by n hermitian matrix, supplied in packed form.
99 // int EIGEN_BLAS_FUNC(hpmv)(char *uplo, int *n, RealScalar *alpha, RealScalar *ap, RealScalar *x, int *incx, RealScalar *beta, RealScalar *y, int *incy)
104 /** ZHPR performs the hermitian rank 1 operation
106 * A := alpha*x*conjg( x' ) + A,
108 * where alpha is a real scalar, x is an n element vector and A is an
109 * n by n hermitian matrix, supplied in packed form.
111 int EIGEN_BLAS_FUNC(hpr
)(char *uplo
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*pap
)
113 typedef void (*functype
)(int, Scalar
*, const Scalar
*, RealScalar
);
114 static functype func
[2];
116 static bool init
= false;
119 for(int k
=0; k
<2; ++k
)
122 func
[UP
] = (internal::selfadjoint_packed_rank1_update
<Scalar
,int,ColMajor
,Upper
,false,Conj
>::run
);
123 func
[LO
] = (internal::selfadjoint_packed_rank1_update
<Scalar
,int,ColMajor
,Lower
,false,Conj
>::run
);
128 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
129 Scalar
* ap
= reinterpret_cast<Scalar
*>(pap
);
130 RealScalar alpha
= *palpha
;
133 if(UPLO(*uplo
)==INVALID
) info
= 1;
134 else if(*n
<0) info
= 2;
135 else if(*incx
==0) info
= 5;
137 return xerbla_(SCALAR_SUFFIX_UP
"HPR ",&info
,6);
142 Scalar
* x_cpy
= get_compact_vector(x
, *n
, *incx
);
144 int code
= UPLO(*uplo
);
145 if(code
>=2 || func
[code
]==0)
148 func
[code
](*n
, ap
, x_cpy
, alpha
);
150 if(x_cpy
!=x
) delete[] x_cpy
;
155 /** ZHPR2 performs the hermitian rank 2 operation
157 * A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
159 * where alpha is a scalar, x and y are n element vectors and A is an
160 * n by n hermitian matrix, supplied in packed form.
162 int EIGEN_BLAS_FUNC(hpr2
)(char *uplo
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
, RealScalar
*pap
)
164 typedef void (*functype
)(int, Scalar
*, const Scalar
*, const Scalar
*, Scalar
);
165 static functype func
[2];
167 static bool init
= false;
170 for(int k
=0; k
<2; ++k
)
173 func
[UP
] = (internal::packed_rank2_update_selector
<Scalar
,int,Upper
>::run
);
174 func
[LO
] = (internal::packed_rank2_update_selector
<Scalar
,int,Lower
>::run
);
179 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
180 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
181 Scalar
* ap
= reinterpret_cast<Scalar
*>(pap
);
182 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
185 if(UPLO(*uplo
)==INVALID
) info
= 1;
186 else if(*n
<0) info
= 2;
187 else if(*incx
==0) info
= 5;
188 else if(*incy
==0) info
= 7;
190 return xerbla_(SCALAR_SUFFIX_UP
"HPR2 ",&info
,6);
195 Scalar
* x_cpy
= get_compact_vector(x
, *n
, *incx
);
196 Scalar
* y_cpy
= get_compact_vector(y
, *n
, *incy
);
198 int code
= UPLO(*uplo
);
199 if(code
>=2 || func
[code
]==0)
202 func
[code
](*n
, ap
, x_cpy
, y_cpy
, alpha
);
204 if(x_cpy
!=x
) delete[] x_cpy
;
205 if(y_cpy
!=y
) delete[] y_cpy
;
210 /** ZHER performs the hermitian rank 1 operation
212 * A := alpha*x*conjg( x' ) + A,
214 * where alpha is a real scalar, x is an n element vector and A is an
215 * n by n hermitian matrix.
217 int EIGEN_BLAS_FUNC(her
)(char *uplo
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*pa
, int *lda
)
219 typedef void (*functype
)(int, Scalar
*, int, const Scalar
*, const Scalar
*, const Scalar
&);
220 static functype func
[2];
222 static bool init
= false;
225 for(int k
=0; k
<2; ++k
)
228 func
[UP
] = (selfadjoint_rank1_update
<Scalar
,int,ColMajor
,Upper
,false,Conj
>::run
);
229 func
[LO
] = (selfadjoint_rank1_update
<Scalar
,int,ColMajor
,Lower
,false,Conj
>::run
);
234 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
235 Scalar
* a
= reinterpret_cast<Scalar
*>(pa
);
236 RealScalar alpha
= *reinterpret_cast<RealScalar
*>(palpha
);
239 if(UPLO(*uplo
)==INVALID
) info
= 1;
240 else if(*n
<0) info
= 2;
241 else if(*incx
==0) info
= 5;
242 else if(*lda
<std::max(1,*n
)) info
= 7;
244 return xerbla_(SCALAR_SUFFIX_UP
"HER ",&info
,6);
246 if(alpha
==RealScalar(0))
249 Scalar
* x_cpy
= get_compact_vector(x
, *n
, *incx
);
251 int code
= UPLO(*uplo
);
252 if(code
>=2 || func
[code
]==0)
255 func
[code
](*n
, a
, *lda
, x_cpy
, x_cpy
, alpha
);
257 matrix(a
,*n
,*n
,*lda
).diagonal().imag().setZero();
259 if(x_cpy
!=x
) delete[] x_cpy
;
264 /** ZHER2 performs the hermitian rank 2 operation
266 * A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
268 * where alpha is a scalar, x and y are n element vectors and A is an n
269 * by n hermitian matrix.
271 int EIGEN_BLAS_FUNC(her2
)(char *uplo
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
, RealScalar
*pa
, int *lda
)
273 typedef void (*functype
)(int, Scalar
*, int, const Scalar
*, const Scalar
*, Scalar
);
274 static functype func
[2];
276 static bool init
= false;
279 for(int k
=0; k
<2; ++k
)
282 func
[UP
] = (internal::rank2_update_selector
<Scalar
,int,Upper
>::run
);
283 func
[LO
] = (internal::rank2_update_selector
<Scalar
,int,Lower
>::run
);
288 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
289 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
290 Scalar
* a
= reinterpret_cast<Scalar
*>(pa
);
291 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
294 if(UPLO(*uplo
)==INVALID
) info
= 1;
295 else if(*n
<0) info
= 2;
296 else if(*incx
==0) info
= 5;
297 else if(*incy
==0) info
= 7;
298 else if(*lda
<std::max(1,*n
)) info
= 9;
300 return xerbla_(SCALAR_SUFFIX_UP
"HER2 ",&info
,6);
305 Scalar
* x_cpy
= get_compact_vector(x
, *n
, *incx
);
306 Scalar
* y_cpy
= get_compact_vector(y
, *n
, *incy
);
308 int code
= UPLO(*uplo
);
309 if(code
>=2 || func
[code
]==0)
312 func
[code
](*n
, a
, *lda
, x_cpy
, y_cpy
, alpha
);
314 matrix(a
,*n
,*n
,*lda
).diagonal().imag().setZero();
316 if(x_cpy
!=x
) delete[] x_cpy
;
317 if(y_cpy
!=y
) delete[] y_cpy
;
322 /** ZGERU performs the rank 1 operation
324 * A := alpha*x*y' + A,
326 * where alpha is a scalar, x is an m element vector, y is an n element
327 * vector and A is an m by n matrix.
329 int EIGEN_BLAS_FUNC(geru
)(int *m
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
, RealScalar
*pa
, int *lda
)
331 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
332 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
333 Scalar
* a
= reinterpret_cast<Scalar
*>(pa
);
334 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
338 else if(*n
<0) info
= 2;
339 else if(*incx
==0) info
= 5;
340 else if(*incy
==0) info
= 7;
341 else if(*lda
<std::max(1,*m
)) info
= 9;
343 return xerbla_(SCALAR_SUFFIX_UP
"GERU ",&info
,6);
348 Scalar
* x_cpy
= get_compact_vector(x
,*m
,*incx
);
349 Scalar
* y_cpy
= get_compact_vector(y
,*n
,*incy
);
351 internal::general_rank1_update
<Scalar
,int,ColMajor
,false,false>::run(*m
, *n
, a
, *lda
, x_cpy
, y_cpy
, alpha
);
353 if(x_cpy
!=x
) delete[] x_cpy
;
354 if(y_cpy
!=y
) delete[] y_cpy
;
359 /** ZGERC performs the rank 1 operation
361 * A := alpha*x*conjg( y' ) + A,
363 * where alpha is a scalar, x is an m element vector, y is an n element
364 * vector and A is an m by n matrix.
366 int EIGEN_BLAS_FUNC(gerc
)(int *m
, int *n
, RealScalar
*palpha
, RealScalar
*px
, int *incx
, RealScalar
*py
, int *incy
, RealScalar
*pa
, int *lda
)
368 Scalar
* x
= reinterpret_cast<Scalar
*>(px
);
369 Scalar
* y
= reinterpret_cast<Scalar
*>(py
);
370 Scalar
* a
= reinterpret_cast<Scalar
*>(pa
);
371 Scalar alpha
= *reinterpret_cast<Scalar
*>(palpha
);
375 else if(*n
<0) info
= 2;
376 else if(*incx
==0) info
= 5;
377 else if(*incy
==0) info
= 7;
378 else if(*lda
<std::max(1,*m
)) info
= 9;
380 return xerbla_(SCALAR_SUFFIX_UP
"GERC ",&info
,6);
385 Scalar
* x_cpy
= get_compact_vector(x
,*m
,*incx
);
386 Scalar
* y_cpy
= get_compact_vector(y
,*n
,*incy
);
388 internal::general_rank1_update
<Scalar
,int,ColMajor
,false,Conj
>::run(*m
, *n
, a
, *lda
, x_cpy
, y_cpy
, alpha
);
390 if(x_cpy
!=x
) delete[] x_cpy
;
391 if(y_cpy
!=y
) delete[] y_cpy
;