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/.
10 #ifndef EIGEN_BLAS_COMMON_H
11 #define EIGEN_BLAS_COMMON_H
14 #include <Eigen/Jacobi>
20 #error the token SCALAR must be defined to compile this file
23 #include <Eigen/src/misc/blas.h>
41 #define OP(X) ( ((X)=='N' || (X)=='n') ? NOTR \
42 : ((X)=='T' || (X)=='t') ? TR \
43 : ((X)=='C' || (X)=='c') ? ADJ \
46 #define SIDE(X) ( ((X)=='L' || (X)=='l') ? LEFT \
47 : ((X)=='R' || (X)=='r') ? RIGHT \
50 #define UPLO(X) ( ((X)=='U' || (X)=='u') ? UP \
51 : ((X)=='L' || (X)=='l') ? LO \
54 #define DIAG(X) ( ((X)=='N' || (X)=='n') ? NUNIT \
55 : ((X)=='U' || (X)=='u') ? UNIT \
59 inline bool check_op(const char* op
)
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;
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
;
92 IsComplex
= Eigen::NumTraits
<SCALAR
>::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
;
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
));
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
));
115 Map
<Matrix
<T
,Dynamic
,1> > vector(T
* data
, int size
)
117 return Map
<Matrix
<T
,Dynamic
,1> >(data
, size
);
121 T
* get_compact_vector(T
* x
, int n
, int incx
)
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
);
133 T
* copy_back(T
* x_cpy
, T
* x
, int n
, int incx
)
138 if(incx
<0) vector(x
,n
,-incx
).reverse() = vector(x_cpy
,n
);
139 else vector(x
,n
, incx
) = vector(x_cpy
,n
);
143 #define EIGEN_BLAS_FUNC(X) EIGEN_CAT(SCALAR_SUFFIX,X##_)
145 #endif // EIGEN_BLAS_COMMON_H