/** * \file cheb_utils.hpp * \author Dhairya Malhotra, dhairya.malhotra@gmail.com * \date 2-11-2011 * \brief This file contains chebyshev related functions. */ #include #include #include #include #ifndef _PVFMM_CHEB_UTILS_HPP_ #define _PVFMM_CHEB_UTILS_HPP_ namespace pvfmm{ /** * \brief Returns the sum of the absolute value of coeffecients of the highest * order polynomial as an estimate of error. */ template T cheb_err(T* cheb_coeff, int deg, int dof); /** * \brief Computes Chebyshev approximation from function values at cheb node points. */ template T cheb_approx(T* fn_v, int d, int dof, T* out, mem::MemoryManager* mem_mgr=NULL); /** * \brief Evaluates polynomial values from input coefficients at points on * a regular grid defined by in_x, in_y, in_z the values in the input vector. */ template void cheb_eval(const Vector& coeff_, int cheb_deg, const std::vector& in_x, const std::vector& in_y, const std::vector& in_z, Vector& out, mem::MemoryManager* mem_mgr=NULL); /** * \brief Evaluates polynomial values from input coefficients at points on * a regular grid defined by the values in the input vector. */ template void cheb_eval(Vector& coeff_, int cheb_deg, std::vector& coord, Vector& out); /** * \brief Computes a least squares solution for Chebyshev approximation over a * cube from point samples. * \param[in] deg Maximum degree of the polynomial. * \param[in] coord Coordinates of points (x,y,z interleaved). * \param[in] node_coord Coordinates of the octant. * \param[in] node_size Length of the side of the octant. * \param[out] cheb_coeff Output coefficients. */ template void points2cheb(int deg, T* coord, T* val, int n, int dim, T* node_coord, T node_size, Vector& cheb_coeff); /** * \brief Returns an n-point quadrature rule with points 'x' and weights 'w'. * Gauss-Legendre quadrature rule for double precision and Chebyshev quadrature * rule for other data types. */ template void quad_rule(int n, T* x, T* w); /** * \brief * \param[in] r Length of the side of cubic region. */ template std::vector cheb_integ(int m, T* s, T r, const Kernel& kernel); /** * \brief Returns coordinates of Chebyshev node points in 'dim' dimensional * space. */ template std::vector cheb_nodes(int deg, int dim); template void cheb_grad(const Vector& A, int deg, Vector& B, mem::MemoryManager* mem_mgr=NULL); template void cheb_laplacian(T* A, int deg, T* B); template void cheb_curl(T* A, int deg, T* B); /* * \brief Computes image of the chebyshev interpolation along the specified axis. */ template void cheb_img(T* A, T* B, int cheb_deg, int dir, bool neg_); }//end namespace #include #endif //_PVFMM_CHEB_UTILS_HPP_