implemented Hermite polynomials
This commit is contained in:
parent
7aae1df938
commit
59f3bb9eea
@ -285,6 +285,12 @@ INSTANTIZE(unsigned int)
|
||||
INSTANTIZE(double)
|
||||
INSTANTIZE(std::complex<double>)
|
||||
|
||||
#define INSTANTIZE2(T) \
|
||||
template Polynomial<T> hermite_polynomial(int); \
|
||||
|
||||
INSTANTIZE2(int)
|
||||
INSTANTIZE2(double)
|
||||
|
||||
|
||||
|
||||
}//namespace
|
||||
|
16
polynomial.h
16
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 <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
|
||||
#endif
|
||||
|
9
t.cc
9
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<<space_dim<<" "<<ipow(unitary_n,n)<<endl;laerror("integer overflow or internal error in space dimensions");}
|
||||
}
|
||||
|
||||
if(1)
|
||||
if(0)
|
||||
{
|
||||
int n;
|
||||
cin >>n ;
|
||||
@ -2284,5 +2284,12 @@ Polynomial<double> qq=q.pow(n);
|
||||
cout <<"test binom "<<(p-qq).norm()<<endl;
|
||||
}
|
||||
|
||||
if(1)
|
||||
{
|
||||
int n;
|
||||
cin >>n ;
|
||||
cout <<"Hermite = "<<hermite_polynomial<int>(n);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user