SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
polynomial_algo.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
75 #ifndef SLIP_POLYNOMIAL_ALGO_HPP
76 #define SLIP_POLYNOMIAL_ALGO_HPP
77 
78 #include "statistics.hpp"
79 #include "Array2d.hpp"
80 #include "arithmetic_op.hpp"
81 //#include "MultivariatePolynomial.hpp"
82 #include <iterator>
83 #include <iostream>
84 #include <algorithm>
85 #include <numeric>
86 #include <cmath>
87 
88 
89 namespace slip
90 {
91 
92 
94  /* @{ */
131  template <typename Poly, typename Poly1, typename Poly2, typename Poly3>
132  inline Poly
133  legendre_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
134  {
135  typedef typename Poly::mapped_type T;
136 
137  return ((((Poly(x) * Poly(Pk))* T(2 * k + 1)) - (Poly(Pkm1)* T(k))) / T(k + 1));
138 
139  }
140 
170  template <typename Poly, typename Poly1, typename Poly2, typename Poly3>
171  inline Poly
172  legendre_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
173  {
174  typedef typename Poly::value_type T;
175 
176  return ((((Poly(x) * Poly(Pk))* T(2 * k + 1)) - (Poly(Pkm1)* T(k))) / T(k + 1));
177 
178  }
179 
180  /* @} */
181 
182 
184  /* @{ */
185 
239  template <typename Poly,
240  typename Poly1,
241  typename Poly2,
242  typename Poly3>
243  inline Poly
244  chebyshev_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
245  {
246  typedef typename Poly::value_type T;
247 
248  return ((Poly(x) * Poly(Pk))* T(2)) - Poly(Pkm1);
249 
250  }
251 
293  template <typename Poly, typename Poly1, typename Poly2, typename Poly3>
294  inline Poly
295  chebyshev_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
296  {
297  typedef typename Poly::mapped_type T;
298 
299  return ((Poly(x) * Poly(Pk))* T(2)) - Poly(Pkm1);
300 
301  }
302 
329  template<typename T, typename RandomAccessIterator>
330  inline
331  void eval_chebyshevII_basis(const T& x,
332  const std::size_t n,
333  RandomAccessIterator first, RandomAccessIterator last)
334  {
335  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
336  if(n == 0)
337  {
338  first[0] = T(1);
339  }
340  else if (n == 1)
341  {
342  first[0] = T(1);
343  first[1] = 2*x;
344  }
345  else
346  {
347 
348  T twox = T(2) * x;
349  first[0] = T(1);
350  first[1] = twox;
351 
352 
353  for (std::size_t j = 2; j <= n; ++j)
354  {
355  first[j] = (twox * first[j-1]) - first[j-2];
356  }
357 
358  }
359 
360  }
361 
362 
389  template<typename T, typename RandomAccessIterator>
390  inline
392  const std::size_t n,
393  RandomAccessIterator first, RandomAccessIterator last)
394  {
395  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
396  T N = static_cast<T>(last-first);
397  if(n == 0)
398  {
399  first[0] = T(1);
400  }
401  else if (n == 1)
402  {
403  first[0] = T(1);
404  first[1] = T(2)*x - N + T(1);
405  }
406  else
407  {
408 
409  T twox = T(2)*x - N + T(1);
410  first[0] = T(1);
411  first[1] = twox;
412  T N2 = N * N;
413 
414  for (std::size_t j = 2; j <= n; ++j)
415  {
416  T jf = static_cast<T>(j);
417  T jf_m_1 = jf - static_cast<T>(1);
418  T alpha = (jf_m_1 + jf_m_1 + static_cast<T>(1)) / jf;
419  T jf_m_12 = static_cast<T>(jf_m_1 * jf_m_1);
420  T beta = (static_cast<T>(jf_m_1)*(N2-jf_m_12))/jf;
421 
422  first[j] = alpha*(twox * first[j-1]) - beta*first[j-2];
423  }
424 
425  }
426 
427  }
428 
429  /* @} */
430 
432  /* @{ */
471  template <typename Poly,
472  typename Poly1,
473  typename Poly2,
474  typename Poly3>
475  inline Poly
476  hermite_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
477  {
478  typedef typename Poly::value_type T;
479 
480  return ((Poly(x) * Poly(Pk))* T(2)) - Poly(Pkm1)* T(2*k);
481 
482  }
483 
524  template <typename Poly, typename Poly1, typename Poly2, typename Poly3>
525  inline Poly
526  hermite_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
527  {
528  typedef typename Poly::mapped_type T;
529 
530  return ((Poly(x) * Poly(Pk))* T(2)) - Poly(Pkm1)* T(2*k);
531 
532  }
533 
560  template<typename T, typename RandomAccessIterator>
561  inline
562  void eval_hermite_basis(const T& x,
563  const std::size_t n,
564  RandomAccessIterator first, RandomAccessIterator last)
565  {
566  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
567  if(n == 0)
568  {
569  first[0] = T(1);
570  }
571  else if (n == 1)
572  {
573  first[0] = T(1);
574  first[1] = 2*x;
575  }
576  else
577  {
578 
579  T twox = T(2) * x;
580  first[0] = T(1);
581  first[1] = twox;
582 
583 
584  for (std::size_t j = 2; j <= n; ++j)
585  {
586  first[j] = (twox * first[j-1]) - T(2*j-2)*first[j-2];
587  }
588 
589  }
590 
591  }
592 /* @} */
593 
595  /* @{ */
644  template <typename Poly,
645  typename Poly1,
646  typename Poly2,
647  typename Poly3>
648  inline Poly
649  laguerre_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
650  {
651  typedef typename Poly::value_type T;
652 
653  return (((T(2*k+1) - Poly(x)) * Poly(Pk)) - Poly(Pkm1)* T(k))/T(k+1);
654 
655  }
656 
657 
658 
699 template <typename Poly, typename Poly1, typename Poly2, typename Poly3>
700 inline Poly
701 laguerre_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
702  {
703  typedef typename Poly::mapped_type T;
704 
705  return (((T(2*k+1) - Poly(x)) * Poly(Pk)) - Poly(Pkm1)* T(k))/T(k+1);
706 
707  }
708 
709 
736  template<typename T, typename RandomAccessIterator>
737  inline
738  void eval_laguerre_basis(const T& x,
739  const std::size_t n,
740  RandomAccessIterator first, RandomAccessIterator last)
741  {
742  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
743  if(n == 0)
744  {
745  first[0] = T(1);
746  }
747  else if (n == 1)
748  {
749  first[0] = T(1);
750  first[1] = -x + T(1);
751  }
752  else
753  {
754 
755  first[0] = T(1);
756  first[1] = -x + T(1);
757 
758 
759  for (std::size_t j = 2; j <= n; ++j)
760  {
761  first[j] = -(((x - T(2*j-1))* first[j-1]) + T(j-1)*first[j-2])/T(j);
762  }
763 
764  }
765 
766  }
767  /* @} */
768 
770  /* @{ */
785  template<typename T, typename RandomAccessIterator>
786  inline
787  T eval_horner(RandomAccessIterator first, RandomAccessIterator last,
788  const T& x)
789  {
790  assert(last != first);
791  T s = T(0);
792  if(x == T(0))
793  {
794  s = *first;
795  }
796  else if(x == T(1))
797  {
798  s = std::accumulate(first,last,T(0));
799  }
800  else if(x == T(-1))
801  {
802  typedef typename std::iterator_traits<RandomAccessIterator>::difference_type _Distance;
803  _Distance size = (last - first);
804  s = *first;
805  for(_Distance i = 1; i < size; ++i)
806  {
807  if(i%2 == 0)
808  {
809  s = s + first[i];
810  }
811  else
812  {
813  s = s - first[i];
814  }
815  }
816  }
817  else
818  {
819  typedef typename std::iterator_traits<RandomAccessIterator>::difference_type _Distance;
820 
821  _Distance size = last - first;
822  s = first[size - 1];
823  for(_Distance i = (size - 2); i >= 0; --i)
824  {
825  s = first[i] + x * s;
826  }
827  }
828  return s;
829  }
830 
847  template<typename T, typename RandomAccessIterator>
848  inline
849  void eval_power_basis(const T& x,
850  const std::size_t n,
851  RandomAccessIterator first, RandomAccessIterator last)
852  {
853  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
854  if(n == 0)
855  {
856  *first = T(1);
857  }
858  else if (n == 1)
859  {
860  *first++ = T(1);
861  *first++ = x;
862  }
863  else
864  {
865  *first++ = T(1);
866 
867  if(x == T(0))
868  {
869  std::fill(first,last,T(0));
870  }
871  else if (x == T(1))
872  {
873  std::fill(first,last,T(1));
874  }
875  else if (x == T(-1))
876  {
877 
878  *first = T(-1);
879  std::size_t i = 0;
880  while(++first != last)
881  {
882  if(i%2 == 0)
883  {
884  *first = T(1);
885  }
886  else
887  {
888  *first = T(-1);
889  }
890  i++;
891  }
892  }
893  else
894  {
895  T pow = x;
896  *first = pow;
897 
898  while(++first != last)
899  {
900  pow = pow * x;
901  *first = pow;
902  }
903  }
904  }
905 
906  }
907 
924  template<typename T, typename RandomAccessIterator>
925  inline
926  void eval_legendre_basis(const T& x,
927  const std::size_t n,
928  RandomAccessIterator first, RandomAccessIterator last)
929  {
930  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
931  if(n == 0)
932  {
933  first[0] = T(1);
934  }
935  else if (n == 1)
936  {
937  first[0] = T(1);
938  first[1] = x;
939  }
940  else
941  {
942  first[0] = T(1);
943  first[1] = x;
944 
945  T twox = T(2) * x;
946  T f2 = x;
947  T d = T(1);
948  T f1 = T(0);
949 
950  for (std::size_t j = 2; j <= n; ++j)
951  {
952  f1 = d++;
953  f2 += twox;
954  first[j] = (f2 * first[j-1] - f1 * first[j-2]) / d;
955  }
956 
957  }
958 
959  }
960 
977  template<typename T, typename RandomAccessIterator>
978  inline
979  void eval_chebyshev_basis(const T& x,
980  const std::size_t n,
981  RandomAccessIterator first, RandomAccessIterator last)
982  {
983  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
984  if(n == 0)
985  {
986  first[0] = T(1);
987  }
988  else if (n == 1)
989  {
990  first[0] = T(1);
991  first[1] = x;
992  }
993  else
994  {
995  first[0] = T(1);
996  first[1] = x;
997 
998  T twox = T(2) * x;
999  for (std::size_t j = 2; j <= n; ++j)
1000  {
1001  first[j] = (twox * first[j-1]) - first[j-2];
1002  }
1003 
1004  }
1005 
1006  }
1007 
1008 
1026  template<class Vector, typename RandomAccessIterator>
1027  inline
1028  void eval_power_2d_basis(const Vector& x,
1029  const std::size_t n,
1030  RandomAccessIterator first, RandomAccessIterator last)
1031  {
1032  assert(x.size() == 2);
1033  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(((n + 1)*(n+2))/2));
1035 
1036  for(std::size_t i = 0; i < Eval.rows(); ++i)
1037  {
1038  slip::eval_power_basis(x[i],n,Eval.row_begin(i),Eval.row_end(i));
1039  }
1040 
1041  for(std::size_t i = 0; i < (n+1); ++i)
1042  {
1043  for(std::size_t j = 0; j < ((n+1) - i); ++j)
1044  {
1045  *first++ = Eval[0][j] * Eval[1][i];
1046  }
1047  }
1048  }
1049 
1050 
1051 
1071  template<class Vector, typename RandomAccessIterator>
1072  inline
1073  void eval_power_nd_basis(const Vector& x,
1074  const std::size_t order,
1075  RandomAccessIterator first, RandomAccessIterator last)
1076  {
1077  std::size_t dim = x.size();
1078  slip::Array<std::size_t> V(dim+order);
1079  slip::iota(V.begin(),V.end(),1,1);
1080  std::size_t result_size = (std::accumulate(V.begin()+order,V.end(),1,std::multiplies<int>()))/(std::accumulate(V.begin(),V.begin()+dim,1,std::multiplies<int>()));
1081 
1082  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(result_size));
1083 
1084 
1085  //array of all the powers combinations sort by lexicographical order
1086  slip::Array2d<std::size_t> powers(slip::power(order+1,dim),dim);
1087  for(std::size_t d = 0; d < powers.dim2(); ++d)
1088  {
1089  std::size_t step = slip::power((order+1),d);
1090  for(std::size_t ord = 0, ord2 = 0; ord <= (powers.dim1() - step); ord+=step,++ord2)
1091  {
1092  std::size_t tmp = ord2%(order+1);
1093  for(std::size_t k = 0; k < step; ++k)
1094  {
1095  powers[ord+k][d] = tmp;
1096  }
1097 
1098  }
1099  }
1100 
1101  typedef typename std::iterator_traits<RandomAccessIterator>::value_type value_type;
1102  //Pre-computation of the powers of x
1103  slip::Array2d<value_type> Eval(x.size(),order+1);
1104  for(std::size_t i = 0; i < Eval.rows(); ++i)
1105  {
1106  slip::eval_power_basis(x[i],order,Eval.row_begin(i),Eval.row_end(i));
1107  }
1108 
1109  //Evaluation of the monomials
1110  for(std::size_t ord = 0; ord < powers.dim1(); ++ord)
1111  {
1112  // if(std::accumulate(powers.row_begin(ord),powers.row_end(ord),value_type()) <= order)
1113  if(std::accumulate(powers.row_begin(ord),powers.row_end(ord),static_cast<std::size_t>(0)) <= order)
1114  {
1115 
1116  value_type res = value_type(1);
1117  for(std::size_t d = 0; d < dim; ++d)
1118  {
1119  res = res * Eval[d][powers[ord][d]];
1120  }
1121  *first++ = res;
1122  }
1123  }
1124 
1125 
1126  }
1127 
1176  template<typename MultivariatePolynomial,
1177  typename RandomAccessIterator>
1178  inline
1180  const std::size_t n,
1181  RandomAccessIterator first,
1182  RandomAccessIterator last)
1183  {
1184  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(n + 1));
1185  if(n == 0)
1186  {
1187  *first = MultivariatePolynomial(0);
1188  }
1189  else if (n == 1)
1190  {
1191  *first++ = MultivariatePolynomial(0);
1192  *first++ = x;
1193  }
1194  else
1195  {
1196  *first++ = MultivariatePolynomial(0);
1197 
1198  MultivariatePolynomial pow = x;
1199  *first = pow;
1200 
1201  while(++first != last)
1202  {
1203  pow = pow * x;
1204  *first = pow;
1205  }
1206 
1207  }
1208 
1209  }
1210 
1253 template<class Vector, typename RandomAccessIterator>
1254 inline
1256  const std::size_t order,
1257  RandomAccessIterator first, RandomAccessIterator last)
1258  {
1259  std::size_t dim = x.size();
1260  slip::Array<std::size_t> V(dim+order);
1261  slip::iota(V.begin(),V.end(),1,1);
1262  std::size_t result_size = (std::accumulate(V.begin()+order,V.end(),1,std::multiplies<int>()))/(std::accumulate(V.begin(),V.begin()+dim,1,std::multiplies<int>()));
1263 
1264  assert((last - first) == typename std::iterator_traits<RandomAccessIterator>::difference_type(result_size));
1265 
1266 
1267  //array of all the powers combinations sort by lexicographical order
1268  slip::Array2d<std::size_t> powers(slip::power(order+1,dim),dim);
1269  for(std::size_t d = 0; d < powers.dim2(); ++d)
1270  {
1271  std::size_t step = slip::power((order+1),d);
1272  for(std::size_t ord = 0, ord2 = 0; ord <= (powers.dim1() - step); ord+=step,++ord2)
1273  {
1274  std::size_t tmp = ord2%(order+1);
1275  for(std::size_t k = 0; k < step; ++k)
1276  {
1277  powers[ord+k][d] = tmp;
1278  }
1279 
1280  }
1281  }
1282 
1283  typedef typename std::iterator_traits<RandomAccessIterator>::value_type value_type;
1284  //Pre-computation of the powers of x
1285  slip::Array2d<value_type> Eval(x.size(),order+1);
1286  for(std::size_t i = 0; i < Eval.rows(); ++i)
1287  {
1288  slip::eval_multi_poly_power_basis(x[i],order,Eval.row_begin(i),Eval.row_end(i));
1289  }
1290 
1291  //Evaluation of the monomials
1292  for(std::size_t ord = 0; ord < powers.dim1(); ++ord)
1293  {
1294  if(std::accumulate(powers.row_begin(ord),powers.row_end(ord),static_cast<std::size_t>(0)) <= order)
1295  {
1296 
1297  value_type res = value_type(0);
1298  for(std::size_t d = 0; d < dim; ++d)
1299  {
1300  res = res * Eval[d][powers[ord][d]];
1301  }
1302  *first++ = res;
1303  }
1304  }
1305 
1306 
1307  }
1308 
1309 /* @} */
1310 
1311  template<typename T,typename RandomAccessIterator>
1312  struct EvalBasis
1313  {
1314  virtual void operator()(const T& x,
1315  const std::size_t n,
1316  RandomAccessIterator first,
1317  RandomAccessIterator last ) const = 0;
1318  virtual ~EvalBasis(){}
1319 
1320  };
1321 
1322  template<typename T,typename RandomAccessIterator>
1323  struct EvalPowerBasis: public EvalBasis<T,RandomAccessIterator>
1324  {
1325  void operator()(const T& x,
1326  const std::size_t n,
1327  RandomAccessIterator first,
1328  RandomAccessIterator last ) const
1329  {
1330  slip::eval_power_basis(x,n,first,last);
1331  }
1332 
1333  };
1334 
1335  template<typename T,typename RandomAccessIterator>
1336  struct EvalLegendreBasis: public EvalBasis<T,RandomAccessIterator>
1337  {
1338  void operator()(const T& x,
1339  const std::size_t n,
1340  RandomAccessIterator first,
1341  RandomAccessIterator last ) const
1342  {
1343  slip::eval_legendre_basis(x,n,first,last);
1344  }
1345  };
1346 
1347  template<typename T,typename RandomAccessIterator>
1348  struct EvalChebyshevBasis: public EvalBasis<T,RandomAccessIterator>
1349  {
1350  void operator()(const T& x,
1351  const std::size_t n,
1352  RandomAccessIterator first,
1353  RandomAccessIterator last ) const
1354  {
1355  slip::eval_chebyshev_basis(x,n,first,last);
1356  }
1357  };
1358 
1359  template<typename T,typename RandomAccessIterator>
1360  struct EvalPower2dBasis: public EvalBasis<T,RandomAccessIterator>
1361  {
1362  void operator()(const T& x,
1363  const std::size_t n,
1364  RandomAccessIterator first,
1365  RandomAccessIterator last ) const
1366  {
1367  slip::eval_power_2d_basis(x,n,first,last);
1368  }
1369 
1370  };
1371 
1372  template<typename T,typename RandomAccessIterator>
1373  struct EvalPowerNdBasis: public EvalBasis<T,RandomAccessIterator>
1374  {
1375 
1376  void operator()(const T& x,
1377  const std::size_t n,
1378  RandomAccessIterator first,
1379  RandomAccessIterator last ) const
1380  {
1381  slip::eval_power_nd_basis(x,n,first,last);
1382  }
1383 
1384  std::size_t dim_;
1385 
1386  };
1387 
1388 
1389 }//::slip
1390 
1391 #endif //SLIP_POLYNOMIAL_ALGO_HPP
Provides a class to manipulate 2d dynamic and generic arrays.
void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const
void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const
void eval_power_2d_basis(const Vector &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluation of the powers of X = (x1,x2) such that with and the power of x1 and x2...
T power(T x, Integer N)
function to compute.
Definition: macros.hpp:368
void eval_chebyshev_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the Chebyshev scheme...
void eval_chebyshevII_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the ChebyshevII scheme...
iterator begin()
Returns a read/write iterator that points to the first element in the Array. Iteration is done in ord...
Definition: Array.hpp:1077
void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const
Poly legendre_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Legendre polynomials, this function can be used...
Poly legendre_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Legendre multivariate polynomials, this function can be used to create a sequence of orthogonal polynomial, and for rising k. This recurrence relation holds for Legendre Polynomials of both the first and second kinds: .
void iota(ForwardIterator first, ForwardIterator last, T value, T step=T(1))
Iota assigns sequential increasing values based on a predefined step to a range. That is...
void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const
Poly chebyshev_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Chebyshev polynomials, this function can be use...
Poly laguerre_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Laguerre multivariate polynomials, this function can be used to create a sequence of orthogonal polynomial, and for rising k. This recurrence relation holds for Laguere Polynomials: .
void eval_laguerre_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the Laguerre scheme...
Numerical MultivariatePolynomial class.
void eval_power_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluation of the power of x until order n to the range [first,last) using the horner sch...
void eval_multi_poly_power_basis(const MultivariatePolynomial &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluation of the power of a slip::MultivariatePolynomial<T,DIM> P until order n to the r...
iterator end()
Returns a read/write iterator that points one past the last element in the Array. Iteration is done i...
Definition: Array.hpp:1084
Provides some statistics algorithms.
size_type size() const
Returns the number of elements in the Vector.
Definition: Vector.hpp:1743
void eval_discrete_chebyshev_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the Discrete Chebyshev sch...
size_type dim2() const
Returns the number of columns (second dimension size) in the Array2d.
Definition: Array2d.hpp:3145
Numerical Vector class. This container statisfies the RandomAccessContainer concepts of the Standard ...
Definition: Vector.hpp:104
T eval_horner(RandomAccessIterator first, RandomAccessIterator last, const T &x)
Returns the evaluation of the polynomial given throw the range [first,last) at x using the horner sch...
Provides some algorithms to computes arithmetical operations on ranges.
row_iterator row_begin(const size_type row)
Returns a read/write iterator that points to the first element of the row row in the Array2d...
Poly hermite_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Hermite multivariate polynomials, this function can be used to create a sequence of orthogonal polynomial, and for rising k. This recurrence relation holds for Hermite Polynomials: .
Poly hermite_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Hermite polynomials, this function can be used ...
Poly laguerre_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Laguerre polynomials, this function can be used...
void eval_power_nd_basis(const Vector &x, const std::size_t order, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluation of the powers of such that with the power of the xk to the range [first...
void eval_multi_poly_power_nd_basis(const Vector &x, const std::size_t order, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluation of the powers of slip::MultivariatePolynomial<T,DIM> such that with the pow...
row_iterator row_end(const size_type row)
Returns a read/write iterator that points one past the end element of the row row in the Array2d...
virtual void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const =0
void eval_hermite_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the Hermite scheme...
void operator()(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last) const
This is a two-dimensional dynamic and generic container. This container statisfies the Bidirectionnal...
Definition: Array2d.hpp:135
Poly chebyshev_nd_next(std::size_t k, Poly1 x, Poly2 Pk, Poly3 Pkm1)
Implements the three term recurrence relation for the Chebyshev multivariate polynomials, this function can be used to create a sequence of orthogonal polynomial, and for rising k. This recurrence relation holds for Chebychev Polynomials of both the first and second kinds: .
void eval_legendre_basis(const T &x, const std::size_t n, RandomAccessIterator first, RandomAccessIterator last)
Returns the evaluations of x until order n to the range [first,last) using the legendre scheme...
size_type dim1() const
Returns the number of rows (first dimension size) in the Array2d.
Definition: Array2d.hpp:3134