implemented Hermite polynomials

This commit is contained in:
Jiri Pittner 2021-10-05 17:15:47 +02:00
parent 7aae1df938
commit 59f3bb9eea
3 changed files with 30 additions and 1 deletions

View File

@ -285,6 +285,12 @@ INSTANTIZE(unsigned int)
INSTANTIZE(double) INSTANTIZE(double)
INSTANTIZE(std::complex<double>) INSTANTIZE(std::complex<double>)
#define INSTANTIZE2(T) \
template Polynomial<T> hermite_polynomial(int); \
INSTANTIZE2(int)
INSTANTIZE2(double)
}//namespace }//namespace

View File

@ -23,6 +23,7 @@
#include "la_traits.h" #include "la_traits.h"
#include "vec.h" #include "vec.h"
#include "nonclass.h" #include "nonclass.h"
#include "matexp.h"
namespace LA { namespace LA {
@ -223,5 +224,20 @@ return p*q/poly_gcd(p,q,thr);
} }
template <typename T>
Polynomial<T> hermite_polynomial(int n) //physicists definition
{
Polynomial<T> 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 }//namespace
#endif #endif

9
t.cc
View File

@ -2156,7 +2156,7 @@ if(tot!=partitions(n)) laerror("internal error in partition generation or enumer
if(space_dim!=longpow(unitary_n,n)) {cout<<space_dim<<" "<<ipow(unitary_n,n)<<endl;laerror("integer overflow or internal error in space dimensions");} if(space_dim!=longpow(unitary_n,n)) {cout<<space_dim<<" "<<ipow(unitary_n,n)<<endl;laerror("integer overflow or internal error in space dimensions");}
} }
if(1) if(0)
{ {
int n; int n;
cin >>n ; cin >>n ;
@ -2284,5 +2284,12 @@ Polynomial<double> qq=q.pow(n);
cout <<"test binom "<<(p-qq).norm()<<endl; cout <<"test binom "<<(p-qq).norm()<<endl;
} }
if(1)
{
int n;
cin >>n ;
cout <<"Hermite = "<<hermite_polynomial<int>(n);
}
} }