1 // This file is part of Eigen, a lightweight C++ template library
4 // Copyright (C) 2009-2015 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
13 #include "../Eigen/Core"
14 #include "../Eigen/Jacobi"
19 #error the token SCALAR must be defined to compile this file
22 #include "../Eigen/src/misc/blas.h"
39 #define OP(X) ( ((X)=='N' || (X)=='n') ? NOTR \
40 : ((X)=='T' || (X)=='t') ? TR \
41 : ((X)=='C' || (X)=='c') ? ADJ \
44 #define SIDE(X) ( ((X)=='L' || (X)=='l') ? LEFT \
45 : ((X)=='R' || (X)=='r') ? RIGHT \
48 #define UPLO(X) ( ((X)=='U' || (X)=='u') ? UP \
49 : ((X)=='L' || (X)=='l') ? LO \
52 #define DIAG(X) ( ((X)=='N' || (X)=='n') ? NUNIT \
53 : ((X)=='U' || (X)=='u') ? UNIT \
57 inline bool check_op(const char* op
)
62 inline bool check_side(const char* side
)
64 return SIDE(*side
)!=0xff;
67 inline bool check_uplo(const char* uplo
)
69 return UPLO(*uplo
)!=0xff;
74 #include "BandTriangularSolver.h"
75 #include "GeneralRank1Update.h"
76 #include "PackedSelfadjointProduct.h"
77 #include "PackedTriangularMatrixVector.h"
78 #include "PackedTriangularSolverVector.h"
79 #include "Rank2Update.h"
82 using namespace Eigen
;
84 typedef SCALAR Scalar
;
85 typedef NumTraits
<Scalar
>::Real RealScalar
;
86 typedef std::complex<RealScalar
> Complex
;
90 IsComplex
= Eigen::NumTraits
<SCALAR
>::IsComplex
,
94 typedef Matrix
<Scalar
,Dynamic
,Dynamic
,ColMajor
> PlainMatrixType
;
95 typedef Map
<Matrix
<Scalar
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> > MatrixType
;
96 typedef Map
<const Matrix
<Scalar
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> > ConstMatrixType
;
97 typedef Map
<Matrix
<Scalar
,Dynamic
,1>, 0, InnerStride
<Dynamic
> > StridedVectorType
;
98 typedef Map
<Matrix
<Scalar
,Dynamic
,1> > CompactVectorType
;
101 Map
<Matrix
<T
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> >
102 matrix(T
* data
, int rows
, int cols
, int stride
)
104 return Map
<Matrix
<T
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> >(data
, rows
, cols
, OuterStride
<>(stride
));
108 Map
<const Matrix
<T
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> >
109 matrix(const T
* data
, int rows
, int cols
, int stride
)
111 return Map
<const Matrix
<T
,Dynamic
,Dynamic
,ColMajor
>, 0, OuterStride
<> >(data
, rows
, cols
, OuterStride
<>(stride
));
115 Map
<Matrix
<T
,Dynamic
,1>, 0, InnerStride
<Dynamic
> > make_vector(T
* data
, int size
, int incr
)
117 return Map
<Matrix
<T
,Dynamic
,1>, 0, InnerStride
<Dynamic
> >(data
, size
, InnerStride
<Dynamic
>(incr
));
121 Map
<const Matrix
<T
,Dynamic
,1>, 0, InnerStride
<Dynamic
> > make_vector(const T
* data
, int size
, int incr
)
123 return Map
<const Matrix
<T
,Dynamic
,1>, 0, InnerStride
<Dynamic
> >(data
, size
, InnerStride
<Dynamic
>(incr
));
127 Map
<Matrix
<T
,Dynamic
,1> > make_vector(T
* data
, int size
)
129 return Map
<Matrix
<T
,Dynamic
,1> >(data
, size
);
133 Map
<const Matrix
<T
,Dynamic
,1> > make_vector(const T
* data
, int size
)
135 return Map
<const Matrix
<T
,Dynamic
,1> >(data
, size
);
139 T
* get_compact_vector(T
* x
, int n
, int incx
)
144 typename
Eigen::internal::remove_const
<T
>::type
* ret
= new Scalar
[n
];
145 if(incx
<0) make_vector(ret
,n
) = make_vector(x
,n
,-incx
).reverse();
146 else make_vector(ret
,n
) = make_vector(x
,n
, incx
);
151 T
* copy_back(T
* x_cpy
, T
* x
, int n
, int incx
)
156 if(incx
<0) make_vector(x
,n
,-incx
).reverse() = make_vector(x_cpy
,n
);
157 else make_vector(x
,n
, incx
) = make_vector(x_cpy
,n
);
161 #define EIGEN_BLAS_FUNC(X) EIGEN_CAT(SCALAR_SUFFIX,X##_)
163 #endif // EIGEN_BLAS_COMMON_H