Spectral Integral Suite in C++
sis::Linop< T > Class Template Reference

Linop This class creates a Linear operator to solve TPBVPs. More...

#include <sis.hpp>

Public Member Functions

 Linop ()
 A null-constructor for Linop. More...
 
 Linop (const int &n_)
 Makes a Linop by specifying the order n_ of the differential equation. More...
 
 Linop (const Linop< T > &in)
 Copy constructor. More...
 
void operator= (const Linop< T > &in)
 Assignment operator. More...
 
Chebfun< T > operator() (Chebfun< T > in)
 Apply the operator on a Chebfun. More...
 
void operator+= (const Linop< T > &in)
 Add to self: More...
 
void operator= (const T &in)
 Assignment operator for constant input. More...
 
void operator= (const Eigen::Array< T, Eigen::Dynamic, 1 > &in)
 Assignment operator for function input, through Eigen array. More...
 
void operator= (const std::valarray< T > &in)
 Assignment operator for function input, through valarray. More...
 
void operator= (Chebfun< T > in)
 Assignment through a Chebfun: More...
 
Linop< T > operator/ (T in)
 Dividing Linop by scalar. More...
 
void set ()
 Sets the the size of coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. More...
 
void set (int n_)
 Sets the the size of coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. More...
 
void ncc ()
 Sets the the size of non-constant coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. This must be called before assigning non-constant coefficients. More...
 
void ncc (int n_)
 Sets the the size of non-constant coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. This must be called before assigning non-constant coefficients. More...
 

Public Attributes

int NCC
 Flag to set (value 1) for enabling nonconstant coefficients. More...
 
int n
 The order of the Linear differential operator. More...
 
Eigen::Matrix< T, Eigen::Dynamic, 1 > coef
 Stores the coefficients in the differential equation. More...
 
ChebfunMat< T > coefFun
 
Eigen::Matrix< T, Eigen::Dynamic, 1 > solution
 Stores the solution. More...
 

Related Functions

(Note that these are not member functions.)

template<class T >
Linop< T > operator* (Linop< T > L1, Linop< T > L2)
 These are used to define operator compositions, L1(L2). It is defined as operator multiplication, L1 * L2. Based on,

\begin{align} \left[ \sum_{i=0}^{m}\,b_i(y)\,D^i \right] \, \left[ \sum_{j=0}^{n}\,a_i(y)\,D^i \right] \;=\; \sum_{i = 0}^{m}\,b_i(y)\, \sum_{j = 0}^{n}\sum_{k = 0}^{i}\,C^i_k\,a_j^k(y)\,Dj+i-k \end{align}

Implemented by recursion, not by the formula above. More...

 

Detailed Description

template<class T>
class sis::Linop< T >

Linop This class creates a Linear operator to solve TPBVPs.

Definition at line 2560 of file sis.hpp.

Constructor & Destructor Documentation

◆ Linop() [1/3]

template<class T>
sis::Linop< T >::Linop ( )
inline

A null-constructor for Linop.

Definition at line 2632 of file sis.hpp.

References sis::Linop< T >::NCC.

◆ Linop() [2/3]

template<class T>
sis::Linop< T >::Linop ( const int &  n_)
inline

Makes a Linop by specifying the order n_ of the differential equation.

Definition at line 2636 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::n, and sis::Linop< T >::NCC.

◆ Linop() [3/3]

template<class T>
sis::Linop< T >::Linop ( const Linop< T > &  in)
inline

Member Function Documentation

◆ ncc() [1/2]

template<class T>
void sis::Linop< T >::ncc ( )
inline

Sets the the size of non-constant coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. This must be called before assigning non-constant coefficients.

Definition at line 2751 of file sis.hpp.

References sis::Linop< T >::coefFun, sis::Linop< T >::n, and sis::Linop< T >::NCC.

Referenced by sis::diff(), sis::dou2com(), sis::Linop< std::complex< T > >::imag(), sis::operator*(), sis::Linop< T >::operator*(), sis::operator+(), sis::Linop< T >::operator=(), sis::Linop< std::complex< T > >::operator=(), and sis::Linop< std::complex< T > >::real().

◆ ncc() [2/2]

template<class T>
void sis::Linop< T >::ncc ( int  n_)
inline

Sets the the size of non-constant coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4. This must be called before assigning non-constant coefficients.

Definition at line 2760 of file sis.hpp.

References sis::Linop< T >::coefFun, sis::Linop< T >::n, and sis::Linop< T >::NCC.

◆ operator()()

template<class T>
Chebfun<T> sis::Linop< T >::operator() ( Chebfun< T >  in)
inline

◆ operator+=()

template<class T>
void sis::Linop< T >::operator+= ( const Linop< T > &  in)
inline

Add to self:

Definition at line 2680 of file sis.hpp.

References sis::Linop< T >::operator=().

◆ operator/()

template<class T>
Linop<T> sis::Linop< T >::operator/ ( in)
inline

Dividing Linop by scalar.

Definition at line 2718 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::coefFun, sis::Linop< T >::n, and sis::Linop< T >::NCC.

◆ operator=() [1/5]

◆ operator=() [2/5]

template<class T>
void sis::Linop< T >::operator= ( const T &  in)
inline

Assignment operator for constant input.

Definition at line 2687 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::n, and sis::Linop< T >::NCC.

◆ operator=() [3/5]

template<class T>
void sis::Linop< T >::operator= ( const Eigen::Array< T, Eigen::Dynamic, 1 > &  in)
inline

Assignment operator for function input, through Eigen array.

Definition at line 2695 of file sis.hpp.

References sis::Linop< T >::coefFun, sis::Linop< T >::n, and sis::Linop< T >::ncc().

◆ operator=() [4/5]

template<class T>
void sis::Linop< T >::operator= ( const std::valarray< T > &  in)
inline

Assignment operator for function input, through valarray.

Definition at line 2702 of file sis.hpp.

References sis::Linop< T >::coefFun, sis::Linop< T >::n, and sis::Linop< T >::ncc().

◆ operator=() [5/5]

template<class T>
void sis::Linop< T >::operator= ( Chebfun< T >  in)
inline

◆ set() [1/2]

template<class T>
void sis::Linop< T >::set ( )
inline

Sets the the size of coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4.

Definition at line 2733 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::n, and sis::Linop< T >::NCC.

Referenced by sis::dou2com(), sis::Linop< std::complex< T > >::imag(), main(), sis::Linop< T >::operator*(), sis::operator*(), sis::operator+(), and sis::Linop< std::complex< T > >::real().

◆ set() [2/2]

template<class T>
void sis::Linop< T >::set ( int  n_)
inline

Sets the the size of coefficient array based on the order of differential equation. Suppose order is 3, then the size of array needed is 4.

Definition at line 2741 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::n, and sis::Linop< T >::NCC.

Friends And Related Function Documentation

◆ operator*()

template<class T >
Linop< T > operator* ( Linop< T >  L1,
Linop< T >  L2 
)
related

These are used to define operator compositions, L1(L2). It is defined as operator multiplication, L1 * L2. Based on,

\begin{align} \left[ \sum_{i=0}^{m}\,b_i(y)\,D^i \right] \, \left[ \sum_{j=0}^{n}\,a_i(y)\,D^i \right] \;=\; \sum_{i = 0}^{m}\,b_i(y)\, \sum_{j = 0}^{n}\sum_{k = 0}^{i}\,C^i_k\,a_j^k(y)\,Dj+i-k \end{align}

Implemented by recursion, not by the formula above.

<std::complex<T>>

Definition at line 12928 of file sis.hpp.

References sis::Linop< T >::coef, sis::Linop< T >::coefFun, sis::diff(), sis::Linop< T >::n, sis::Linop< T >::NCC, sis::Linop< T >::ncc(), and sis::Linop< T >::set().

Member Data Documentation

◆ coef

◆ coefFun

template<class T>
ChebfunMat<T> sis::Linop< T >::coefFun

Use this to input all non-constant coefficients.

For instance, for the differential operator \(2y^2\,\partial_y + 3y\), coefFun \( [0]= 2y^2\) and coef \([1] = 3y\), where y is a array whose cheb-points have been set. Note that this can only be called after calling Linop.ncc(), which initiates non-constant coefficients. One can also use the Eigen format to input coefficients. For example, to set coefficients of above differential equation, we need to do the following (assuming double precision):

Eigen::ArrayXd y;
Linop <double> L(2); // Second order differential operator
L.ncc();
L.coefFun[0] = 2.0*pow(y,2.0);
L.coefFun[1] = 3.0*y;

Alternatively, in the eigen-input format, one can do the following:

Eigen::ArrayXd y;
Linop <double> L(2); // Second order differential operator
L.ncc();
L.coefFun << 2.0*pow(y,2.0), 3.0*y;

Note that when ncc() is called coef is no more used in any function in Linop. In other words, DO NOT to mix coef and coefFun and expect it to work. If there is even one non-constant coefficient in the differential equation, then you must set coefficients in coefFun, and not in coef. This also means that constant coefficients problem can be solved as a non-constant coefficient problem, as in consider the differential operator \(2\,\partial_y + 3\). This can input as a constant coefficient problem in the following manner:

Linop <double> L(1);
L.set();
L.coef << 2.0, 3.0;

or as a non-constant coefficient problem as in:

Linop <double> L(1);
L.ncc();
L.coefFun << 2.0, 3.0;

Ofcourse, constant input to a coefFun automatically assigns values at all cheb-points to that constant.

However, the constant coefficient solver is far more efficient in terms of speed and memory than a non-constant solver, and hence we provide separate solvers for each case.

Definition at line 2621 of file sis.hpp.

Referenced by sis::conj(), sis::diff(), sis::dou2com(), sis::Linop< std::complex< T > >::imag(), sis::Linop< T >::Linop(), sis::Linop< std::complex< T > >::Linop(), sis::Linop< T >::ncc(), sis::Linop< std::complex< T > >::ncc(), sis::Linop< T >::operator()(), sis::Linop< std::complex< T > >::operator()(), sis::Linop< std::complex< T > >::operator*(), sis::operator*(), sis::Linop< T >::operator*(), sis::operator+(), sis::operator-(), sis::Linop< T >::operator/(), sis::Linop< std::complex< T > >::operator/(), sis::Linop< T >::operator=(), sis::Linop< std::complex< T > >::operator=(), and sis::Linop< std::complex< T > >::real().

◆ n

◆ NCC

◆ solution

template<class T>
Eigen::Matrix<T, Eigen::Dynamic, 1> sis::Linop< T >::solution

Stores the solution.

The solution here involves storing the Chebyshev coeefficients of the highest derivative in the differential equation, and also the constants of integration. This can be used to construct all other lower derivatives using integration.

First N+1 elements of sol hold the Chebyshev coefficients and the remaining elements store the integration constants

Definition at line 2629 of file sis.hpp.

Referenced by sis::Linop< T >::Linop(), sis::Linop< std::complex< T > >::Linop(), sis::Linop< T >::operator=(), and sis::Linop< std::complex< T > >::operator=().


The documentation for this class was generated from the following file: