KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
la_utils.h File Reference

linear algebra for array More...

#include "array_utils.h"
#include "types.h"
#include "../thirdpart/Eigen/Dense"
#include "../thirdpart/Eigen/QR"
Include dependency graph for la_utils.h:

Go to the source code of this file.

Macros

#define ARRAY_USE_EIGEN
 
#define EigMajor   Eigen::RowMajor
 
#define DEFINE_POINTER(T, name)
 each pointer associate with an eigen container
 
#define DEFINE_POINTER_PROTECTED(T, name)
 
#define ALLOCATE_PTR_TO_VECTOR(name, size)
 allocate eigen container, then refer ptr to the container
 
#define ALLOCATE_PTR_TO_MATRIX(name, size1, size2)
 allocate eigen container, then refer ptr to the container
 

Typedefs

template<class T >
using EigVX = Eigen::Matrix<T, Eigen::Dynamic, 1, EigMajor>
 
template<class T >
using EigMX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, EigMajor>
 
template<class T >
using EigAX = Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic, EigMajor>
 
typedef EigVX< num_real > EigVXr
 
typedef EigVX< num_complex > EigVXc
 
typedef EigMX< num_real > EigMXr
 
typedef EigMX< num_complex > EigMXc
 
typedef EigMX< num_real > EigAXr
 
typedef EigMX< num_complex > EigAXc
 
typedef Eigen::Map< EigVXrMapVXr
 
typedef Eigen::Map< EigVXcMapVXc
 
typedef Eigen::Map< EigMXrMapMXr
 
typedef Eigen::Map< EigMXcMapMXc
 
typedef Eigen::Map< EigAXrMapAXr
 
typedef Eigen::Map< EigAXcMapAXc
 

Functions

void LinearSolve (num_real *x, num_real *A, num_real *b, const int &N)
 
void EigenSolve (num_real *E, num_real *T, num_real *A, const int &N)
 
void EigenSolve (num_real *E, num_complex *T, num_complex *A, const int &N)
 
void EigenSolve (num_complex *E, num_complex *T, num_complex *A, const int &N)
 
void PseudoInverse (num_real *A, num_real *invA, const int &N, num_real e=1E-5)
 

Detailed Description

linear algebra for array

Author
xshinhe
Version
1.0
Date
2019-01-01

here we use eigen for linear algebra (with EIGEN_USE_MKL)

See also
eigen: https://eigen.tuxfamily.org/dox/ mkl : https://www.intel.com/content/www/us/en/develop/documentation/onemkl-lapack-examples/top.html

Definition in file la_utils.h.

Macro Definition Documentation

◆ ALLOCATE_PTR_TO_MATRIX

#define ALLOCATE_PTR_TO_MATRIX ( name,
size1,
size2 )
Value:
name##_eigen_container.resize(size1, size2); \
name = name##_eigen_container.data();

allocate eigen container, then refer ptr to the container

Definition at line 124 of file la_utils.h.

◆ ALLOCATE_PTR_TO_VECTOR

#define ALLOCATE_PTR_TO_VECTOR ( name,
size )
Value:
name##_eigen_container.resize(size, 1); \
name = name##_eigen_container.data();

allocate eigen container, then refer ptr to the container

Definition at line 117 of file la_utils.h.

◆ ARRAY_USE_EIGEN

#define ARRAY_USE_EIGEN

Definition at line 25 of file la_utils.h.

◆ DEFINE_POINTER

#define DEFINE_POINTER ( T,
name )
Value:
public: \
EigMX<T>& ref_##name() { return name##_eigen_container; } \
T* name; \
EigMX<T> name##_eigen_container;
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, EigMajor > EigMX
Definition linalg_tpl.h:48

each pointer associate with an eigen container

Definition at line 100 of file la_utils.h.

◆ DEFINE_POINTER_PROTECTED

#define DEFINE_POINTER_PROTECTED ( T,
name )
Value:
public: \
EigMX<T>& ref_##name() { return name##_eigen_container; } \
\
protected: \
T* name; \
EigMX<T> name##_eigen_container;

Definition at line 106 of file la_utils.h.

◆ EigMajor

#define EigMajor   Eigen::RowMajor

Definition at line 62 of file la_utils.h.

Typedef Documentation

◆ EigAX

template<class T >
using EigAX = Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic, EigMajor>

Definition at line 71 of file la_utils.h.

◆ EigAXc

typedef EigMX<num_complex> EigAXc

Definition at line 78 of file la_utils.h.

◆ EigAXr

typedef EigMX<num_real> EigAXr

Definition at line 77 of file la_utils.h.

◆ EigMX

template<class T >
using EigMX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, EigMajor>

Definition at line 68 of file la_utils.h.

◆ EigMXc

typedef EigMX<num_complex> EigMXc

Definition at line 76 of file la_utils.h.

◆ EigMXr

typedef EigMX<num_real> EigMXr

Definition at line 75 of file la_utils.h.

◆ EigVX

template<class T >
using EigVX = Eigen::Matrix<T, Eigen::Dynamic, 1, EigMajor>

Definition at line 65 of file la_utils.h.

◆ EigVXc

typedef EigVX<num_complex> EigVXc

Definition at line 74 of file la_utils.h.

◆ EigVXr

typedef EigVX<num_real> EigVXr

Definition at line 73 of file la_utils.h.

◆ MapAXc

typedef Eigen::Map<EigAXc> MapAXc

Definition at line 84 of file la_utils.h.

◆ MapAXr

typedef Eigen::Map<EigAXr> MapAXr

Definition at line 83 of file la_utils.h.

◆ MapMXc

typedef Eigen::Map<EigMXc> MapMXc

Definition at line 82 of file la_utils.h.

◆ MapMXr

typedef Eigen::Map<EigMXr> MapMXr

Definition at line 81 of file la_utils.h.

◆ MapVXc

typedef Eigen::Map<EigVXc> MapVXc

Definition at line 80 of file la_utils.h.

◆ MapVXr

typedef Eigen::Map<EigVXr> MapVXr

Definition at line 79 of file la_utils.h.

Function Documentation

◆ EigenSolve() [1/3]

void EigenSolve ( num_complex * E,
num_complex * T,
num_complex * A,
const int & N )

◆ EigenSolve() [2/3]

void EigenSolve ( num_real * E,
num_complex * T,
num_complex * A,
const int & N )

◆ EigenSolve() [3/3]

void EigenSolve ( num_real * E,
num_real * T,
num_real * A,
const int & N )

◆ LinearSolve()

void LinearSolve ( num_real * x,
num_real * A,
num_real * b,
const int & N )

◆ PseudoInverse()

void PseudoInverse ( num_real * A,
num_real * invA,
const int & N,
num_real e = 1E-5 )