| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | // This file is part of Eigen, a lightweight C++ template library
 | 
					
						
							|  |  |  | // for linear algebra.
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2015-02-11 02:22:05 +08:00
										 |  |  | // Copyright (C) 2009-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2012-07-14 02:42:47 +08:00
										 |  |  | // This Source Code Form is subject to the terms of the Mozilla
 | 
					
						
							|  |  |  | // Public License v. 2.0. If a copy of the MPL was not distributed
 | 
					
						
							|  |  |  | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef EIGEN_BLAS_COMMON_H
 | 
					
						
							|  |  |  | #define EIGEN_BLAS_COMMON_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-29 00:32:39 +08:00
										 |  |  | #ifdef __GNUC__
 | 
					
						
							|  |  |  | #if __GNUC__ < 5
 | 
					
						
							|  |  |  | // GCC < 5.0 does not like the global Scalar typedef
 | 
					
						
							|  |  |  | // we just keep shadow-warnings disabled permanently
 | 
					
						
							|  |  |  | #define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 23:13:01 +08:00
										 |  |  | #include "../Eigen/Core"
 | 
					
						
							|  |  |  | #include "../Eigen/Jacobi"
 | 
					
						
							| 
									
										
										
										
											2012-09-11 19:32:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-17 19:49:43 +08:00
										 |  |  | #include <complex>
 | 
					
						
							| 
									
										
										
										
											2010-03-02 02:06:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | #ifndef SCALAR
 | 
					
						
							|  |  |  | #error the token SCALAR must be defined to compile this file
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-24 05:54:05 +08:00
										 |  |  | #include "blas.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define NOTR 0
 | 
					
						
							|  |  |  | #define TR 1
 | 
					
						
							|  |  |  | #define ADJ 2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define LEFT 0
 | 
					
						
							|  |  |  | #define RIGHT 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define UP 0
 | 
					
						
							|  |  |  | #define LO 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define NUNIT 0
 | 
					
						
							|  |  |  | #define UNIT 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-04 05:03:12 +08:00
										 |  |  | #define INVALID 0xff
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | #define OP(X) \
 | 
					
						
							|  |  |  |   (((X) == 'N' || (X) == 'n') ? NOTR : ((X) == 'T' || (X) == 't') ? TR : ((X) == 'C' || (X) == 'c') ? ADJ : INVALID) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SIDE(X) (((X) == 'L' || (X) == 'l') ? LEFT : ((X) == 'R' || (X) == 'r') ? RIGHT : INVALID)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define UPLO(X) (((X) == 'U' || (X) == 'u') ? UP : ((X) == 'L' || (X) == 'l') ? LO : INVALID)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 15:31:19 +08:00
										 |  |  | #define DIAG(X) (((X) == 'N' || (X) == 'n') ? NUNIT : ((X) == 'U' || (X) == 'u') ? UNIT : INVALID)
 | 
					
						
							| 
									
										
										
										
											2010-11-04 05:03:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | inline bool check_op(const char* op) { return OP(*op) != 0xff; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | inline bool check_side(const char* side) { return SIDE(*side) != 0xff; } | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-04 05:03:12 +08:00
										 |  |  | inline bool check_uplo(const char* uplo) { return UPLO(*uplo) != 0xff; } | 
					
						
							| 
									
										
										
										
											2011-12-02 01:06:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Eigen { | 
					
						
							|  |  |  | #include "BandTriangularSolver.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-08 01:39:16 +08:00
										 |  |  | #include "GeneralRank1Update.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-09 02:55:10 +08:00
										 |  |  | #include "PackedSelfadjointProduct.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-09 23:34:45 +08:00
										 |  |  | #include "PackedTriangularMatrixVector.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-10 06:29:02 +08:00
										 |  |  | #include "PackedTriangularSolverVector.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-08 01:39:16 +08:00
										 |  |  | #include "Rank2Update.h"
 | 
					
						
							| 
									
										
										
										
											2011-12-02 01:06:28 +08:00
										 |  |  | }  // namespace Eigen
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | using namespace Eigen; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-02 02:06:07 +08:00
										 |  |  | typedef SCALAR Scalar; | 
					
						
							|  |  |  | typedef NumTraits<Scalar>::Real RealScalar; | 
					
						
							|  |  |  | typedef std::complex<RealScalar> Complex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum { IsComplex = Eigen::NumTraits<SCALAR>::IsComplex, Conj = IsComplex }; | 
					
						
							| 
									
										
										
										
											2023-12-06 05:22:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-18 18:32:39 +08:00
										 |  |  | typedef Matrix<Scalar, Dynamic, Dynamic, ColMajor> PlainMatrixType; | 
					
						
							| 
									
										
										
										
											2010-07-17 05:30:06 +08:00
										 |  |  | typedef Map<Matrix<Scalar, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> > MatrixType; | 
					
						
							| 
									
										
										
										
											2016-04-11 23:13:01 +08:00
										 |  |  | typedef Map<const Matrix<Scalar, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> > ConstMatrixType; | 
					
						
							| 
									
										
										
										
											2010-03-02 02:06:07 +08:00
										 |  |  | typedef Map<Matrix<Scalar, Dynamic, 1>, 0, InnerStride<Dynamic> > StridedVectorType; | 
					
						
							|  |  |  | typedef Map<Matrix<Scalar, Dynamic, 1> > CompactVectorType; | 
					
						
							| 
									
										
										
										
											2023-12-06 05:22:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | template <typename T> | 
					
						
							| 
									
										
										
										
											2010-07-17 05:30:06 +08:00
										 |  |  | Map<Matrix<T, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> > matrix(T* data, int rows, int cols, int stride) { | 
					
						
							|  |  |  |   return Map<Matrix<T, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> >(data, rows, cols, OuterStride<>(stride)); | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 21:12:44 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | Map<const Matrix<T, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> > matrix(const T* data, int rows, int cols, | 
					
						
							|  |  |  |                                                                            int stride) { | 
					
						
							|  |  |  |   return Map<const Matrix<T, Dynamic, Dynamic, ColMajor>, 0, OuterStride<> >(data, rows, cols, OuterStride<>(stride)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | template <typename T> | 
					
						
							| 
									
										
										
										
											2014-04-01 17:23:28 +08:00
										 |  |  | Map<Matrix<T, Dynamic, 1>, 0, InnerStride<Dynamic> > make_vector(T* data, int size, int incr) { | 
					
						
							| 
									
										
										
										
											2010-03-02 02:06:07 +08:00
										 |  |  |   return Map<Matrix<T, Dynamic, 1>, 0, InnerStride<Dynamic> >(data, size, InnerStride<Dynamic>(incr)); | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 21:12:44 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | Map<const Matrix<T, Dynamic, 1>, 0, InnerStride<Dynamic> > make_vector(const T* data, int size, int incr) { | 
					
						
							|  |  |  |   return Map<const Matrix<T, Dynamic, 1>, 0, InnerStride<Dynamic> >(data, size, InnerStride<Dynamic>(incr)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | template <typename T> | 
					
						
							| 
									
										
										
										
											2014-04-01 17:23:28 +08:00
										 |  |  | Map<Matrix<T, Dynamic, 1> > make_vector(T* data, int size) { | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  |   return Map<Matrix<T, Dynamic, 1> >(data, size); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-11 21:12:44 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | Map<const Matrix<T, Dynamic, 1> > make_vector(const T* data, int size) { | 
					
						
							|  |  |  |   return Map<const Matrix<T, Dynamic, 1> >(data, size); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-19 23:51:52 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | T* get_compact_vector(T* x, int n, int incx) { | 
					
						
							|  |  |  |   if (incx == 1) return x; | 
					
						
							| 
									
										
										
										
											2010-11-23 01:49:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-17 00:43:40 +08:00
										 |  |  |   std::remove_const_t<T>* ret = new Scalar[n]; | 
					
						
							| 
									
										
										
										
											2014-04-01 17:23:28 +08:00
										 |  |  |   if (incx < 0) | 
					
						
							|  |  |  |     make_vector(ret, n) = make_vector(x, n, -incx).reverse(); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     make_vector(ret, n) = make_vector(x, n, incx); | 
					
						
							| 
									
										
										
										
											2010-11-19 23:51:52 +08:00
										 |  |  |   return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-20 00:22:43 +08:00
										 |  |  | template <typename T> | 
					
						
							|  |  |  | T* copy_back(T* x_cpy, T* x, int n, int incx) { | 
					
						
							|  |  |  |   if (x_cpy == x) return 0; | 
					
						
							| 
									
										
										
										
											2010-11-23 01:49:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 17:23:28 +08:00
										 |  |  |   if (incx < 0) | 
					
						
							|  |  |  |     make_vector(x, n, -incx).reverse() = make_vector(x_cpy, n); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     make_vector(x, n, incx) = make_vector(x_cpy, n); | 
					
						
							| 
									
										
										
										
											2010-11-20 00:22:43 +08:00
										 |  |  |   return x_cpy; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-28 03:30:58 +08:00
										 |  |  | #ifndef EIGEN_BLAS_FUNC_SUFFIX
 | 
					
						
							|  |  |  | #define EIGEN_BLAS_FUNC_SUFFIX _
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define EIGEN_BLAS_FUNC(X) EIGEN_CAT(SCALAR_SUFFIX, EIGEN_CAT(X, EIGEN_BLAS_FUNC_SUFFIX))
 | 
					
						
							| 
									
										
										
										
											2009-09-25 19:08:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif  // EIGEN_BLAS_COMMON_H
 |