G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsLegendreBasis.hpp
1
2#pragma once
3
4namespace gismo
5{
6
7template<class T>
9{
10 result.resize(m_p+1,u.cols());
11 result.colwise() = gsVector<index_t>::LinSpaced(m_p+1, 0, m_p);
12}
13
14template<class T>
16{
17 // P_i = (A*x + B) * P_{i-1} - C * P_{i-2}
18 result.resize(m_p+1,u.cols());
19 result.row(0).setOnes();
20
21 if ( 0!=m_p )
22 result.row(1) = u;
23
24 if (m_p>1) // Bonnet’s recursion
25 {
26 for (int i=2; i<=m_p; ++i)
27 {
28 result.row(i) =
29 _getA(i) * u.array() * result.row(i-1).array() -
30 _getC(i) * result.row(i-2).array();
31 }
32 }
33}
34
35template<class T>
37{
38 // P_i' = A * (P_{i-1} + x * P_{i-1}') + B * P_{i-1}' - C * P_{i-2}'
39 result.resize(m_p+1,u.cols());
40 result.row(0).setZero();
41
42 if ( 0!=m_p )
43 result.row(1).setOnes();
44
45 if (m_p>1)
46 {
47 gsMatrix<T> val;
48 eval_into(u, val);
49
50 for (int i=2; i<=m_p; ++i)
51 {
52 // todo: inline val
53
54 result.row(i) =
55 _getA(i) * ( val.row(i-1).array() + u.array() * result.row(i-1).array() ) -
56 _getC(i) * result.row(i-2).array();
57 }
58 }
59}
60
61template<class T>
66
67} // namespace gismo
68
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Definition gsLegendreBasis.hpp:62
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the non-zero basis functions at value u.
Definition gsLegendreBasis.hpp:15
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Definition gsLegendreBasis.hpp:8
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of non-zero basis functions at (the columns of) u.
Definition gsLegendreBasis.hpp:36
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
The G+Smo namespace, containing all definitions for the library.