/[escript]/trunk/escript/test/DataTestCase.cpp
ViewVC logotype

Diff of /trunk/escript/test/DataTestCase.cpp

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

revision 1795 by phornby, Thu Feb 28 17:19:44 2008 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 32  using namespace std; Line 32  using namespace std;
32  using namespace CppUnitTest;  using namespace CppUnitTest;
33  using namespace escript;  using namespace escript;
34  using namespace esysUtils;  using namespace esysUtils;
35    using namespace escript::DataTypes;
36    
37  void DataTestCase::setUp() {  void DataTestCase::setUp() {
38    //    //
# Line 43  void DataTestCase::tearDown() { Line 44  void DataTestCase::tearDown() {
44    // This is called after each test has been run    // This is called after each test has been run
45  }  }
46    
47    
48    
49    namespace
50    {
51    
52    inline
53    DataTypes::ValueType::reference
54    getRef(Data& d,int s1, int p1, int x, int y)
55    {
56        return d.getDataAtOffset(d.getDataOffset(s1,p1)+getRelIndex(d.getDataPointShape(),x,y));
57    }
58    
59    inline
60    DataTypes::ValueType::reference
61    getRef(Data& d, int x, int y)
62    {
63        return d.getDataAtOffset(getRelIndex(d.getDataPointShape(),x,y));
64    }
65    
66    }
67    
68  void DataTestCase::testSlicing() {  void DataTestCase::testSlicing() {
69    
70      using namespace escript::DataTypes;
71    cout << endl;    cout << endl;
72    
73    {    {
74    
75      cout << "\tTest get-slicing DataConstant" << endl;      cout << "\tTest get-slicing DataConstant" << endl;
76    
77      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
78      viewShape.push_back(2);      viewShape.push_back(2);
79      viewShape.push_back(3);      viewShape.push_back(3);
80      Data data(1.3,viewShape,FunctionSpace(),false);      Data data(1.3,viewShape,FunctionSpace(),false);
81    
82      //cout << data.toString() << endl;      //cout << data.toString() << endl;
83    
84      DataArrayView::RegionType region;      DataTypes::RegionType region;
85      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
86      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
87    
88      Data slice1(data.getSlice(region));      Data slice1(data.getSlice(region));
89    
90      //cout << slice1.toString() << endl;      //cout << slice1.toString() << endl;
91    
92      assert(slice1.getDataPointRank()==0);      assert(slice1.getDataPointRank()==0);
93      assert(slice1.getDataPoint(0,0)()==1.3);      assert(slice1.getDataPoint(0,0)==1.3);
94    
95      region.clear();      region.clear();
96      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
97      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
98    
99      Data slice2(data.getSlice(region));      Data slice2(data.getSlice(region));
100    
101      //cout << slice2.toString() << endl;      //cout << slice2.toString() << endl;
102    
103      assert(slice2.getDataPointRank()==2);      assert(slice2.getDataPointRank()==2);
104      assert(slice2.getDataPoint(0,0)(0,0)==1.3);      int off1=slice2.getDataOffset(0,0);
105    //     assert(slice2.getDataPoint(0,0)(0,0)==1.3);
106        assert(slice2.getDataAtOffset(off1+getRelIndex(slice2.getDataPointShape(),0,0))==1.3);
107    
108      region.clear();      region.clear();
109      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
110      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
111    
112      Data slice3(data.getSlice(region));      Data slice3(data.getSlice(region));
113    
114      //cout << slice3.toString() << endl;      //cout << slice3.toString() << endl;
115    
116      assert(slice3.getDataPointRank()==2);      assert(slice3.getDataPointRank()==2);
117      assert(slice3.getDataPoint(0,0)(0,0)==1.3);      off1=slice3.getDataOffset(0,0);
118      assert(slice3.getDataPoint(0,0)(0,1)==1.3);  //     assert(slice3.getDataPoint(0,0)(0,0)==1.3);
119    //     assert(slice3.getDataPoint(0,0)(0,1)==1.3);
120        assert(slice3.getDataAtOffset(off1+getRelIndex(slice3.getDataPointShape(),0,0))==1.3);
121        assert(slice3.getDataAtOffset(off1+getRelIndex(slice3.getDataPointShape(),0,1))==1.3);
122    
123    }    }
124    
# Line 98  void DataTestCase::testSlicing() { Line 126  void DataTestCase::testSlicing() {
126    
127      cout << "\tTest set-slicing DataConstant" << endl;      cout << "\tTest set-slicing DataConstant" << endl;
128    
129      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
130      Data source(10.0,viewShape,FunctionSpace(),false);      Data source(10.0,viewShape,FunctionSpace(),false);
131    
132      //cout << source.toString() << endl;      //cout << source.toString() << endl;
# Line 109  void DataTestCase::testSlicing() { Line 137  void DataTestCase::testSlicing() {
137    
138      //cout << target.toString() << endl;      //cout << target.toString() << endl;
139    
140      DataArrayView::RegionType region;      DataTypes::RegionType region;
141      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
142      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
143    
144      target.setSlice(source,region);      target.setSlice(source,region);
145    
146      //cout << target.toString() << endl;      //cout << target.toString() << endl;
147    
148      assert(target.getDataPoint(0,0)(0,0)==source.getDataPoint(0,0)());      int off1=target.getDataOffset(0,0);
149        assert(target.getDataAtOffset(off1+getRelIndex(target.getDataPointShape(),0,0)==source.getDataPoint(0,0)));
150    
151    }    }
152    
153    {    {
154    
155      cout << "\tTest get-slicing DataTagged" << endl;      cout << "\tTest get-slicing DataTagged" << endl;
   
156      //      //
157      // create a DataTagged with a default value only      // create a DataTagged with a default value only
158    
159      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
160      viewShape.push_back(2);      viewShape.push_back(2);
161      viewShape.push_back(3);      viewShape.push_back(3);
162      Data data(1.3,viewShape,FunctionSpace(),false);      Data data(1.3,viewShape,FunctionSpace(),false);
163      data.tag();      data.tag();
164      data.getDataPoint(0,0)(0,0)=1.0;      data.getDataAtOffset(data.getDataOffset(0,0)+getRelIndex(viewShape,0,0))=1.0;
165      data.getDataPoint(0,0)(1,1)=2.0;      data.getDataAtOffset(data.getDataOffset(0,0)+getRelIndex(viewShape,1,1))=2.0;  
166    //     data.getDataPoint(0,0)(0,0)=1.0;
167    //     data.getDataPoint(0,0)(1,1)=2.0;
168    
169      //cout << data.toString() << endl;      //cout << data.toString() << endl;
   
170      //      //
171      // create a scalar slice      // create a scalar slice
172    
173      DataArrayView::RegionType region;      DataTypes::RegionType region;
174      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
175      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
176    
177      Data slice1(data.getSlice(region));      Data slice1(data.getSlice(region));
   
178      //cout << slice1.toString() << endl;      //cout << slice1.toString() << endl;
179    
180      assert(slice1.isTagged());      assert(slice1.isTagged());
181      assert(slice1.getDataPointRank()==0);      assert(slice1.getDataPointRank()==0);
182      assert(slice1.getDataPoint(0,0)()==1.0);      assert(slice1.getDataPoint(0,0)==1.0);
   
183      //      //
184      // create a rank 2 slice with one value      // create a rank 2 slice with one value
185    
186      region.clear();      region.clear();
187      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
188      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
189    
190      Data slice2(data.getSlice(region));      Data slice2(data.getSlice(region));
191    
# Line 166  void DataTestCase::testSlicing() { Line 193  void DataTestCase::testSlicing() {
193    
194      assert(slice2.isTagged());      assert(slice2.isTagged());
195      assert(slice2.getDataPointRank()==2);      assert(slice2.getDataPointRank()==2);
196      assert(slice2.getDataPoint(0,0)(0,0)==1.0);  
197        assert(slice2.getDataAtOffset(slice2.getDataOffset(0,0)+getRelIndex(slice2.getDataPointShape(),0,0))==1.0);
198    
199      //      //
200      // create a rank 2 slice with four values      // create a rank 2 slice with four values
201    
202      region.clear();      region.clear();
203      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
204      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
205    
206      Data slice3(data.getSlice(region));      Data slice3(data.getSlice(region));
207    
# Line 181  void DataTestCase::testSlicing() { Line 209  void DataTestCase::testSlicing() {
209    
210      assert(slice3.isTagged());      assert(slice3.isTagged());
211      assert(slice3.getDataPointRank()==2);      assert(slice3.getDataPointRank()==2);
212      assert(slice3.getDataPoint(0,0)(0,0)==1.0);      assert(getRef(slice3,0,0,0,0)==1.0);
213      assert(slice3.getDataPoint(0,0)(0,1)==1.3);      assert(getRef(slice3,0,0,0,1)==1.3);
214      assert(slice3.getDataPoint(0,0)(1,0)==1.3);      assert(getRef(slice3,0,0,1,0)==1.3);
215      assert(slice3.getDataPoint(0,0)(1,1)==2.0);      assert(getRef(slice3,0,0,1,1)==2.0);
216    
217      //      //
218      // add a value for tag "1"      // add a value for tag "1"
219    
220      DataArrayView::ValueType viewData(6);      DataTypes::ValueType viewData(6);
221      for (int i=0;i<viewData.size();i++) {      for (int i=0;i<viewData.size();i++) {
222        viewData[i]=i;        viewData[i]=i;
223      }      }
224      DataArrayView dataView(viewData,viewShape);  //    DataArrayView dataView(viewData,viewShape);
225    
226    //     data.setTaggedValueFromCPP(1, dataView);
227        data.setTaggedValueFromCPP(1, viewShape, viewData);
228    
     data.setTaggedValueFromCPP(1, dataView);  
229    
230      //      //
231      // create a full slice      // create a full slice
232    
233      region.clear();      region.clear();
234      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
235      region.push_back(DataArrayView::RegionType::value_type(0,3));      region.push_back(DataTypes::RegionType::value_type(0,3));
236    
237      Data slice4(data.getSlice(region));      Data slice4(data.getSlice(region));
238    
# Line 210  void DataTestCase::testSlicing() { Line 240  void DataTestCase::testSlicing() {
240    
241      assert(slice4.isTagged());      assert(slice4.isTagged());
242      assert(slice4.getDataPointRank()==2);      assert(slice4.getDataPointRank()==2);
243      assert(slice4.getDataPoint(0,0)(0,0)==0);      assert(getRef(slice4,0,0,0,0)==0);
244      assert(slice4.getDataPoint(0,0)(0,1)==2);      assert(getRef(slice4,0,0,0,1)==2);
245      assert(slice4.getDataPoint(0,0)(0,2)==4);      assert(getRef(slice4,0,0,0,2)==4);
246      assert(slice4.getDataPoint(0,0)(1,0)==1);      assert(getRef(slice4,0,0,1,0)==1);
247      assert(slice4.getDataPoint(0,0)(1,1)==3);      assert(getRef(slice4,0,0,1,1)==3);
248      assert(slice4.getDataPoint(0,0)(1,2)==5);      assert(getRef(slice4,0,0,1,2)==5);
249    
250    }    }
251    
# Line 226  void DataTestCase::testSlicing() { Line 256  void DataTestCase::testSlicing() {
256      //      //
257      // create a source DataTagged with a scalar default value only      // create a source DataTagged with a scalar default value only
258    
259      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
260      Data source(10.0,viewShape,FunctionSpace(),false);      Data source(10.0,viewShape,FunctionSpace(),false);
261      source.tag();      source.tag();
262    
# Line 245  void DataTestCase::testSlicing() { Line 275  void DataTestCase::testSlicing() {
275      //      //
276      // set a slice in target from source      // set a slice in target from source
277    
278      DataArrayView::RegionType region;      DataTypes::RegionType region;
279      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
280      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
281    
282      target.setSlice(source,region);      target.setSlice(source,region);
283    
# Line 255  void DataTestCase::testSlicing() { Line 285  void DataTestCase::testSlicing() {
285    
286      assert(target.isTagged());      assert(target.isTagged());
287      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
288      assert(target.getDataPoint(0,0)(0,0)==1.3);      assert(getRef(target,0,0,0,0)==1.3);
289      assert(target.getDataPoint(0,0)(0,1)==1.3);      assert(getRef(target,0,0,0,1)==1.3);
290      assert(target.getDataPoint(0,0)(0,2)==1.3);      assert(getRef(target,0,0,0,2)==1.3);
291      assert(target.getDataPoint(0,0)(1,0)==1.3);      assert(getRef(target,0,0,1,0)==1.3);
292      assert(target.getDataPoint(0,0)(1,1)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,1,1)==source.getDataPoint(0,0));
293      assert(target.getDataPoint(0,0)(1,2)==1.3);      assert(getRef(target,0,0,1,2)==1.3);
294    
295      //      //
296      // add a value for tag "1" to target      // add a value for tag "1" to target
297    
298      DataArrayView::ValueType viewData(6);      DataTypes::ValueType viewData(6);
299      for (int i=0;i<viewData.size();i++) {      for (int i=0;i<viewData.size();i++) {
300        viewData[i]=i;        viewData[i]=i;
301      }      }
302      DataArrayView dataView(viewData,viewShape);  //     DataArrayView dataView(viewData,viewShape);
303    //
304      target.setTaggedValueFromCPP(1, dataView);  //     target.setTaggedValueFromCPP(1, dataView);
305        target.setTaggedValueFromCPP(1, viewShape, viewData);
306    
307      //cout << "target:\n" << target.toString() << endl;      //cout << "target:\n" << target.toString() << endl;
308    
# Line 279  void DataTestCase::testSlicing() { Line 310  void DataTestCase::testSlicing() {
310      // set a slice in target from source      // set a slice in target from source
311    
312      region.clear();      region.clear();
313      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
314      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
315    
316      target.setSlice(source,region);      target.setSlice(source,region);
317    
# Line 288  void DataTestCase::testSlicing() { Line 319  void DataTestCase::testSlicing() {
319    
320      assert(target.isTagged());      assert(target.isTagged());
321      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
322      assert(target.getDataPoint(0,0)(0,0)==0);      assert(getRef(target,0,0,0,0)==0);
323      assert(target.getDataPoint(0,0)(0,1)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,0,1)==source.getDataPoint(0,0));
324      assert(target.getDataPoint(0,0)(0,2)==4);      assert(getRef(target,0,0,0,2)==4);
325      assert(target.getDataPoint(0,0)(1,0)==1);      assert(getRef(target,0,0,1,0)==1);
326      assert(target.getDataPoint(0,0)(1,1)==3);      assert(getRef(target,0,0,1,1)==3);
327      assert(target.getDataPoint(0,0)(1,2)==5);      assert(getRef(target,0,0,1,2)==5);
328    
329      //      //
330      // add a value for tag "2" to source      // add a value for tag "2" to source
331    
332      DataArrayView::ShapeType viewShape2;      DataTypes::ShapeType viewShape2;
333      DataArrayView::ValueType viewData2(1);      DataTypes::ValueType viewData2(1);
334      viewData2[0]=6;      viewData2[0]=6;
335      DataArrayView dataView2(viewData2,viewShape2);  //     DataArrayView dataView2(viewData2,viewShape2);
336    //
337      source.setTaggedValueFromCPP(2, dataView2);  //     source.setTaggedValueFromCPP(2, dataView2);
338        source.setTaggedValueFromCPP(2, viewShape2, viewData2);
339    
340      //cout << "source:\n" << source.toString() << endl;      //cout << "source:\n" << source.toString() << endl;
341    
# Line 311  void DataTestCase::testSlicing() { Line 343  void DataTestCase::testSlicing() {
343      // set a slice in target from source      // set a slice in target from source
344    
345      region.clear();      region.clear();
346      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
347      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
348    
349      target.setSlice(source,region);      target.setSlice(source,region);
350    
# Line 352  void DataTestCase::testSlicing() { Line 384  void DataTestCase::testSlicing() {
384    
385      cout << "\tTest get-slicing DataExpanded" << endl;      cout << "\tTest get-slicing DataExpanded" << endl;
386    
387      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
388      viewShape.push_back(2);      viewShape.push_back(2);
389      viewShape.push_back(3);      viewShape.push_back(3);
390      Data temp(1.3,viewShape,FunctionSpace(),true);      Data temp(1.3,viewShape,FunctionSpace(),true);
391    
392      temp.getDataPoint(0,0)(0,0)=0.0;      getRef(temp,0,0,0,0)=0.0;
393      temp.getDataPoint(0,0)(1,1)=1.0;      getRef(temp,0,0,1,1)=1.0;
394    
395      DataArrayView::RegionType region;      DataTypes::RegionType region;
396      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
397      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
398    
399      Data slice(temp.getSlice(region));      Data slice(temp.getSlice(region));
400    
401      assert(slice.getDataPointRank()==0);      assert(slice.getDataPointRank()==0);
402      assert(slice.getDataPoint(0,0)()==0.0);      assert(slice.getDataPoint(0,0)==0.0);
403    
404      region.clear();      region.clear();
405      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
406      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
407    
408      slice=temp.getSlice(region);      slice=temp.getSlice(region);
409    
410      assert(slice.getDataPointRank()==2);      assert(slice.getDataPointRank()==2);
411      assert(slice.getDataPoint(0,0)(0,0)==0.0);      assert(getRef(slice,0,0,0,0)==0.0);
412    
413      region.clear();      region.clear();
414      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
415      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
416    
417      slice=temp.getSlice(region);      slice=temp.getSlice(region);
418    
419      assert(slice.getDataPoint(0,0)(0,0)==0.0);      assert(getRef(slice,0,0,0,0)==0.0);
420      assert(slice.getDataPoint(0,0)(1,1)==1.0);      assert(getRef(slice,0,0,1,1)==1.0);
421    
422    }    }
423    
# Line 393  void DataTestCase::testSlicing() { Line 425  void DataTestCase::testSlicing() {
425    
426      cout << "\tTest set-slicing DataExpanded" << endl;      cout << "\tTest set-slicing DataExpanded" << endl;
427    
428      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
429      Data source(10.0,viewShape,FunctionSpace(),true);      Data source(10.0,viewShape,FunctionSpace(),true);
430    
431      viewShape.push_back(2);      viewShape.push_back(2);
432      viewShape.push_back(3);      viewShape.push_back(3);
433      Data target(1.3,viewShape,FunctionSpace(),true);      Data target(1.3,viewShape,FunctionSpace(),true);
434    
435      DataArrayView::RegionType region;      DataTypes::RegionType region;
436      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
437      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
438    
439      target.setSlice(source,region);      target.setSlice(source,region);
440    
441      assert(target.getDataPoint(0,0)(0,0)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,0,0)==source.getDataPoint(0,0));
442    
443    }    }
444    
# Line 418  void DataTestCase::testAll() { Line 450  void DataTestCase::testAll() {
450    
451    cout << "\tCreate a Data object from a DataArrayView" << endl;    cout << "\tCreate a Data object from a DataArrayView" << endl;
452    
453    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
454    viewShape.push_back(3);    viewShape.push_back(3);
455    DataArrayView::ValueType viewData(3);    DataTypes::ValueType viewData(3);
456    for (int i=0;i<viewShape[0];++i) {    for (int i=0;i<viewShape[0];++i) {
457      viewData[i]=i;      viewData[i]=i;
458    }    }
459    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
460    
461    bool expanded=true;    bool expanded=true;
462    Data exData(myView,FunctionSpace(),expanded);    Data exData(viewData,viewShape,FunctionSpace(),expanded);
463    Data cData(myView);  //   Data cData(myView);
464      Data cData(viewData,viewShape,FunctionSpace());
465    Data result;    Data result;
466    
467    assert(exData.isExpanded());    assert(exData.isExpanded());
# Line 447  void DataTestCase::testMore() { Line 480  void DataTestCase::testMore() {
480    
481    cout << "\tCreate a Data object from a DataArrayView" << endl;    cout << "\tCreate a Data object from a DataArrayView" << endl;
482    
483    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
484    viewShape.push_back(3);    viewShape.push_back(3);
485    DataArrayView::ValueType viewData(3);    DataTypes::ValueType viewData(3);
486    for (int i=0;i<viewShape[0];++i) {    for (int i=0;i<viewShape[0];++i) {
487      viewData[i]=i;      viewData[i]=i;
488    }    }
489    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
490    
491    bool expanded=true;    bool expanded=true;
492    Data exData(myView,FunctionSpace(),expanded);    Data exData(viewData,viewShape,FunctionSpace(),expanded);
493    Data cData(myView);    Data cData(viewData,viewShape);
494    Data result;    Data result;
495    
496    assert(exData.isExpanded());    assert(exData.isExpanded());
# Line 491  void DataTestCase::testDataConstant() { Line 524  void DataTestCase::testDataConstant() {
524    
525    cout << "\tCreate a DataConstant object from a DataArrayView" << endl;    cout << "\tCreate a DataConstant object from a DataArrayView" << endl;
526    
527    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
528    viewShape.push_back(2);    viewShape.push_back(2);
529    viewShape.push_back(3);    viewShape.push_back(3);
530    viewShape.push_back(4);    viewShape.push_back(4);
531    DataArrayView::ValueType viewData(2*3*4);    DataTypes::ValueType viewData(2*3*4);
532    for (int i=0;i<DataArrayView::noValues(viewShape);++i) {    for (int i=0;i<DataTypes::noValues(viewShape);++i) {
533      viewData[i]=i;      viewData[i]=i;
534    }    }
535    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
536    
537    Data left(myView);    Data left(viewData,viewShape);
538    Data right(myView);    Data right(viewData,viewShape);
539    Data result;    Data result;
540    
541    cout << "\tTest some basic operations" << endl;    cout << "\tTest some basic operations" << endl;
# Line 532  void DataTestCase::testDataTagged() { Line 565  void DataTestCase::testDataTagged() {
565    
566      cout << "\tCreate a DataTagged object with a default value only." << endl;      cout << "\tCreate a DataTagged object with a default value only." << endl;
567    
568      DataTagged::TagListType keys;  //    DataTagged::TagListType keys;
569    
570      DataTagged::ValueListType values;  //    DataTagged::ValueListType values;
571    
572      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
573      viewShape.push_back(3);      viewShape.push_back(3);
574    
575      DataArrayView::ValueType viewData(3);      DataTypes::ValueType viewData(3);
576      for (int i=0;i<viewShape[0];i++) {      for (int i=0;i<viewShape[0];i++) {
577        viewData[i]=i;        viewData[i]=i;
578      }      }
579      DataArrayView defaultValue(viewData,viewShape);  /*    DataArrayView defaultValue(viewData,viewShape);
580    
581      bool expanded=false;      bool expanded=false;
582    
583      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);*/
584        int arr[1]={1};     // iso c++ does not like empty arrays
585        DataTagged* dt=new DataTagged(FunctionSpace(),viewShape,arr,viewData);
586        Data myData(dt);
587    
588      // cout << myData.toString() << endl;      // cout << myData.toString() << endl;
589    
# Line 556  void DataTestCase::testDataTagged() { Line 592  void DataTestCase::testDataTagged() {
592      assert(myData.getTagNumber(0)==1);      assert(myData.getTagNumber(0)==1);
593      assert(myData.getDataPointRank()==1);      assert(myData.getDataPointRank()==1);
594      assert(myData.getLength()==3);      assert(myData.getLength()==3);
595        
596      DataArrayView myDataView = myData.getPointDataView();      assert(myData.getNoValues()==3);
597      assert(!myDataView.isEmpty());      assert(myData.getDataAtOffset(0)==0.0);
598      assert(myDataView.getOffset()==0);      assert(myData.getDataAtOffset(1)==1.0);
599      assert(myDataView.getRank()==1);      assert(myData.getDataAtOffset(2)==2.0);
600      assert(myDataView.noValues()==3);  
601      assert(myDataView.getShape().size()==1);  //     DataArrayView myDataView = myData.getPointDataView();
602      assert(myDataView(0)==0.0);  //     assert(!myDataView.isEmpty());
603      assert(myDataView(1)==1.0);  //     assert(myDataView.getOffset()==0);
604      assert(myDataView(2)==2.0);  //     assert(myDataView.getRank()==1);
605    //     assert(myDataView.noValues()==3);
606      myDataView = myData.getDataPoint(0,0);  //     assert(myDataView.getShape().size()==1);
607      assert(!myDataView.isEmpty());  //     assert(myDataView(0)==0.0);
608      assert(myDataView.getOffset()==0);  //     assert(myDataView(1)==1.0);
609      assert(myDataView.getRank()==1);  //     assert(myDataView(2)==2.0);
610      assert(myDataView.noValues()==3);  
611      assert(myDataView.getShape().size()==1);  //     myDataView = myData.getDataPoint(0,0);
612      assert(myDataView(0)==0.0);  //     assert(!myDataView.isEmpty());
613      assert(myDataView(1)==1.0);  //     assert(myDataView.getOffset()==0);
614      assert(myDataView(2)==2.0);  //     assert(myDataView.getRank()==1);
615    //     assert(myDataView.noValues()==3);
616    //     assert(myDataView.getShape().size()==1);
617    //     assert(myDataView(0)==0.0);
618    //     assert(myDataView(1)==1.0);
619    //     assert(myDataView(2)==2.0);
620    
621      double* sampleData=myData.getSampleData(0);      double* sampleData=myData.getSampleData(0);
622      for (int i=0; i<myDataView.noValues(); i++) {      for (int i=0; i<myData.getNoValues(); i++) {
623        assert(sampleData[i]==i);        assert(sampleData[i]==i);
624      }      }
625      // use a non-existent tag so we get a pointer to      // use a non-existent tag so we get a pointer to
# Line 591  void DataTestCase::testDataTagged() { Line 632  void DataTestCase::testDataTagged() {
632      cout << "\tTest setting of a tag and associated value." << endl;      cout << "\tTest setting of a tag and associated value." << endl;
633    
634      // value for tag "1"      // value for tag "1"
635      DataArrayView::ValueType eTwoData(viewData);      DataTypes::ValueType eTwoData(viewData);
636      DataArrayView eTwoView(eTwoData, viewShape);   //   DataArrayView eTwoView(eTwoData, viewShape);
637      for (int i=0;i<eTwoView.getShape()[0];i++) {      for (int i=0;i<viewShape[0];i++) {
638        eTwoView(i)=i+2.0;        eTwoData[i]=i+2.0;
639      }      }
640    
641      myData.setTaggedValueFromCPP(1,eTwoView);      myData.setTaggedValueFromCPP(1,viewShape, eTwoData);
642    
643      assert(myData.getLength()==6);      assert(myData.getLength()==6);
644    
645      myDataView = myData.getDataPoint(0,0);      int offset=myData.getDataOffset(0,0);
646      assert(myDataView==eTwoView);  //    myDataView = myData.getDataPoint(0,0);
647      assert(!myDataView.isEmpty());  //     assert(myDataView==eTwoView);
648      assert(myDataView.getOffset()==3);  //     assert(!myDataView.isEmpty());
649      assert(myDataView.getRank()==1);      assert(offset==3);
650      assert(myDataView.noValues()==3);      assert(myData.getDataPointRank()==1);
651      assert(myDataView.getShape().size()==1);      assert(myData.getNoValues()==3);
652      assert(myDataView(0)==2);  //    assert(myDataView.getShape().size()==1);
653      assert(myDataView(1)==3);  
654      assert(myDataView(2)==4);      assert(myData.getDataAtOffset(offset+0)==2);
655        assert(myData.getDataAtOffset(offset+1)==3);
656        assert(myData.getDataAtOffset(offset+2)==4);
657    
658      sampleData=myData.getSampleDataByTag(1);      sampleData=myData.getSampleDataByTag(1);
659      for (int i=0; i<myDataView.noValues(); i++) {      for (int i=0; i<myData.getNoValues(); i++) {
660        assert(sampleData[i]==i+2);        assert(sampleData[i]==i+2);
661      }      }
662    
# Line 623  void DataTestCase::testDataTagged() { Line 666  void DataTestCase::testDataTagged() {
666    
667      cout << "\tCreate a DataTagged object via tag() method." << endl;      cout << "\tCreate a DataTagged object via tag() method." << endl;
668    
669      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
670      viewShape.push_back(2);      viewShape.push_back(2);
671      viewShape.push_back(3);      viewShape.push_back(3);
672      Data myData(1.3,viewShape,FunctionSpace(),false);      Data myData(1.3,viewShape,FunctionSpace(),false);
# Line 638  void DataTestCase::testDataTagged() { Line 681  void DataTestCase::testDataTagged() {
681      assert(myData.getLength()==6);      assert(myData.getLength()==6);
682    
683      // check default value      // check default value
684      DataArrayView myDataView = myData.getPointDataView();  //     DataArrayView myDataView = myData.getPointDataView();
685      assert(!myDataView.isEmpty());      assert(!myData.isEmpty());
686      assert(myDataView.getOffset()==0);  //     assert(myDataView.getOffset()==0);
687      assert(myDataView.getRank()==2);      assert(myData.getDataPointRank()==2);
688      assert(myDataView.noValues()==6);      assert(myData.getNoValues()==6);
689      assert(myDataView.getShape().size()==2);      assert(myData.getDataPointShape().size()==2);
690      assert(myDataView(0,0)==1.3);      assert(getRef(myData,0,0)==1.3);
691      assert(myDataView(0,1)==1.3);      assert(getRef(myData,0,1)==1.3);
692      assert(myDataView(0,2)==1.3);      assert(getRef(myData,0,2)==1.3);
693      assert(myDataView(1,0)==1.3);      assert(getRef(myData,1,0)==1.3);
694      assert(myDataView(1,1)==1.3);      assert(getRef(myData,1,1)==1.3);
695      assert(myDataView(1,2)==1.3);      assert(getRef(myData,1,2)==1.3);
696    
697      // check value for data-point (0,0).      // check value for data-point (0,0).
698      myDataView = myData.getDataPoint(0,0);  //     myDataView = myData.getDataPoint(0,0);
699      assert(!myDataView.isEmpty());      assert(!myData.isEmpty());
700      assert(myDataView.getOffset()==0);  //     assert(myDataView.getOffset()==0);
701      assert(myDataView.getRank()==2);      assert(myData.getDataPointRank()==2);
702      assert(myDataView.noValues()==6);      assert(myData.getNoValues()==6);
703      assert(myDataView.getShape().size()==2);      assert(myData.getDataPointShape().size()==2);
704      assert(myDataView(0,0)==1.3);      assert(getRef(myData,0,0)==1.3);
705      assert(myDataView(0,1)==1.3);      assert(getRef(myData,0,1)==1.3);
706      assert(myDataView(0,2)==1.3);      assert(getRef(myData,0,2)==1.3);
707      assert(myDataView(1,0)==1.3);      assert(getRef(myData,1,0)==1.3);
708      assert(myDataView(1,1)==1.3);      assert(getRef(myData,1,1)==1.3);
709      assert(myDataView(1,2)==1.3);      assert(getRef(myData,1,2)==1.3);
710    
711    }    }
712    
# Line 676  void DataTestCase::testDataTaggedExcepti Line 719  void DataTestCase::testDataTaggedExcepti
719    cout << "\tTest DataTagged exceptions." << endl;    cout << "\tTest DataTagged exceptions." << endl;
720    
721    Data myData;    Data myData;
   DataArrayView myView;  
722    
723    try {    try {
724        myData.getSampleDataByTag(0);;        myData.getSampleDataByTag(0);;
# Line 688  void DataTestCase::testDataTaggedExcepti Line 730  void DataTestCase::testDataTaggedExcepti
730    }    }
731    
732    try {    try {
733        myData.setTaggedValueFromCPP(0,myView);;        myData.setTaggedValueFromCPP(0,DataTypes::ShapeType(), DataTypes::ValueType());;
734        assert(false);        assert(false);
735    }    }
736    catch (EsysException&) {    catch (EsysException&) {
# Line 702  void DataTestCase::testConstructors() { Line 744  void DataTestCase::testConstructors() {
744    
745    cout << endl;    cout << endl;
746    
747    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
748    {    {
749      cout << "\tCreate an Empty Data object" << endl;      cout << "\tCreate an Empty Data object" << endl;
750      Data temp(1.3,viewShape,FunctionSpace(),false);      Data temp(1.3,viewShape,FunctionSpace(),false);
# Line 720  void DataTestCase::testOperations() { Line 762  void DataTestCase::testOperations() {
762    cout << endl;    cout << endl;
763    
764    // define the shape for the DataArrayView test data    // define the shape for the DataArrayView test data
765    DataArrayView::ShapeType shape;    DataTypes::ShapeType shape;
766    shape.push_back(2);    shape.push_back(2);
767    shape.push_back(3);    shape.push_back(3);
768    
769    // allocate the data for the DataArrayView    // allocate the data for the DataArrayView
770    DataArrayView::ValueType data(DataArrayView::noValues(shape),0);    DataTypes::ValueType data(DataTypes::noValues(shape),0);
771    
772    // construct DataArrayView    // construct DataArrayView
773    DataArrayView dataView(data,shape);  //   DataArrayView dataView(data,shape);
774    
775    // assign values to the data    // assign values to the data
776    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
777      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
778        dataView(i,j)=dataView.index(i,j);        data[getRelIndex(shape,i,j)]=getRelIndex(shape,i,j);
779      }      }
780    }    }
781    
782    Data baseEx(dataView,FunctionSpace(),true);    Data baseEx(data,shape,FunctionSpace(),true);
783    Data baseCon(dataView,FunctionSpace(),false);    Data baseCon(data,shape,FunctionSpace(),false);
784    Data baseTag(dataView,FunctionSpace(),false);    Data baseTag(data,shape,FunctionSpace(),false);
785    baseTag.tag();    baseTag.tag();
786    
787    assert(baseEx.isExpanded());    assert(baseEx.isExpanded());
# Line 760  void DataTestCase::testOperations() { Line 802  void DataTestCase::testOperations() {
802    resultTag.copy(baseTag.powD(power));    resultTag.copy(baseTag.powD(power));
803    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
804      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
805        tmp=pow((double)dataView.index(i,j),(double)3.0);        tmp=pow((double)data[getRelIndex(shape,i,j)],(double)3.0);
806        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
807        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
808        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
809      }      }
810    }    }
811    
# Line 773  void DataTestCase::testOperations() { Line 815  void DataTestCase::testOperations() {
815    resultTag.copy(baseTag.sin());    resultTag.copy(baseTag.sin());
816    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
817      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
818        tmp=sin((double)dataView.index(i,j));        tmp=sin((double)data[getRelIndex(shape,i,j)]);
819        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
820        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
821        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
822      }      }
823    }    }
824    
# Line 786  void DataTestCase::testOperations() { Line 828  void DataTestCase::testOperations() {
828    resultTag.copy(baseTag.cos());    resultTag.copy(baseTag.cos());
829    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
830      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
831        tmp=cos((double)dataView.index(i,j));        tmp=cos((double)data[getRelIndex(shape,i,j)]);
832        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
833        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
834        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
835      }      }
836    }    }
837    
# Line 799  void DataTestCase::testOperations() { Line 841  void DataTestCase::testOperations() {
841    resultTag.copy(baseTag.tan());    resultTag.copy(baseTag.tan());
842    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
843      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
844        tmp=tan((double)dataView.index(i,j));        tmp=tan((double)data[getRelIndex(shape,i,j)]);
845        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
846        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
847        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
848      }      }
849    }    }
850    
# Line 824  void DataTestCase::testOperations() { Line 866  void DataTestCase::testOperations() {
866    resultTag.copy(baseTag.atan());    resultTag.copy(baseTag.atan());
867    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
868      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
869        tmp=atan((double)dataView.index(i,j));        tmp=atan((double)data[getRelIndex(shape,i,j)]);
870        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
871        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
872        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
873      }      }
874    }    }
875    
# Line 837  void DataTestCase::testOperations() { Line 879  void DataTestCase::testOperations() {
879    resultTag.copy(baseTag.sinh());    resultTag.copy(baseTag.sinh());
880    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
881      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
882        tmp=sinh((double)dataView.index(i,j));        tmp=sinh((double)data[getRelIndex(shape,i,j)]);
883        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
884        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
885        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
886      }      }
887    }    }
888    
# Line 850  void DataTestCase::testOperations() { Line 892  void DataTestCase::testOperations() {
892    resultTag.copy(baseTag.cosh());    resultTag.copy(baseTag.cosh());
893    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
894      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
895        tmp=cosh((double)dataView.index(i,j));        tmp=cosh((double)data[getRelIndex(shape,i,j)]);
896        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
897        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
898        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
899      }      }
900    }    }
901    
# Line 863  void DataTestCase::testOperations() { Line 905  void DataTestCase::testOperations() {
905    resultTag.copy(baseTag.tanh());    resultTag.copy(baseTag.tanh());
906    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
907      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
908        tmp=tanh((double)dataView.index(i,j));        tmp=tanh((double)data[getRelIndex(shape,i,j)]);
909        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
910        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
911        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
912      }      }
913    }    }
914    
# Line 900  void DataTestCase::testOperations() { Line 942  void DataTestCase::testOperations() {
942    resultTag.copy(baseTag.abs());    resultTag.copy(baseTag.abs());
943    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
944      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
945        tmp=abs((double)dataView.index(i,j));        tmp=abs((double)data[getRelIndex(shape,i,j)]);
946        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
947        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
948        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
949      }      }
950    }    }
951    
# Line 919  void DataTestCase::testOperations() { Line 961  void DataTestCase::testOperations() {
961    resultTag.copy(baseTag.exp());    resultTag.copy(baseTag.exp());
962    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
963      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
964        tmp=exp((double)dataView.index(i,j));        tmp=exp((double)data[getRelIndex(shape,i,j)]);
965        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
966        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
967        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
968      }      }
969    }    }
970    
# Line 932  void DataTestCase::testOperations() { Line 974  void DataTestCase::testOperations() {
974    resultTag.copy(baseTag.sqrt());    resultTag.copy(baseTag.sqrt());
975    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
976      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
977        tmp=sqrt((double)dataView.index(i,j));        tmp=sqrt((double)data[getRelIndex(shape,i,j)]);
978        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
979        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
980        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
981      }      }
982    }    }
983    
# Line 951  void DataTestCase::testOperations() { Line 993  void DataTestCase::testOperations() {
993    resultTag.copy(baseTag.pos());    resultTag.copy(baseTag.pos());
994    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
995      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
996        assert(std::abs(resultEx.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultEx,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
997        assert(std::abs(resultCon.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultCon,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
998        assert(std::abs(resultTag.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultTag,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
999      }      }
1000    }    }
1001    
# Line 980  void DataTestCase::testOperations() { Line 1022  void DataTestCase::testOperations() {
1022    resultEx.copy(baseEx.minval());    resultEx.copy(baseEx.minval());
1023    resultCon.copy(baseCon.minval());    resultCon.copy(baseCon.minval());
1024    resultTag.copy(baseTag.minval());    resultTag.copy(baseTag.minval());
1025    assert(std::abs(resultEx.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultEx.getPointDataView()() - 0) <= REL_TOL*0);
1026    assert(std::abs(resultCon.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultCon.getPointDataView()() - 0) <= REL_TOL*0);
1027    assert(std::abs(resultTag.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultTag.getPointDataView()() - 0) <= REL_TOL*0);
1028      assert(std::abs(resultEx.getDataAtOffset(0) - 0) <= REL_TOL*0);
1029      assert(std::abs(resultCon.getDataAtOffset(0) - 0) <= REL_TOL*0);
1030      assert(std::abs(resultTag.getDataAtOffset(0) - 0) <= REL_TOL*0);
1031    
1032    cout << "\tTest Data::maxval." << endl;    cout << "\tTest Data::maxval." << endl;
1033    resultEx.copy(baseEx.maxval());    resultEx.copy(baseEx.maxval());
1034    resultCon.copy(baseCon.maxval());    resultCon.copy(baseCon.maxval());
1035    resultTag.copy(baseTag.maxval());    resultTag.copy(baseTag.maxval());
1036    assert(std::abs(resultEx.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultEx.getDataAtOffset(0) - 5) <= REL_TOL*5);
1037    assert(std::abs(resultCon.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultCon.getDataAtOffset(0) - 5) <= REL_TOL*5);
1038    assert(std::abs(resultTag.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultTag.getDataAtOffset(0) - 5) <= REL_TOL*5);
1039    
1040  }  }
1041    
# Line 1004  void DataTestCase::testMemAlloc() { Line 1049  void DataTestCase::testMemAlloc() {
1049    
1050    Data *testData;    Data *testData;
1051    for (int i=0; i<1000; i++) {    for (int i=0; i<1000; i++) {
1052      testData = new Data(0.0, DataArrayView::ShapeType(), FunctionSpace(), true);      testData = new Data(0.0, DataTypes::ShapeType(), FunctionSpace(), true);
1053      delete testData;      delete testData;
1054    }    }
1055    
1056    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
1057    viewShape.push_back(10);    viewShape.push_back(10);
1058    viewShape.push_back(10);    viewShape.push_back(10);
1059    viewShape.push_back(10);    viewShape.push_back(10);

Legend:
Removed from v.1795  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26