00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <iostream>
00042 #include <iomanip>
00043 #include <math.h>
00044
00045 #include "Sacado.hpp"
00046 #include "Sacado_PCE_Hermite.hpp"
00047
00048 #ifdef HAVE_SACADO_STOKHOS
00049 #include "Sacado_PCE_OrthogPoly.hpp"
00050 #include "Stokhos_HermiteEBasis.hpp"
00051 #endif
00052
00053
00054 template <typename ScalarT>
00055 ScalarT func(const ScalarT& a) {
00056 ScalarT r = std::exp(a);
00057
00058 return r;
00059 }
00060
00061 int main(int argc, char **argv)
00062 {
00063 try {
00064 const unsigned int d = 7;
00065 Sacado::PCE::Hermite<double>::initWorkspace(d);
00066 Sacado::PCE::Hermite<double> u(d);
00067 u.fastAccessCoeff(0) = 1.0;
00068 u.fastAccessCoeff(1) = 0.4;
00069 u.fastAccessCoeff(2) = 0.06;
00070 u.fastAccessCoeff(3) = 0.002;
00071
00072 Sacado::PCE::Hermite<double> v = std::log(u);
00073
00074
00075 std::cout.precision(12);
00076 std::cout << "u (hermite basis) = " << u << std::endl;
00077 std::cout << "u (standard basis) = " << u.toStandardBasis() << std::endl;
00078
00079 std::cout << "v (hermite basis) = " << v << std::endl;
00080 std::cout << "v (standard basis) = " << v.toStandardBasis() << std::endl;
00081
00082 Sacado::PCE::StandardPoly<double> us = u.toStandardBasis();
00083 Sacado::Tay::Taylor<double> ut(d);
00084 for (unsigned int i=0; i<=d; i++)
00085 ut.fastAccessCoeff(i) = us.coeff(i);
00086
00087 Sacado::Tay::Taylor<double> vt = std::log(ut);
00088
00089
00090 std::cout.precision(12);
00091 std::cout << "u (taylor basis) = " << ut << std::endl;
00092 std::cout << "v (taylor basis) = " << vt << std::endl;
00093
00094 #ifdef HAVE_SACADO_STOKHOS
00095 typedef Stokhos::HermiteEBasis<double> basis_type;
00096 typedef Sacado::PCE::OrthogPoly<double>::expansion_type expansion_type;
00097 Teuchos::RCP<basis_type> basis = Teuchos::rcp(new basis_type(d));
00098 Teuchos::RCP<expansion_type> expansion =
00099 Teuchos::rcp(new expansion_type(basis));
00100 Sacado::PCE::OrthogPoly<double>::initExpansion(expansion);
00101 Sacado::PCE::OrthogPoly<double> ue(d+1);
00102 for (unsigned int i=0; i<=d; i++)
00103 ue.fastAccessCoeff(i) = u.coeff(i);
00104
00105 Sacado::PCE::OrthogPoly<double> ve = std::log(ue);
00106
00107
00108 std::cout << "ue (hermite basis) = " << ue << std::endl;
00109 std::cout << "ue (standard basis) = " << ue.toStandardBasis() << std::endl;
00110 std::cout << "ve (hermite basis) = " << ve << std::endl;
00111 std::cout << "ve (standard basis) = " << ve.toStandardBasis() << std::endl;
00112 #endif
00113
00114 std::cout << "\nExample passed!" << std::endl;
00115 }
00116 catch (std::exception& e) {
00117 std::cout << e.what() << std::endl;
00118 }
00119 }