proj home

Files   Classes   Functions   Hierarchy  

vectest Class Reference

Testing the vec class. More...

#include <vectest.h>

List of all members.

Static Public Member Functions

static void test01 ()
 Adding some vectors of equal length and number operations.
static void test02 ()
 The difference function is used to generate binomial coefficients.


Detailed Description

Testing the vec class.

Definition at line 7 of file vectest.h.


Member Function Documentation

void vectest::test01 (  )  [static]

Adding some vectors of equal length and number operations.

Definition at line 10 of file vectest.cpp.

References print(), and SHOW2.

Referenced by main().

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 }

void vectest::test02 (  )  [static]

The difference function is used to generate binomial coefficients.

Definition at line 52 of file vectest.cpp.

References vec< A, T >::binomial(), and vec< A, T >::difference().

Referenced by main().

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 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:23 2011 for Chelton Evans Source by  doxygen 1.5.8