From 59f3bb9eea396d9469b905f589a969b4c7d618ab Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Tue, 5 Oct 2021 17:15:47 +0200 Subject: [PATCH] implemented Hermite polynomials --- polynomial.cc | 6 ++++++ polynomial.h | 16 ++++++++++++++++ t.cc | 9 ++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/polynomial.cc b/polynomial.cc index 7d531d5..2175fd5 100644 --- a/polynomial.cc +++ b/polynomial.cc @@ -285,6 +285,12 @@ INSTANTIZE(unsigned int) INSTANTIZE(double) INSTANTIZE(std::complex) +#define INSTANTIZE2(T) \ +template Polynomial hermite_polynomial(int); \ + +INSTANTIZE2(int) +INSTANTIZE2(double) + }//namespace diff --git a/polynomial.h b/polynomial.h index a41598b..89ce8ca 100644 --- a/polynomial.h +++ b/polynomial.h @@ -23,6 +23,7 @@ #include "la_traits.h" #include "vec.h" #include "nonclass.h" +#include "matexp.h" namespace LA { @@ -223,5 +224,20 @@ return p*q/poly_gcd(p,q,thr); } +template +Polynomial hermite_polynomial(int n) //physicists definition +{ +Polynomial h(n); +h.clear(); +h[n]=ipow((T)2,n); +for(int m=1; n-2*m>=0; m+=1) + { + int i=n-2*m; + h[i] = (-h[i+2] *(i+2)*(i+1)) /(4*m); + } +return h; +} + + }//namespace #endif diff --git a/t.cc b/t.cc index 95d5560..c3f391b 100644 --- a/t.cc +++ b/t.cc @@ -2156,7 +2156,7 @@ if(tot!=partitions(n)) laerror("internal error in partition generation or enumer if(space_dim!=longpow(unitary_n,n)) {cout<>n ; @@ -2284,5 +2284,12 @@ Polynomial qq=q.pow(n); cout <<"test binom "<<(p-qq).norm()<>n ; +cout <<"Hermite = "<(n); +} + }