/[escript]/branches/escript3047_with_pastix2995/escript/test/DataAlgorithmAdapterTestCase.cpp
ViewVC logotype

Diff of /branches/escript3047_with_pastix2995/escript/test/DataAlgorithmAdapterTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 682 by robwdcock, Mon Mar 27 02:43:09 2006 UTC revision 713 by gross, Thu Apr 27 05:03:44 2006 UTC
# Line 46  void DataAlgorithmAdapterTestCase::testA Line 46  void DataAlgorithmAdapterTestCase::testA
46    cout << "\tTesting FMax." << endl;    cout << "\tTesting FMax." << endl;
47    
48    FMax fmax;    FMax fmax;
49    assert(fmax(5,6)==6);    assert(std::abs(fmax(5,6)-6)<=REL_TOL*6);
50    assert(fmax(5,-6)==5);    assert(std::abs(fmax(5,-6)-5)<=REL_TOL*5);
51    assert(fmax(0,0)==0);    assert(std::abs(fmax(0,0)-0)<=REL_TOL*0);
52    assert(fmax(15,-96)==15);    assert(std::abs(fmax(15,-96)-15)<=REL_TOL*15);
53    
54    DataAlgorithmAdapter<FMax> sup(numeric_limits<double>::max()*-1);    DataAlgorithmAdapter<FMax> sup(numeric_limits<double>::max()*-1);
55    sup.resetResult();    sup.resetResult();
# Line 57  void DataAlgorithmAdapterTestCase::testA Line 57  void DataAlgorithmAdapterTestCase::testA
57    sup(-2);    sup(-2);
58    sup(-14);    sup(-14);
59    sup(3);    sup(3);
60    assert(sup.getResult()==3);    assert(std::abs(sup.getResult()-3)<=REL_TOL*3);
61    
62    cout << "\tTesting AbsMax." << endl;    cout << "\tTesting AbsMax." << endl;
63    
64    AbsMax absmax;    AbsMax absmax;
65    assert(absmax(5,6)==6);    assert(std::abs(absmax(5,6)-6)<=REL_TOL*6);
66    assert(absmax(5,-6)==6);    assert(std::abs(absmax(5,-6)-6)<=REL_TOL*6);
67    assert(absmax(0,0)==0);    assert(std::abs(absmax(0,0)-0)<=REL_TOL*6);
68    assert(absmax(15,-96)==96);    assert(std::abs(absmax(15,-96)-96)<=REL_TOL*6);
69    
70    DataAlgorithmAdapter<AbsMax> Lsup(0);    DataAlgorithmAdapter<AbsMax> Lsup(0);
71    Lsup.resetResult();    Lsup.resetResult();
# Line 73  void DataAlgorithmAdapterTestCase::testA Line 73  void DataAlgorithmAdapterTestCase::testA
73    Lsup(2);    Lsup(2);
74    Lsup(5);    Lsup(5);
75    Lsup(-10);    Lsup(-10);
76    assert(Lsup.getResult()==10);    assert(std::abs(Lsup.getResult()-10)<=REL_TOL*10);
77    
78    cout << "\tTesting FMin." << endl;    cout << "\tTesting FMin." << endl;
79    
80    FMin fmin;    FMin fmin;
81    assert(fmin(5,6)==5);    assert(std::abs(fmin(5,6)-5)<=REL_TOL*5);
82    assert(fmin(5,-6)==-6);    assert(std::abs(fmin(5,-6)-(-6))<=REL_TOL*6);
83    assert(fmin(0,0)==0);    assert(std::abs(fmin(0,0)-0)<=REL_TOL*0);
84    assert(fmin(15,-96)==-96);    assert(std::abs(fmin(15,-96)-(-96))<=REL_TOL*96);
85    
86    DataAlgorithmAdapter<FMin> inf(numeric_limits<double>::max());    DataAlgorithmAdapter<FMin> inf(numeric_limits<double>::max());
87    inf.resetResult();    inf.resetResult();
# Line 89  void DataAlgorithmAdapterTestCase::testA Line 89  void DataAlgorithmAdapterTestCase::testA
89    inf(12);    inf(12);
90    inf(2);    inf(2);
91    inf(99);    inf(99);
92    assert(inf.getResult()==1);    assert(std::abs(inf.getResult()-1)<=REL_TOL*1);
93    
94    cout << "\tTesting Length." << endl;    cout << "\tTesting Length." << endl;
95    
96    Length lngth;    Length lngth;
97    assert(lngth(5,6)==std::sqrt(61.0));    assert(std::abs(lngth(5,6)-std::sqrt(61.0))<=REL_TOL*std::sqrt(61.0));
98    assert(lngth(5,-6)==std::sqrt(61.0));    assert(std::abs(lngth(5,-6)-std::sqrt(61.0))<=REL_TOL*std::sqrt(61.0));
99    assert(lngth(0,0)==std::sqrt(0.0));    assert(std::abs(lngth(0,0)-std::sqrt(0.0))<=REL_TOL*std::sqrt(61.0));
100    assert(lngth(15,-96)==std::sqrt(9441.0));    assert(std::abs(lngth(15,-96)-std::sqrt(9441.0))<=REL_TOL*std::sqrt(61.0));
101    
102    DataAlgorithmAdapter<Length> length(0);    DataAlgorithmAdapter<Length> length(0);
103    length.resetResult();    length.resetResult();
# Line 105  void DataAlgorithmAdapterTestCase::testA Line 105  void DataAlgorithmAdapterTestCase::testA
105    length(4);    length(4);
106    length(6);    length(6);
107    length(8);    length(8);
108    assert(length.getResult()==std::sqrt(120.0));    assert(std::abs(length.getResult()-std::sqrt(120.0))<=REL_TOL*std::sqrt(120.0));
109    length.resetResult();    length.resetResult();
110    length(1.5);    length(1.5);
111    length(2.5);    length(2.5);
112    length(3.5);    length(3.5);
113    length(4.5);    length(4.5);
114    assert(length.getResult()==std::sqrt(41.0));    assert(std::abs(length.getResult()-std::sqrt(41.0))<=REL_TOL*std::sqrt(41.0));
115    
116    cout << "\tTesting Trace." << endl;    cout << "\tTesting Trace." << endl;
117    
118    Trace trce;    Trace trce;
119    assert(trce(5,6)==11);    assert(std::abs(trce(5,6)-11)<=REL_TOL*11);
120    assert(trce(5,-6)==-1);    assert(std::abs(trce(5,-6)-(-1))<=REL_TOL*1);
121    assert(trce(0,0)==0);    assert(std::abs(trce(0,0)-0)<=REL_TOL*0);
122    assert(trce(15,-96)==-81);    assert(std::abs(trce(15,-96)-(-81))<=REL_TOL*81);
123    
124    DataAlgorithmAdapter<Trace> trace(0);    DataAlgorithmAdapter<Trace> trace(0);
125    trace.resetResult();    trace.resetResult();
# Line 128  void DataAlgorithmAdapterTestCase::testA Line 128  void DataAlgorithmAdapterTestCase::testA
128    trace(3);    trace(3);
129    trace(4);    trace(4);
130    trace(5);    trace(5);
131    assert(trace.getResult()==15);    assert(std::abs(trace.getResult()-15)<=REL_TOL*15);
132    trace.resetResult();    trace.resetResult();
133    trace(1.5);    trace(1.5);
134    trace(2.5);    trace(2.5);
135    trace(3.5);    trace(3.5);
136    trace(4.5);    trace(4.5);
137    trace(5.5);    trace(5.5);
138    assert(trace.getResult()==17.5);    assert(std::abs(trace.getResult()-17.5)<=REL_TOL*17.5);
139    
140  }  }
141    
# Line 172  void DataAlgorithmAdapterTestCase::testA Line 172  void DataAlgorithmAdapterTestCase::testA
172    
173      // test algorithm on DataExpanded      // test algorithm on DataExpanded
174      FMin fmin_func;      FMin fmin_func;
175      assert(escript::algorithm(dataExp,fmin_func,numeric_limits<double>::max())==0);      assert(std::abs(escript::algorithm(dataExp,fmin_func,numeric_limits<double>::max())-0)<=REL_TOL*0);
176      FMax fmax_func;      FMax fmax_func;
177      assert(escript::algorithm(dataExp,fmax_func,numeric_limits<double>::max()*-1)==5);      assert(std::abs(escript::algorithm(dataExp,fmax_func,numeric_limits<double>::max()*-1)-5)<=REL_TOL*5);
178    
179      // test algorithm on DataTagged      // test algorithm on DataTagged
180      assert(escript::algorithm(dataTag,fmin_func,numeric_limits<double>::max())==0);      assert(std::abs(escript::algorithm(dataTag,fmin_func,numeric_limits<double>::max())-0)<=REL_TOL*0);
181      assert(escript::algorithm(dataTag,fmax_func,numeric_limits<double>::max()*-1)==5);      assert(std::abs(escript::algorithm(dataTag,fmax_func,numeric_limits<double>::max()*-1)-5)<=REL_TOL*5);
182    
183      // test algorithm on DataConstant      // test algorithm on DataConstant
184      assert(escript::algorithm(dataCon,fmin_func,numeric_limits<double>::max())==0);      assert(std::abs(escript::algorithm(dataCon,fmin_func,numeric_limits<double>::max())-0)<=REL_TOL*0);
185      assert(escript::algorithm(dataCon,fmax_func,numeric_limits<double>::max()*-1)==5);      assert(std::abs(escript::algorithm(dataCon,fmax_func,numeric_limits<double>::max()*-1)-5)<=REL_TOL*5);
186    
187    }    }
188    
# Line 230  void DataAlgorithmAdapterTestCase::testD Line 230  void DataAlgorithmAdapterTestCase::testD
230      // test dp_algorithm on DataExpanded      // test dp_algorithm on DataExpanded
231      FMin fmin_func;      FMin fmin_func;
232      escript::dp_algorithm(dataExp,dataExp2,fmin_func,numeric_limits<double>::max());      escript::dp_algorithm(dataExp,dataExp2,fmin_func,numeric_limits<double>::max());
233      assert(dataExp2.getDataPoint(0,0)()==0);      assert(std::abs(dataExp2.getDataPoint(0,0)()-0)<=REL_TOL*0);
234      FMax fmax_func;      FMax fmax_func;
235      escript::dp_algorithm(dataExp,dataExp2,fmax_func,numeric_limits<double>::max()*-1);      escript::dp_algorithm(dataExp,dataExp2,fmax_func,numeric_limits<double>::max()*-1);
236      assert(dataExp2.getDataPoint(0,0)()==5);      assert(std::abs(dataExp2.getDataPoint(0,0)()-5)<=REL_TOL*5);
237    
238      // test dp_algorithm on DataTagged      // test dp_algorithm on DataTagged
239      escript::dp_algorithm(dataTag,dataTag2,fmin_func,numeric_limits<double>::max());      escript::dp_algorithm(dataTag,dataTag2,fmin_func,numeric_limits<double>::max());
240      assert(dataTag2.getDataPoint(0,0)()==0);      assert(std::abs(dataTag2.getDataPoint(0,0)()-0)<=REL_TOL*0);
241      escript::dp_algorithm(dataTag,dataTag2,fmax_func,numeric_limits<double>::max()*-1);      escript::dp_algorithm(dataTag,dataTag2,fmax_func,numeric_limits<double>::max()*-1);
242      assert(dataTag2.getDataPoint(0,0)()==5);      assert(std::abs(dataTag2.getDataPoint(0,0)()-5)<=REL_TOL*5);
243    
244      // test dp_algorithm on DataConstant      // test dp_algorithm on DataConstant
245      escript::dp_algorithm(dataCon,dataCon2,fmin_func,numeric_limits<double>::max());      escript::dp_algorithm(dataCon,dataCon2,fmin_func,numeric_limits<double>::max());
246      assert(dataCon2.getDataPoint(0,0)()==0);      assert(std::abs(dataCon2.getDataPoint(0,0)()-0)<=REL_TOL*0);
247      escript::dp_algorithm(dataCon,dataCon2,fmax_func,numeric_limits<double>::max()*-1);      escript::dp_algorithm(dataCon,dataCon2,fmax_func,numeric_limits<double>::max()*-1);
248      assert(dataCon2.getDataPoint(0,0)()==5);      assert(std::abs(dataCon2.getDataPoint(0,0)()-5)<=REL_TOL*5);
249    
250    }    }
251    

Legend:
Removed from v.682  
changed lines
  Added in v.713

  ViewVC Help
Powered by ViewVC 1.1.26