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 #ifdef __GNUC__
14 #if __GNUC__ < 5
15 // GCC < 5.0 does not like the global Scalar typedef
16 // we just keep shadow-warnings disabled permanently
17 #define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
18 #endif
19 #endif
20 
21 #include "../Eigen/Core"
22 #include "../Eigen/Jacobi"
23 
24 #include <complex>
25 
26 #ifndef SCALAR
27 #error the token SCALAR must be defined to compile this file
28 #endif
29 
30 #include "blas.h"
31 
32 #include "BandTriangularSolver.h"
33 #include "GeneralRank1Update.h"
37 #include "Rank2Update.h"
38 
39 #define NOTR 0
40 #define TR 1
41 #define ADJ 2
42 
43 #define LEFT 0
44 #define RIGHT 1
45 
46 #define UP 0
47 #define LO 1
48 
49 #define NUNIT 0
50 #define UNIT 1
51 
52 #define INVALID 0xff
53 
54 #define OP(X) \
55  (((X) == 'N' || (X) == 'n') ? NOTR : ((X) == 'T' || (X) == 't') ? TR : ((X) == 'C' || (X) == 'c') ? ADJ : INVALID)
56 
57 #define SIDE(X) (((X) == 'L' || (X) == 'l') ? LEFT : ((X) == 'R' || (X) == 'r') ? RIGHT : INVALID)
58 
59 #define UPLO(X) (((X) == 'U' || (X) == 'u') ? UP : ((X) == 'L' || (X) == 'l') ? LO : INVALID)
60 
61 #define DIAG(X) (((X) == 'N' || (X) == 'n') ? NUNIT : ((X) == 'U' || (X) == 'u') ? UNIT : INVALID)
62 
63 inline bool check_op(const char* op) { return OP(*op) != 0xff; }
64 
65 inline bool check_side(const char* side) { return SIDE(*side) != 0xff; }
66 
67 inline bool check_uplo(const char* uplo) { return UPLO(*uplo) != 0xff; }
68 
69 typedef SCALAR Scalar;
71 typedef std::complex<RealScalar> Complex;
72 
74 
83 
84 template <typename T>
86  T* data, int rows, int cols, int stride) {
88  data, rows, cols, Eigen::OuterStride<>(stride));
89 }
90 
91 template <typename T>
93  const T* data, int rows, int cols, int stride) {
95  data, rows, cols, Eigen::OuterStride<>(stride));
96 }
97 
98 template <typename T>
100  int incr) {
103 }
104 
105 template <typename T>
107  int size,
108  int incr) {
111 }
112 
113 template <typename T>
116 }
117 
118 template <typename T>
121 }
122 
123 template <typename T>
124 T* get_compact_vector(T* x, int n, int incx) {
125  if (incx == 1) return x;
126 
127  std::remove_const_t<T>* ret = new Scalar[n];
128  if (incx < 0)
129  make_vector(ret, n) = make_vector(x, n, -incx).reverse();
130  else
132  return ret;
133 }
134 
135 template <typename T>
136 T* copy_back(T* x_cpy, T* x, int n, int incx) {
137  if (x_cpy == x) return 0;
138 
139  if (incx < 0)
140  make_vector(x, n, -incx).reverse() = make_vector(x_cpy, n);
141  else
143  return x_cpy;
144 }
145 
146 #ifndef EIGEN_BLAS_FUNC_SUFFIX
147 #define EIGEN_BLAS_FUNC_SUFFIX _
148 #endif
149 
150 #define EIGEN_BLAS_FUNC_NAME(X) EIGEN_CAT(SCALAR_SUFFIX, EIGEN_CAT(X, EIGEN_BLAS_FUNC_SUFFIX))
151 #define EIGEN_BLAS_FUNC(X) extern "C" void EIGEN_BLAS_FUNC_NAME(X)
152 
153 #endif // EIGEN_BLAS_COMMON_H
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
int data[]
Definition: Map_placement_new.cpp:1
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
#define SCALAR
Definition: bench_gemm.cpp:22
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:93
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:104
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, 1 >, 0, Eigen::InnerStride< Eigen::Dynamic > > make_vector(T *data, int size, int incr)
Definition: common.h:99
SCALAR Scalar
Definition: common.h:69
Eigen::Map< Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > MatrixType
Definition: common.h:77
@ IsComplex
Definition: common.h:73
@ Conj
Definition: common.h:73
std::complex< RealScalar > Complex
Definition: common.h:71
Eigen::Map< Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > > CompactVectorType
Definition: common.h:82
T * copy_back(T *x_cpy, T *x, int n, int incx)
Definition: common.h:136
T * get_compact_vector(T *x, int n, int incx)
Definition: common.h:124
bool check_uplo(const char *uplo)
Definition: common.h:67
#define SIDE(X)
Definition: common.h:57
#define OP(X)
Definition: common.h:54
Eigen::Map< const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > ConstMatrixType
Definition: common.h:80
bool check_op(const char *op)
Definition: common.h:63
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > PlainMatrixType
Definition: common.h:75
bool check_side(const char *side)
Definition: common.h:65
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: common.h:70
Eigen::Map< Eigen::Matrix< Scalar, Eigen::Dynamic, 1 >, 0, Eigen::InnerStride< Eigen::Dynamic > > StridedVectorType
Definition: common.h:81
#define UPLO(X)
Definition: common.h:59
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
RealScalar RealScalar int * incx
Definition: level1_cplx_impl.h:27
const char * uplo
Definition: level2_cplx_impl.h:20
Scalar * x_cpy
Definition: level2_cplx_impl.h:177
char char * op
Definition: level2_impl.h:374
const char * side
Definition: level3_impl.h:101
list x
Definition: plotDoE.py:28
T Real
Definition: NumTraits.h:183
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217