protected :
std::vector<opt_long_scalar_type> base_;
public :
/// Gives the array of basic functions (components).
const std::vector<opt_long_scalar_type> &base(void) const { return base_; }
std::vector<opt_long_scalar_type> &base(void) { return base_; }
/** Evaluates at point x, all base functions and returns the result in
t(nb_base,target_dim) */
void base_value(const base_node &z, base_tensor &t) const {
//scalar_type res = 0;
bgeot::multi_index mi(2);
mi[1] = target_dim(); mi[0] = short_type(nb_base(0));
t.adjust_sizes(mi);
base_tensor::iterator it = t.begin();
scalar_type x = *z.begin();//z[0];
scalar_type y = *z.end();
*it = bgeot::to_scalar(x*y); ++it;
*it = bgeot::to_scalar((1-x)*y); ++it;
*it = bgeot::to_scalar((1-x)*(1-y)); ++it;
*it = bgeot::to_scalar(x*(1-y)); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(1-x)*sqrt(1-x)*(12*x-66*x*x+(143/2)*x*x*x)); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(1-y)*sqrt(1-y)*(12*y+66*y*y+(143/2)*y*y*y));
}
/** Evaluates at point x, the gradient of all base functions w.r.t. the
reference element directions 0,..,dim-1 and returns the result in
t(nb_base,target_dim,dim) */
void grad_base_value(const base_node &z, base_tensor &t) const {
bgeot::multi_index mi(3);
dim_type n = dim();
mi[2] = n; mi[1] = target_dim(); mi[0] = short_type(nb_base(0));
t.adjust_sizes(mi);
base_tensor::iterator it = t.begin();
scalar_type x = *z.begin();
scalar_type y = *z.end();
*it = bgeot::to_scalar(y); ++it;
*it = bgeot::to_scalar(-y); ++it;
*it = bgeot::to_scalar(-(1-y) ); ++it;
*it = bgeot::to_scalar((1-y)); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(-3/2*sqrt(1-x)*(12*x-66*x*x+(143/2)*x*x*x)+(1-x)*sqrt(1-x)*(12-132*x+(429/2)*x*x))); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(x); ++it;
*it = bgeot::to_scalar((1-x)); ++it;
*it = bgeot::to_scalar(-(1-x)); ++it;
*it = bgeot::to_scalar(-x); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(-3/2*sqrt(1-y)*(12*y-66*y*y+(143/2)*y*y*y)+(1-y)*sqrt(1-y)*(12-132*y+(429/2)*y*y)));
}
/** Evaluates at point x, the hessian of all base functions w.r.t. the
reference element directions 0,..,dim-1 and returns the result in
t(nb_base,target_dim,dim,dim) */
void hess_base_value(const base_node &z, base_tensor &t) const {
bgeot::multi_index mi(4);
dim_type n = dim();
mi[3] = n; mi[2] = n; mi[1] = target_dim();
mi[0] = short_type(nb_base(0));
t.adjust_sizes(mi);
base_tensor::iterator it = t.begin();
scalar_type x = *z.begin();
scalar_type y = *z.end();
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(3/4*(1/sqrt(1-x))*(12*x-66*x*x+(143/2)*x*x*x)-3*sqrt(1-x)*(12-132*x+(429/2)*x*x)+(1-x)*sqrt(1-x)*(-132+429*x))); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(1); ++it;
*it = bgeot::to_scalar(-1); ++it;
*it = bgeot::to_scalar(1); ++it;
*it = bgeot::to_scalar(-1); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(1); ++it;
*it = bgeot::to_scalar(-1); ++it;
*it = bgeot::to_scalar(1); ++it;
*it = bgeot::to_scalar(-1); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar(0); ++it;
*it = bgeot::to_scalar((32/1281)*sqrt(2)*(3/4*(1/sqrt(1-y))*(12*y-66*y*y+(143/2)*y*y*y)-3*sqrt(1-y)*(12-132*y+(429/2)*y*y)+(1-y)*sqrt(1-y)*(-132+429*y)));
}
};