cheb_utils.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * \file cheb_utils.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 2-11-2011
  5. * \brief This file contains chebyshev related functions.
  6. */
  7. #ifndef _PVFMM_CHEB_UTILS_HPP_
  8. #define _PVFMM_CHEB_UTILS_HPP_
  9. #include <pvfmm_common.hpp>
  10. #include <vector>
  11. #include <kernel.hpp>
  12. #include <vector.hpp>
  13. namespace pvfmm{
  14. /**
  15. * \brief Returns the sum of the absolute value of coeffecients of the highest
  16. * order polynomial as an estimate of error.
  17. */
  18. template <class T>
  19. T cheb_err(T* cheb_coeff, int deg, int dof);
  20. /**
  21. * \brief Computes Chebyshev approximation from function values at cheb node points.
  22. */
  23. template <class T, class Y>
  24. T cheb_approx(T* fn_v, int d, int dof, T* out);
  25. /**
  26. * \brief Evaluates polynomial values from input coefficients at points on
  27. * a regular grid defined by in_x, in_y, in_z the values in the input vector.
  28. */
  29. template <class T>
  30. void cheb_eval(Vector<T>& coeff_, int cheb_deg, std::vector<T>& in_x, std::vector<T>& in_y, std::vector<T>& in_z, Vector<T>& out);
  31. /**
  32. * \brief Evaluates polynomial values from input coefficients at points on
  33. * a regular grid defined by the values in the input vector.
  34. */
  35. template <class T>
  36. void cheb_eval(Vector<T>& coeff_, int cheb_deg, std::vector<T>& coord, Vector<T>& out);
  37. /**
  38. * \brief Computes a least squares solution for Chebyshev approximation over a
  39. * cube from point samples.
  40. * \param[in] deg Maximum degree of the polynomial.
  41. * \param[in] coord Coordinates of points (x,y,z interleaved).
  42. * \param[in] node_coord Coordinates of the octant.
  43. * \param[in] node_size Length of the side of the octant.
  44. * \param[out] cheb_coeff Output coefficients.
  45. */
  46. template <class T>
  47. void points2cheb(int deg, T* coord, T* val, int n, int dim, T* node_coord, T node_size, Vector<T>& cheb_coeff);
  48. /**
  49. * \brief
  50. * \param[in] r Length of the side of cubic region.
  51. */
  52. template <class T>
  53. std::vector<T> cheb_integ(int m, T* s, T r, Kernel<T>& kernel);
  54. /**
  55. * \brief Returns coordinates of Chebyshev node points in 'dim' dimensional
  56. * space.
  57. */
  58. template <class T>
  59. std::vector<T> cheb_nodes(int deg, int dim);
  60. template <class T>
  61. void cheb_grad(T* A, int deg, T* B);
  62. template <class T>
  63. void cheb_laplacian(T* A, int deg, T* B);
  64. template <class T>
  65. void cheb_curl(T* A, int deg, T* B);
  66. /*
  67. * \brief Computes image of the chebyshev interpolation along the specified axis.
  68. */
  69. template <class T>
  70. void cheb_img(T* A, T* B, int cheb_deg, int dir, bool neg_);
  71. }//end namespace
  72. #include <cheb_utils.txx>
  73. #endif //_PVFMM_CHEB_UTILS_HPP_