common.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2015 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/.
9 
10 #ifndef EIGEN_BLAS_COMMON_H
11 #define EIGEN_BLAS_COMMON_H
12 
13 #include "../Eigen/Core"
14 #include "../Eigen/Jacobi"
15 
16 #include <complex>
17 
18 #ifndef SCALAR
19 #error the token SCALAR must be defined to compile this file
20 #endif
21 
22 #include "../Eigen/src/misc/blas.h"
23 
24 #define NOTR 0
25 #define TR 1
26 #define ADJ 2
27 
28 #define LEFT 0
29 #define RIGHT 1
30 
31 #define UP 0
32 #define LO 1
33 
34 #define NUNIT 0
35 #define UNIT 1
36 
37 #define INVALID 0xff
38 
39 #define OP(X) ( ((X)=='N' || (X)=='n') ? NOTR \
40  : ((X)=='T' || (X)=='t') ? TR \
41  : ((X)=='C' || (X)=='c') ? ADJ \
42  : INVALID)
43 
44 #define SIDE(X) ( ((X)=='L' || (X)=='l') ? LEFT \
45  : ((X)=='R' || (X)=='r') ? RIGHT \
46  : INVALID)
47 
48 #define UPLO(X) ( ((X)=='U' || (X)=='u') ? UP \
49  : ((X)=='L' || (X)=='l') ? LO \
50  : INVALID)
51 
52 #define DIAG(X) ( ((X)=='N' || (X)=='n') ? NUNIT \
53  : ((X)=='U' || (X)=='u') ? UNIT \
54  : INVALID)
55 
56 
57 inline bool check_op(const char* op)
58 {
59  return OP(*op)!=0xff;
60 }
61 
62 inline bool check_side(const char* side)
63 {
64  return SIDE(*side)!=0xff;
65 }
66 
67 inline bool check_uplo(const char* uplo)
68 {
69  return UPLO(*uplo)!=0xff;
70 }
71 
72 
73 namespace Eigen {
74 #include "BandTriangularSolver.h"
75 #include "GeneralRank1Update.h"
79 #include "Rank2Update.h"
80 }
81 
82 using namespace Eigen;
83 
84 typedef SCALAR Scalar;
86 typedef std::complex<RealScalar> Complex;
87 
88 enum
89 {
92 };
93 
99 
100 template<typename T>
102 matrix(T* data, int rows, int cols, int stride)
103 {
104  return Map<Matrix<T,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> >(data, rows, cols, OuterStride<>(stride));
105 }
106 
107 template<typename T>
109 matrix(const T* data, int rows, int cols, int stride)
110 {
111  return Map<const Matrix<T,Dynamic,Dynamic,ColMajor>, 0, OuterStride<> >(data, rows, cols, OuterStride<>(stride));
112 }
113 
114 template<typename T>
116 {
118 }
119 
120 template<typename T>
122 {
124 }
125 
126 template<typename T>
128 {
129  return Map<Matrix<T,Dynamic,1> >(data, size);
130 }
131 
132 template<typename T>
134 {
135  return Map<const Matrix<T,Dynamic,1> >(data, size);
136 }
137 
138 template<typename T>
139 T* get_compact_vector(T* x, int n, int incx)
140 {
141  if(incx==1)
142  return x;
143 
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);
147  return ret;
148 }
149 
150 template<typename T>
151 T* copy_back(T* x_cpy, T* x, int n, int incx)
152 {
153  if(x_cpy==x)
154  return 0;
155 
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);
158  return x_cpy;
159 }
160 
161 #define EIGEN_BLAS_FUNC(X) EIGEN_CAT(SCALAR_SUFFIX,X##_)
162 
163 #endif // EIGEN_BLAS_COMMON_H
T * get_compact_vector(T *x, int n, int incx)
Definition: common.h:139
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:102
Matrix< Scalar, Dynamic, Dynamic, ColMajor > PlainMatrixType
Definition: common.h:94
Scalar * x
#define SCALAR
bool check_uplo(const char *uplo)
Definition: common.h:67
T * copy_back(T *x_cpy, T *x, int n, int incx)
Definition: common.h:151
std::complex< RealScalar > Complex
Definition: common.h:86
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
RealScalar RealScalar int * incx
Definition: common.h:73
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Map< Matrix< Scalar, Dynamic, 1 >, 0, InnerStride< Dynamic > > StridedVectorType
Definition: common.h:97
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
Map< const Matrix< Scalar, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > ConstMatrixType
Definition: common.h:96
#define OP(X)
Definition: common.h:39
NumTraits< Scalar >::Real RealScalar
Definition: common.h:85
Map< Matrix< Scalar, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > MatrixType
Definition: common.h:95
bool check_side(const char *side)
Definition: common.h:62
Convenience specialization of Stride to specify only an inner stride See class Map for some examples...
Definition: Stride.h:90
#define SIDE(X)
Definition: common.h:44
SCALAR Scalar
Definition: common.h:84
Map< Matrix< T, Dynamic, 1 >, 0, InnerStride< Dynamic > > make_vector(T *data, int size, int incr)
Definition: common.h:115
DenseIndex ret
Definition: level1_impl.h:59
Map< Matrix< Scalar, Dynamic, 1 > > CompactVectorType
Definition: common.h:98
Definition: common.h:91
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
PlainMatrixType mat * n
Definition: eigenvalues.cpp:41
bool check_op(const char *op)
Definition: common.h:57
#define UPLO(X)
Definition: common.h:48


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:06:46