proj home

Files   Classes   Functions   Hierarchy  

vectest.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 using namespace std;
00003 
00004 
00005 #include <print.h>
00006 #include <vec.h>
00007 #include <vectest.h>
00008 
00009 
00010 void vectest::test01()
00011 {
00012   cout << "Testing vec" << endl;
00013   uintc n=3;
00014   double a1[] = { 0.0, 0.0, 0.10 };
00015   double a2[n] = { 1.0, -3.0, 2.0 };
00016   double a3[n] = { 0.0, 0.0, 0.0 };
00017 
00018   cout << "a1=" << print(a1,a1+n) << endl;
00019   cout << "a2=" << print(a2,a2+n) << endl;
00020   
00021   cout << "v1 is a1" << endl;
00022   vec<double*,double> v1(&a1[0],n);
00023   cout << "v1 += a2" << endl;
00024   v1 += a2;
00025   cout << "v1=" << print(a1,a1+n) << endl;
00026 
00027   cout << "v1 += 3" << endl;
00028   v1 += 3.0;
00029   cout << "v1=" << print(a1,a1+n) << endl;
00030 
00031   cout << SHOW2(v1[1]=2.4) << endl;
00032   cout << "v1=" << print(a1,a1+n) << endl;
00033 
00034   vec<double*,double> x0(&a1[0],n);
00035   vec<double*,double> x1(&a2[0],n);
00036   vec<double*,double> x2(&a3[0],n);
00037 
00038   cout << "Calculating an equation" << endl;
00039   cout << "x2 = x0 + 2(x1-x0)" << endl;
00040   cout << "x0=" << (string)x0 << endl;
00041   cout << "x1=" << (string)x1 << endl;
00042   cout << SHOW2(x2 = x1) << endl;
00043   cout << "x2=" << (string)x2 << endl;
00044   cout << SHOW2(x2 -= x0) << endl;
00045   cout << "x2=" << (string)x2 << endl;
00046   cout << SHOW2(x2 *= 2.0) << endl;
00047   cout << "x2=" << (string)x2 << endl;
00048   cout << SHOW2(x2 += x0) << endl;
00049   cout << "x2=" << (string)x2 << endl;
00050 }
00051 
00052 void vectest::test02()
00053 {
00054   cout << "Using vec to generate binomial coefficients" << endl;
00055   cout << "For D[X[n]] backward difference operator." << endl;
00056   uintc n=5;
00057   double ci[n] = { 1.0, 0.0, 0.0, 0.0, 0.0 };
00058   vec<double*,double> x(&ci[0],n);
00059 
00060   cout << (string)x << endl;
00061   x.difference();
00062   cout << (string)x << endl;
00063   x.difference();
00064   cout << (string)x << endl;
00065   x.difference();
00066   cout << (string)x << endl;
00067   x.difference();
00068   cout << (string)x << endl;
00069 
00070   cout << endl << endl;
00071   cout << "Generating the binomial coefficients." << endl;
00072   cout << "For case N=12" << endl;
00073   uintc N(13);
00074   double di[N];
00075   vec<double*,double> y(&di[0],N);
00076   y.binomial(12);
00077 
00078   cout << (string)y << endl;
00079 }
00080 
00081 
00082 
00083 
00084 

Generated on Fri Mar 4 00:49:28 2011 for Chelton Evans Source by  doxygen 1.5.8