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();
gsMonomialBasis()
Default constructor, which sets the degree to 0.
Definition: gsMonomialBasis.h:36
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
virtual index_t size() const
Returns the numer of basis functions.
Definition: gsMonomialBasis.hpp:35
#define short_t
Definition: gsConfig.h:35
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluates all derivatives up to order n of the i-th basis function at values u.
Definition: gsMonomialBasis.hpp:161
virtual short_t domainDim() const
Returns the dimension of the parameter domain.
Definition: gsMonomialBasis.hpp:20
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the derivative of the basis functions at values u.
Definition: gsMonomialBasis.hpp:73
Provides combinatorial unitilies.
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the basis functions at values u.
Definition: gsMonomialBasis.hpp:47
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsMonomialBasis.hpp:26
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the second derivative of the basis functions at values u.
Definition: gsMonomialBasis.hpp:105
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluates all derivatives up to order n of the basis functions at values u.
Definition: gsMonomialBasis.hpp:139
virtual void evalDerSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluates the derivative of order n of the i-th basis function at values u.
Definition: gsMonomialBasis.hpp:185
virtual void deriv2Single_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the second derivatives of the i-th basis function at values u.
Definition: gsMonomialBasis.hpp:123
virtual void evalSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the i-th basis function at values u.
Definition: gsMonomialBasis.hpp:61
virtual void evalFunc_into(const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
Evaluate the function described by coefs at points u, i.e., evaluates a linear combination of coefs x...
Definition: gsMonomialBasis.hpp:207
unsigned factorial(unsigned n)
Returns the factorial of n i.e. n! Remember that factorial grow too fast and only n! with n<=13 can b...
Definition: gsCombinatorics.h:29
virtual void derivSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the derivatives of the i-th basis function at values u.
Definition: gsMonomialBasis.hpp:89
virtual memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Definition: gsMonomialBasis.hpp:41