LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / blas / level2_cplx_impl.h
blobb850b6cd1b46b5dddbb2204e6c9a419cbaf91ea5
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
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/.
10 #include "common.h"
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;
25 if(!init)
27 for(int k=0; k<2; ++k)
28 func[k] = 0;
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);
33 init = true;
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);
42 // check arguments
43 int info = 0;
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;
49 if(info)
50 return xerbla_(SCALAR_SUFFIX_UP"HEMV ",&info,6);
52 if(*n==0)
53 return 1;
55 Scalar* actual_x = get_compact_vector(x,*n,*incx);
56 Scalar* actual_y = get_compact_vector(y,*n,*incy);
58 if(beta!=Scalar(1))
60 if(beta==Scalar(0)) vector(actual_y, *n).setZero();
61 else vector(actual_y, *n) *= beta;
64 if(alpha!=Scalar(0))
66 int code = UPLO(*uplo);
67 if(code>=2 || func[code]==0)
68 return 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);
76 return 1;
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)
88 // {
89 // return 1;
90 // }
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)
100 // {
101 // return 1;
102 // }
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;
117 if(!init)
119 for(int k=0; k<2; ++k)
120 func[k] = 0;
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);
125 init = true;
128 Scalar* x = reinterpret_cast<Scalar*>(px);
129 Scalar* ap = reinterpret_cast<Scalar*>(pap);
130 RealScalar alpha = *palpha;
132 int info = 0;
133 if(UPLO(*uplo)==INVALID) info = 1;
134 else if(*n<0) info = 2;
135 else if(*incx==0) info = 5;
136 if(info)
137 return xerbla_(SCALAR_SUFFIX_UP"HPR ",&info,6);
139 if(alpha==Scalar(0))
140 return 1;
142 Scalar* x_cpy = get_compact_vector(x, *n, *incx);
144 int code = UPLO(*uplo);
145 if(code>=2 || func[code]==0)
146 return 0;
148 func[code](*n, ap, x_cpy, alpha);
150 if(x_cpy!=x) delete[] x_cpy;
152 return 1;
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;
168 if(!init)
170 for(int k=0; k<2; ++k)
171 func[k] = 0;
173 func[UP] = (internal::packed_rank2_update_selector<Scalar,int,Upper>::run);
174 func[LO] = (internal::packed_rank2_update_selector<Scalar,int,Lower>::run);
176 init = true;
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);
184 int info = 0;
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;
189 if(info)
190 return xerbla_(SCALAR_SUFFIX_UP"HPR2 ",&info,6);
192 if(alpha==Scalar(0))
193 return 1;
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)
200 return 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;
207 return 1;
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;
223 if(!init)
225 for(int k=0; k<2; ++k)
226 func[k] = 0;
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);
231 init = true;
234 Scalar* x = reinterpret_cast<Scalar*>(px);
235 Scalar* a = reinterpret_cast<Scalar*>(pa);
236 RealScalar alpha = *reinterpret_cast<RealScalar*>(palpha);
238 int info = 0;
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;
243 if(info)
244 return xerbla_(SCALAR_SUFFIX_UP"HER ",&info,6);
246 if(alpha==RealScalar(0))
247 return 1;
249 Scalar* x_cpy = get_compact_vector(x, *n, *incx);
251 int code = UPLO(*uplo);
252 if(code>=2 || func[code]==0)
253 return 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;
261 return 1;
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;
277 if(!init)
279 for(int k=0; k<2; ++k)
280 func[k] = 0;
282 func[UP] = (internal::rank2_update_selector<Scalar,int,Upper>::run);
283 func[LO] = (internal::rank2_update_selector<Scalar,int,Lower>::run);
285 init = true;
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);
293 int info = 0;
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;
299 if(info)
300 return xerbla_(SCALAR_SUFFIX_UP"HER2 ",&info,6);
302 if(alpha==Scalar(0))
303 return 1;
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)
310 return 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;
319 return 1;
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);
336 int info = 0;
337 if(*m<0) info = 1;
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;
342 if(info)
343 return xerbla_(SCALAR_SUFFIX_UP"GERU ",&info,6);
345 if(alpha==Scalar(0))
346 return 1;
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;
356 return 1;
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);
373 int info = 0;
374 if(*m<0) info = 1;
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;
379 if(info)
380 return xerbla_(SCALAR_SUFFIX_UP"GERC ",&info,6);
382 if(alpha==Scalar(0))
383 return 1;
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;
393 return 1;