LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / blas / common.h
blob2bf642c6b4d5d279502786895bb681b516374e6d
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 #ifndef EIGEN_BLAS_COMMON_H
11 #define EIGEN_BLAS_COMMON_H
13 #include <Eigen/Core>
14 #include <Eigen/Jacobi>
16 #include <iostream>
17 #include <complex>
19 #ifndef SCALAR
20 #error the token SCALAR must be defined to compile this file
21 #endif
23 #include <Eigen/src/misc/blas.h>
26 #define NOTR 0
27 #define TR 1
28 #define ADJ 2
30 #define LEFT 0
31 #define RIGHT 1
33 #define UP 0
34 #define LO 1
36 #define NUNIT 0
37 #define UNIT 1
39 #define INVALID 0xff
41 #define OP(X) ( ((X)=='N' || (X)=='n') ? NOTR \
42 : ((X)=='T' || (X)=='t') ? TR \
43 : ((X)=='C' || (X)=='c') ? ADJ \
44 : INVALID)
46 #define SIDE(X) ( ((X)=='L' || (X)=='l') ? LEFT \
47 : ((X)=='R' || (X)=='r') ? RIGHT \
48 : INVALID)
50 #define UPLO(X) ( ((X)=='U' || (X)=='u') ? UP \
51 : ((X)=='L' || (X)=='l') ? LO \
52 : INVALID)
54 #define DIAG(X) ( ((X)=='N' || (X)=='n') ? NUNIT \
55 : ((X)=='U' || (X)=='u') ? UNIT \
56 : INVALID)
59 inline bool check_op(const char* op)
61 return OP(*op)!=0xff;
64 inline bool check_side(const char* side)
66 return SIDE(*side)!=0xff;
69 inline bool check_uplo(const char* uplo)
71 return UPLO(*uplo)!=0xff;
75 namespace Eigen {
76 #include "BandTriangularSolver.h"
77 #include "GeneralRank1Update.h"
78 #include "PackedSelfadjointProduct.h"
79 #include "PackedTriangularMatrixVector.h"
80 #include "PackedTriangularSolverVector.h"
81 #include "Rank2Update.h"
84 using namespace Eigen;
86 typedef SCALAR Scalar;
87 typedef NumTraits<Scalar>::Real RealScalar;
88 typedef std::complex<RealScalar> Complex;
90 enum
92 IsComplex = Eigen::NumTraits<SCALAR>::IsComplex,
93 Conj = IsComplex
96 typedef Matrix<Scalar,Dynamic,Dynamic,ColMajor> PlainMatrixType;
97 typedef Map<Matrix<Scalar,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> > MatrixType;
98 typedef Map<Matrix<Scalar,Dynamic,1>, 0, InnerStride<Dynamic> > StridedVectorType;
99 typedef Map<Matrix<Scalar,Dynamic,1> > CompactVectorType;
101 template<typename T>
102 Map<Matrix<T,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> >
103 matrix(T* data, int rows, int cols, int stride)
105 return Map<Matrix<T,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> >(data, rows, cols, OuterStride<>(stride));
108 template<typename T>
109 Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> > vector(T* data, int size, int incr)
111 return Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> >(data, size, InnerStride<Dynamic>(incr));
114 template<typename T>
115 Map<Matrix<T,Dynamic,1> > vector(T* data, int size)
117 return Map<Matrix<T,Dynamic,1> >(data, size);
120 template<typename T>
121 T* get_compact_vector(T* x, int n, int incx)
123 if(incx==1)
124 return x;
126 T* ret = new Scalar[n];
127 if(incx<0) vector(ret,n) = vector(x,n,-incx).reverse();
128 else vector(ret,n) = vector(x,n, incx);
129 return ret;
132 template<typename T>
133 T* copy_back(T* x_cpy, T* x, int n, int incx)
135 if(x_cpy==x)
136 return 0;
138 if(incx<0) vector(x,n,-incx).reverse() = vector(x_cpy,n);
139 else vector(x,n, incx) = vector(x_cpy,n);
140 return x_cpy;
143 #define EIGEN_BLAS_FUNC(X) EIGEN_CAT(SCALAR_SUFFIX,X##_)
145 #endif // EIGEN_BLAS_COMMON_H