3#include <gsPolynomial/gsMonomialBasis.h>
16 std::cout<<
"Error: The degree has to be >=0"<<std::endl;
28 os<<
"gsMonomialBasis"<<std::endl;
29 os<<
"degree: "<<m_p<<std::endl;
30 os<<
"size: "<<size()<<std::endl;
49 result.resize(size(), u.cols());
52 result.row(0).setOnes();
54 for(
int p=1; p<=m_p; p++)
55 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
56 result(p,eval_point)=result(p-1,eval_point)*u(0,eval_point);
63 GISMO_ENSURE(
static_cast<int>(i)<=m_p,
"Error: There is no i-th basis function in the basis."<<std::endl<<
64 "Number of basis functions in the basis is "<<size()<<
".");
66 result.resize(1,u.cols());
68 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
69 result(0,eval_point) = math::pow(u(0,eval_point),
static_cast<int>(i));
75 result.resize(size(), u.cols());
78 result.row(0).setZero();
81 result.row(1).setOnes();
83 for(
int p=2; p<=m_p; p++)
84 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
85 result(p,eval_point)=(real_t)p/(p-1)*result(p-1,eval_point)*u(0,eval_point);
91 GISMO_ENSURE(
static_cast<int>(i)<=m_p,
"Error: There is no i-th basis function in the basis."<<std::endl<<
92 "Number of basis functions in the basis is "<<size()<<
".");
94 result.resize(1,u.cols());
97 result.setZero(1,u.cols());
99 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
100 result(0,eval_point)=i* math::pow(u(0,eval_point),
static_cast<int>(i)-1);
107 result.resize(size(), u.cols());
110 result.row(0).setZero();
112 result.row(1).setZero();
115 result.row(2).setConstant(2);
117 for(
int p=3; p<=m_p; p++)
118 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
119 result(p,eval_point)=(real_t)p/(p-2)*result(p-1,eval_point)*u(0,eval_point);
125 GISMO_ENSURE(
static_cast<int>(i)<=m_p,
"Error: There is no i-th basis function in the basis."<<std::endl<<
126 "Number of basis functions in the basis is "<<size()<<
".");
128 result.resize(1,u.cols());
131 result.setZero(1,u.cols());
133 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
134 result(0,eval_point)=i*(i-1) * math::pow(u(0,eval_point),
static_cast<int>(i)-2);
141 result.resize(size()*(n+1),u.cols());
143 for (
int deriv_order=0; deriv_order<=n; deriv_order++)
146 for(
int p=0; p<deriv_order && p<=m_p; p++)
147 result.row(deriv_order*size()+p).setZero();
151 result.row(deriv_order*size()+deriv_order).setConstant(
factorial(deriv_order));
154 for(
int p=deriv_order+1; p<=m_p; p++)
155 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
156 result(deriv_order*size()+p,eval_point)=(real_t)p/(p-deriv_order)*result(deriv_order*size()+p-1,eval_point)*u(0,eval_point);
163 GISMO_ENSURE(
static_cast<int>(i)<=m_p,
"Error: There is no i-th basis function in the basis."<<std::endl<<
164 "Number of basis functions in the basis is "<<size()<<
".");
166 result.resize(n+1, u.cols());
169 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
170 result(0,eval_point) = math::pow(u(0,eval_point),
static_cast<int>(i));
173 for (
int deriv_order=1; deriv_order<=n; deriv_order++)
175 if(
static_cast<int>(i)<deriv_order)
176 result.row(deriv_order).setZero();
178 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
179 result(deriv_order,eval_point)=(i+1-deriv_order)*result(deriv_order-1,eval_point)/u(0,eval_point);
187 GISMO_ENSURE(
static_cast<int>(i)<=m_p,
"Error: There is no i-th basis function in the basis."<<std::endl<<
188 "Number of basis functions in the basis is "<<size()<<
".");
190 result.resize(1, u.cols());
194 for(
int j=0; j<=n-1; j++)
200 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
201 result(0,eval_point)=factor * math::pow(u(0,eval_point),
static_cast<int>(i)-n);
209 result.resize(coefs.cols(),u.cols());
210 int n_coefs=coefs.rows();
213 for(
int eval_point=0; eval_point<u.cols(); eval_point++)
216 result.col(eval_point)=coefs.row(n_coefs-1).transpose();
217 for(
int i=n_coefs-2; i>=0; i--)
218 result.col(eval_point)=result.col(eval_point)*u.col(eval_point)+coefs.row(i).transpose();
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
An univariate monomial polynomial basis. If the degree is p the basis is given by: [ 1,...
Definition gsMonomialBasis.h:24
unsigned factorial(unsigned n)
Returns the factorial of n i.e. n! Remember that factorial grow too fast and only n!...
Definition gsCombinatorics.h:29
Provides combinatorial unitilies.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
The G+Smo namespace, containing all definitions for the library.