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

Contents of /trunk/escript/test/DataTaggedTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 548 - (show annotations)
Tue Feb 21 23:52:41 2006 UTC (13 years, 9 months ago) by jgs
Original Path: trunk/escript/test/DataTagged/DataTaggedTestCase.cpp
File size: 156375 byte(s)
modify tests for binary operations and setSlice to ensure situations where two DataTaggeds with mismatched tag sets are tested correctly
1 // $Id$
2
3 /*
4 *****************************************************************************
5 * *
6 * COPYRIGHT ACcESS - All Rights Reserved *
7 * *
8 * This software is the property of ACcESS. No part of this code *
9 * may be copied in any form or by any means without the expressed written *
10 * consent of ACcESS. Copying, use or modification of this software *
11 * by any unauthorised person is illegal unless that person has a software *
12 * license agreement with ACcESS. *
13 * *
14 *****************************************************************************
15 */
16
17 #include "EsysException.h"
18
19 #include "DataTagged.h"
20 #include "DataConstant.h"
21
22 #include "DataTaggedTestCase.h"
23
24 #include "BinaryOp.h"
25 #include "UnaryOp.h"
26 #include "FunctionSpaceFactory.h"
27 #include "DataFactory.h"
28
29 #include <iostream>
30 #include <functional>
31 #include <algorithm>
32
33 using namespace CppUnitTest;
34 using namespace escript;
35 using namespace esysUtils;
36 using namespace std;
37
38 void DataTaggedTestCase::setUp() {
39 //
40 // This is called before each test is run
41
42 }
43
44 void DataTaggedTestCase::tearDown() {
45 //
46 // This is called after each test has been run
47
48 }
49
50 void DataTaggedTestCase::testReshape() {
51
52 cout << endl;
53
54 {
55
56 cout << "\tTest rank 1 reshape of default DataTagged." << endl;
57
58 DataTagged myData;
59 myData.getPointDataView()()=1.0;
60
61 DataArrayView::ShapeType shape;
62 shape.push_back(2);
63
64 myData.reshapeDataPoint(shape);
65
66 for (int i=0;i<shape[0];i++) {
67 assert(myData.getDefaultValue()(i)==1);
68 }
69
70 //cout << myData.toString() << endl;
71
72 assert(myData.getNumSamples()==1);
73 assert(myData.getNumDPPSample()==1);
74
75 assert(myData.validSamplePointNo(0));
76 assert(myData.validSampleNo(0));
77 assert(!myData.validSamplePointNo(1));
78 assert(!myData.validSampleNo(1));
79
80 // data-point 0 has tag number 1 by default
81 assert(myData.getTagNumber(0)==1);
82
83 assert(!myData.isCurrentTag(1));
84
85 assert(myData.getTagLookup().size()==0);
86
87 assert(myData.getLength()==2);
88
89 assert(myData.getPointOffset(0,0)==0);
90
91 DataArrayView myDataView = myData.getDataPoint(0,0);
92 assert(!myDataView.isEmpty());
93 assert(myDataView.getOffset()==0);
94 assert(myDataView.getRank()==1);
95 assert(myDataView.noValues()==2);
96 assert(myDataView.getShape().size()==1);
97 assert(myDataView(0)==1.0);
98 assert(myDataView(1)==1.0);
99
100 // Test non-existent tag returns the default value.
101 myDataView = myData.getDataPointByTag(1);
102 assert(!myDataView.isEmpty());
103 assert(myDataView.getOffset()==0);
104 assert(myDataView.getRank()==1);
105 assert(myDataView.noValues()==2);
106 assert(myDataView.getShape().size()==1);
107 assert(myDataView(0)==1.0);
108 assert(myDataView(1)==1.0);
109
110 myDataView = myData.getDefaultValue();
111 assert(!myDataView.isEmpty());
112 assert(myDataView.getOffset()==0);
113 assert(myDataView.getRank()==1);
114 assert(myDataView.noValues()==2);
115 assert(myDataView.getShape().size()==1);
116 assert(myDataView(0)==1.0);
117 assert(myDataView(1)==1.0);
118
119 // use a non-existent tag so we get a pointer to
120 // the first element of the data array
121 double* sampleData=myData.getSampleDataByTag(9);
122 for (int i=0; i<myData.getLength(); i++) {
123 assert(sampleData[i]==1.0);
124 }
125
126 }
127
128 {
129
130 cout << "\tTest rank 2 reshape of DataTagged with one tag." << endl;
131
132 DataTagged::TagListType keys;
133 keys.push_back(1);
134
135 DataTagged::ValueListType values;
136
137 DataArrayView::ShapeType viewShape;
138
139 // default value
140 DataArrayView::ValueType viewData(1);
141 viewData[0]=1.0;
142 DataArrayView myView(viewData,viewShape);
143
144 // value for tag "1"
145 DataArray eOne(myView);
146 eOne.getView()()=2.0;
147 values.push_back(eOne.getView());
148
149 DataTagged myData(keys,values,myView,FunctionSpace());
150
151 DataArrayView::ShapeType shape;
152 shape.push_back(2);
153 shape.push_back(5);
154
155 myData.reshapeDataPoint(shape);
156
157 //cout << myData.toString() << endl;
158
159 assert(myData.getNumSamples()==1);
160 assert(myData.getNumDPPSample()==1);
161
162 assert(myData.validSamplePointNo(0));
163 assert(myData.validSampleNo(0));
164 assert(!myData.validSamplePointNo(1));
165 assert(!myData.validSampleNo(1));
166
167 // data-point 0 has tag number 1 by default
168 assert(myData.getTagNumber(0)==1);
169
170 assert(myData.isCurrentTag(1));
171
172 assert(myData.getTagLookup().size()==1);
173
174 assert(myData.getLength()==20);
175
176 assert(myData.getPointOffset(0,0)==10);
177
178 DataArrayView myDataView = myData.getDataPoint(0,0);
179 assert(!myDataView.isEmpty());
180 assert(myDataView.getOffset()==10);
181 assert(myDataView.getRank()==2);
182 assert(myDataView.noValues()==10);
183 assert(myDataView.getShape().size()==2);
184 for (int j=0;j<shape[1];j++) {
185 for (int i=0;i<shape[0];i++) {
186 assert(myDataView(i,j)==2.0);
187 }
188 }
189
190 myDataView = myData.getDataPointByTag(1);
191 assert(!myDataView.isEmpty());
192 assert(myDataView.getOffset()==10);
193 assert(myDataView.getRank()==2);
194 assert(myDataView.noValues()==10);
195 assert(myDataView.getShape().size()==2);
196 for (int j=0;j<shape[1];j++) {
197 for (int i=0;i<shape[0];i++) {
198 assert(myDataView(i,j)==2.0);
199 }
200 }
201
202 myDataView = myData.getDefaultValue();
203 assert(!myDataView.isEmpty());
204 assert(myDataView.getOffset()==0);
205 assert(myDataView.getRank()==2);
206 assert(myDataView.noValues()==10);
207 assert(myDataView.getShape().size()==2);
208 for (int j=0;j<shape[1];j++) {
209 for (int i=0;i<shape[0];i++) {
210 assert(myDataView(i,j)==1.0);
211 }
212 }
213
214 // use a non-existent tag so we get a pointer to
215 // the first element of the data array
216 double* sampleData=myData.getSampleDataByTag(9);
217 for (int i=0; i<myData.getLength(); i++) {
218 if (i<10) {
219 assert(sampleData[i]==1.0);
220 } else {
221 assert(sampleData[i]==2.0);
222 }
223 }
224
225 }
226
227 {
228
229 cout << "\tTest rank 3 reshape of DataTagged with three tags." << endl;
230
231 DataTagged::TagListType keys;
232 keys.push_back(1);
233 keys.push_back(2);
234 keys.push_back(3);
235
236 DataTagged::ValueListType values;
237
238 DataArrayView::ShapeType viewShape;
239
240 // default value
241 DataArrayView::ValueType viewData(1);
242 viewData[0]=0.0;
243 DataArrayView myView(viewData,viewShape);
244
245 // value for tag "1"
246 DataArray eOne(myView);
247 eOne.getView()()=1.0;
248 values.push_back(eOne.getView());
249
250 // value for tag "2"
251 DataArray eTwo(myView);
252 eTwo.getView()()=2.0;
253 values.push_back(eTwo.getView());
254
255 // value for tag "3"
256 DataArray eThree(myView);
257 eThree.getView()()=3.0;
258 values.push_back(eThree.getView());
259
260 DataTagged myData(keys,values,myView,FunctionSpace());
261
262 DataArrayView::ShapeType shape;
263 shape.push_back(2);
264 shape.push_back(2);
265 shape.push_back(2);
266
267 myData.reshapeDataPoint(shape);
268
269 //cout << myData.toString() << endl;
270
271 assert(myData.getNumSamples()==1);
272 assert(myData.getNumDPPSample()==1);
273
274 assert(myData.validSamplePointNo(0));
275 assert(myData.validSampleNo(0));
276 assert(!myData.validSamplePointNo(1));
277 assert(!myData.validSampleNo(1));
278
279 // data-point 0 has tag number 1 by default
280 assert(myData.getTagNumber(0)==1);
281
282 assert(myData.isCurrentTag(1));
283 assert(myData.isCurrentTag(2));
284 assert(myData.isCurrentTag(3));
285
286 assert(myData.getTagLookup().size()==3);
287
288 assert(myData.getLength()==32);
289
290 assert(myData.getPointOffset(0,0)==8);
291
292 DataArrayView myDataView = myData.getDataPoint(0,0);
293 assert(!myDataView.isEmpty());
294 assert(myDataView.getOffset()==8);
295 assert(myDataView.getRank()==3);
296 assert(myDataView.noValues()==8);
297 assert(myDataView.getShape().size()==3);
298 for (int k=0;k<shape[2];k++) {
299 for (int j=0;j<shape[1];j++) {
300 for (int i=0;i<shape[0];i++) {
301 assert(myDataView(i,j,k)==1.0);
302 }
303 }
304 }
305
306 myDataView = myData.getDataPointByTag(1);
307 assert(!myDataView.isEmpty());
308 assert(myDataView.getOffset()==8);
309 assert(myDataView.getRank()==3);
310 assert(myDataView.noValues()==8);
311 assert(myDataView.getShape().size()==3);
312 for (int k=0;k<shape[2];k++) {
313 for (int j=0;j<shape[1];j++) {
314 for (int i=0;i<shape[0];i++) {
315 assert(myDataView(i,j,k)==1.0);
316 }
317 }
318 }
319
320 myDataView = myData.getDataPointByTag(2);
321 assert(!myDataView.isEmpty());
322 assert(myDataView.getOffset()==16);
323 assert(myDataView.getRank()==3);
324 assert(myDataView.noValues()==8);
325 assert(myDataView.getShape().size()==3);
326 for (int k=0;k<shape[2];k++) {
327 for (int j=0;j<shape[1];j++) {
328 for (int i=0;i<shape[0];i++) {
329 assert(myDataView(i,j,k)==2.0);
330 }
331 }
332 }
333
334 myDataView = myData.getDataPointByTag(3);
335 assert(!myDataView.isEmpty());
336 assert(myDataView.getOffset()==24);
337 assert(myDataView.getRank()==3);
338 assert(myDataView.noValues()==8);
339 assert(myDataView.getShape().size()==3);
340 for (int k=0;k<shape[2];k++) {
341 for (int j=0;j<shape[1];j++) {
342 for (int i=0;i<shape[0];i++) {
343 assert(myDataView(i,j,k)==3.0);
344 }
345 }
346 }
347
348 myDataView = myData.getDefaultValue();
349 assert(!myDataView.isEmpty());
350 assert(myDataView.getOffset()==0);
351 assert(myDataView.getRank()==3);
352 assert(myDataView.noValues()==8);
353 assert(myDataView.getShape().size()==3);
354 for (int k=0;k<shape[2];k++) {
355 for (int j=0;j<shape[1];j++) {
356 for (int i=0;i<shape[0];i++) {
357 assert(myDataView(i,j,k)==0.0);
358 }
359 }
360 }
361
362 // use a non-existent tag so we get a pointer to
363 // the first element of the data array
364 double* sampleData=myData.getSampleDataByTag(9);
365 for (int i=0; i<myData.getLength(); i++) {
366 if (i<8) {
367 assert(sampleData[i]==0.0);
368 } else if ((i>=8) && (i<16)) {
369 assert(sampleData[i]==1.0);
370 } else if ((i>=16) && (i<24)) {
371 assert(sampleData[i]==2.0);
372 } else {
373 assert(sampleData[i]==3.0);
374 }
375 }
376
377 }
378
379 }
380
381 void DataTaggedTestCase::testOperations() {
382
383 cout << endl;
384
385 {
386 cout << "\tTest binaryOp addition of two default DataTagged objects." << endl;
387
388 DataTagged myData;
389 DataTagged right;
390
391 binaryOp(myData,right,plus<double>());
392
393 //cout << myData.toString() << endl;
394
395 assert(myData.getNumSamples()==1);
396 assert(myData.getNumDPPSample()==1);
397
398 assert(myData.validSamplePointNo(0));
399 assert(myData.validSampleNo(0));
400 assert(!myData.validSamplePointNo(1));
401 assert(!myData.validSampleNo(1));
402
403 // data-point 0 has tag number 1 by default
404 assert(myData.getTagNumber(0)==1);
405
406 assert(!myData.isCurrentTag(1));
407
408 assert(myData.getTagLookup().size()==0);
409
410 assert(myData.getLength()==1);
411
412 assert(myData.getPointOffset(0,0)==0);
413
414 DataArrayView myDataView = myData.getDataPoint(0,0);
415 assert(!myDataView.isEmpty());
416 assert(myDataView.getOffset()==0);
417 assert(myDataView.getRank()==0);
418 assert(myDataView.noValues()==1);
419 assert(myDataView.getShape().size()==0);
420 assert(myDataView()==0.0);
421
422 // Test non-existent tag returns the default value.
423 myDataView = myData.getDataPointByTag(1);
424 assert(!myDataView.isEmpty());
425 assert(myDataView.getOffset()==0);
426 assert(myDataView.getRank()==0);
427 assert(myDataView.noValues()==1);
428 assert(myDataView.getShape().size()==0);
429 assert(myDataView()==0.0);
430
431 myDataView = myData.getDefaultValue();
432 assert(!myDataView.isEmpty());
433 assert(myDataView.getOffset()==0);
434 assert(myDataView.getRank()==0);
435 assert(myDataView.noValues()==1);
436 assert(myDataView.getShape().size()==0);
437 assert(myDataView()==0.0);
438
439 // use a non-existent tag so we get a pointer to
440 // the first element of the data array
441 double* sampleData=myData.getSampleDataByTag(9);
442 for (int i=0; i<myData.getLength(); i++) {
443 assert(sampleData[i]==i);
444 }
445
446 }
447
448 {
449 cout << "\tTest binaryOp addition of two DataTagged objects with default values only." << endl;
450
451 DataArrayView::ShapeType viewShape;
452 viewShape.push_back(3);
453
454 DataTagged::TagListType keys;
455
456 DataTagged::ValueListType values;
457
458 DataArrayView::ValueType viewData(3);
459 for (int i=0;i<viewShape[0];i++) {
460 viewData[i]=i;
461 }
462 DataArrayView myView(viewData,viewShape);
463
464 DataTagged myData(keys,values,myView,FunctionSpace());
465 DataTagged right(keys,values,myView,FunctionSpace());
466
467 binaryOp(myData,right,plus<double>());
468
469 //cout << myData.toString() << endl;
470
471 assert(myData.getNumSamples()==1);
472 assert(myData.getNumDPPSample()==1);
473
474 assert(myData.validSamplePointNo(0));
475 assert(myData.validSampleNo(0));
476 assert(!myData.validSamplePointNo(1));
477 assert(!myData.validSampleNo(1));
478
479 // data-point 0 has tag number 1 by default
480 assert(myData.getTagNumber(0)==1);
481
482 assert(!myData.isCurrentTag(1));
483
484 assert(myData.getTagLookup().size()==0);
485
486 assert(myData.getLength()==3);
487
488 assert(myData.getPointOffset(0,0)==0);
489
490 DataArrayView myDataView = myData.getDefaultValue();
491 assert(!myDataView.isEmpty());
492 assert(myDataView.getOffset()==0);
493 assert(myDataView.getRank()==1);
494 assert(myDataView.noValues()==3);
495 assert(myDataView.getShape().size()==1);
496 assert(myDataView(0)==0);
497 assert(myDataView(1)==2);
498 assert(myDataView(2)==4);
499
500 // use a non-existent tag so we get a pointer to
501 // the first element of the data array
502 double* sampleData=myData.getSampleDataByTag(9);
503 for (int i=0; i<myData.getLength(); i++) {
504 assert(sampleData[i]==i*2);
505 }
506
507 }
508
509 {
510 cout << "\tTest binaryOp addition of two DataTagged objects with one identical tag each." << endl;
511
512 DataTagged myData;
513 DataTagged right;
514
515 DataArray vOne(1.0);
516 myData.addTaggedValue(1,vOne.getView());
517 right.addTaggedValue(1,vOne.getView());
518
519 binaryOp(myData,right,plus<double>());
520
521 assert(myData.getNumSamples()==1);
522 assert(myData.getNumDPPSample()==1);
523
524 assert(myData.validSamplePointNo(0));
525 assert(myData.validSampleNo(0));
526 assert(!myData.validSamplePointNo(1));
527 assert(!myData.validSampleNo(1));
528
529 // data-point 0 has tag number 1 by default
530 assert(myData.getTagNumber(0)==1);
531
532 assert(myData.isCurrentTag(1));
533
534 assert(myData.getTagLookup().size()==1);
535
536 assert(myData.getLength()==2);
537
538 assert(myData.getPointOffset(0,0)==1);
539
540 // check result value for tag "1"
541 DataArrayView myDataView = myData.getDataPointByTag(1);
542 assert(!myDataView.isEmpty());
543 assert(myDataView.getOffset()==1);
544 assert(myDataView.getRank()==0);
545 assert(myDataView.noValues()==1);
546 assert(myDataView.getShape().size()==0);
547 assert(myDataView()==2.0);
548
549 // check result for default value
550 myDataView = myData.getDefaultValue();
551 assert(!myDataView.isEmpty());
552 assert(myDataView.getOffset()==0);
553 assert(myDataView.getRank()==0);
554 assert(myDataView.noValues()==1);
555 assert(myDataView.getShape().size()==0);
556 assert(myDataView()==0.0);
557
558 // use a non-existent tag so we get a pointer to
559 // the first element of the data array
560 double* sampleData=myData.getSampleDataByTag(9);
561 for (int i=0; i<myData.getLength(); i++) {
562 assert(sampleData[i]==i*2);
563 }
564
565 }
566
567 {
568 cout << "\tTest binaryOp addition of two DataTagged objects with one different tag each." << endl;
569
570 DataTagged myData;
571 DataTagged right;
572
573 // it's important that default values are different, as we need to be able to
574 // verify that the tag values in each object are being added to the correct
575 // default values - since the tag lists don't match, the default values will
576 // be used for missing tags in each object
577 myData.getDefaultValue()()=1.0;
578 right.getDefaultValue()()=2.0;
579
580 DataArray vOne(3.0);
581 DataArray vTwo(4.0);
582 myData.addTaggedValue(1,vOne.getView());
583 right.addTaggedValue(2,vTwo.getView());
584
585 //cout << myData.toString() << endl;
586 //cout << right.toString() << endl;
587
588 binaryOp(myData,right,plus<double>());
589
590 //cout << myData.toString() << endl;
591
592 assert(myData.getNumSamples()==1);
593 assert(myData.getNumDPPSample()==1);
594
595 assert(myData.validSamplePointNo(0));
596 assert(myData.validSampleNo(0));
597 assert(!myData.validSamplePointNo(1));
598 assert(!myData.validSampleNo(1));
599
600 // data-point 0 has tag number 1 by default
601 assert(myData.getTagNumber(0)==1);
602
603 assert(myData.isCurrentTag(1));
604 assert(myData.isCurrentTag(2));
605
606 assert(myData.getTagLookup().size()==2);
607
608 assert(myData.getLength()==3);
609
610 assert(myData.getPointOffset(0,0)==1);
611
612 // check result value for tag "1"
613 DataArrayView myDataView = myData.getDataPointByTag(1);
614 assert(!myDataView.isEmpty());
615 assert(myDataView.getOffset()==1);
616 assert(myDataView.getRank()==0);
617 assert(myDataView.noValues()==1);
618 assert(myDataView.getShape().size()==0);
619 assert(myDataView()==5.0);
620
621 // check result value for tag "2"
622 myDataView = myData.getDataPointByTag(2);
623 assert(!myDataView.isEmpty());
624 assert(myDataView.getOffset()==2);
625 assert(myDataView.getRank()==0);
626 assert(myDataView.noValues()==1);
627 assert(myDataView.getShape().size()==0);
628 assert(myDataView()==5.0);
629
630 // check result for default value
631 myDataView = myData.getDefaultValue();
632 assert(!myDataView.isEmpty());
633 assert(myDataView.getOffset()==0);
634 assert(myDataView.getRank()==0);
635 assert(myDataView.noValues()==1);
636 assert(myDataView.getShape().size()==0);
637 assert(myDataView()==3.0);
638
639 // use a non-existent tag so we get a pointer to
640 // the first element of the data array
641 double* sampleData=myData.getSampleDataByTag(9);
642 assert(sampleData[0]==3);
643 assert(sampleData[1]==5);
644 assert(sampleData[2]==5);
645
646 }
647
648 {
649 cout << "\tTest binaryOp addition of two DataTagged objects with overlapping tag sets." << endl;
650
651 DataTagged myData;
652 DataTagged right;
653
654 // it's important that default values are different, as we need to be able to
655 // verify that the tag values in each object are being added to the correct
656 // default values - since the tag lists don't match, the default values will
657 // be used for missing tags in each object
658 myData.getDefaultValue()()=2.0;
659 right.getDefaultValue()()=3.0;
660
661 DataArray vOne(1.0);
662 myData.addTaggedValue(1,vOne.getView());
663 myData.addTaggedValue(2,vOne.getView());
664 right.addTaggedValue(2,vOne.getView());
665 right.addTaggedValue(3,vOne.getView());
666
667 //cout << myData.toString() << endl;
668 //cout << right.toString() << endl;
669
670 binaryOp(myData,right,plus<double>());
671
672 //cout << myData.toString() << endl;
673
674 assert(myData.getNumSamples()==1);
675 assert(myData.getNumDPPSample()==1);
676
677 assert(myData.validSamplePointNo(0));
678 assert(myData.validSampleNo(0));
679 assert(!myData.validSamplePointNo(1));
680 assert(!myData.validSampleNo(1));
681
682 // data-point 0 has tag number 1 by default
683 assert(myData.getTagNumber(0)==1);
684
685 assert(myData.isCurrentTag(1));
686 assert(myData.isCurrentTag(2));
687 assert(myData.isCurrentTag(3));
688
689 assert(myData.getTagLookup().size()==3);
690
691 assert(myData.getLength()==4);
692
693 assert(myData.getPointOffset(0,0)==1);
694
695 // check result value for tag "1"
696 DataArrayView myDataView = myData.getDataPointByTag(1);
697 assert(!myDataView.isEmpty());
698 assert(myDataView.getOffset()==1);
699 assert(myDataView.getRank()==0);
700 assert(myDataView.noValues()==1);
701 assert(myDataView.getShape().size()==0);
702 assert(myDataView()==4.0);
703
704 // check result value for tag "2"
705 myDataView = myData.getDataPointByTag(2);
706 assert(!myDataView.isEmpty());
707 assert(myDataView.getOffset()==2);
708 assert(myDataView.getRank()==0);
709 assert(myDataView.noValues()==1);
710 assert(myDataView.getShape().size()==0);
711 assert(myDataView()==2.0);
712
713 // check result value for tag "3"
714 myDataView = myData.getDataPointByTag(3);
715 assert(!myDataView.isEmpty());
716 assert(myDataView.getOffset()==3);
717 assert(myDataView.getRank()==0);
718 assert(myDataView.noValues()==1);
719 assert(myDataView.getShape().size()==0);
720 assert(myDataView()==3.0);
721
722 // check result for default value
723 myDataView = myData.getDefaultValue();
724 assert(!myDataView.isEmpty());
725 assert(myDataView.getOffset()==0);
726 assert(myDataView.getRank()==0);
727 assert(myDataView.noValues()==1);
728 assert(myDataView.getShape().size()==0);
729 assert(myDataView()==5.0);
730
731 // use a non-existent tag so we get a pointer to
732 // the first element of the data array
733 double* sampleData=myData.getSampleDataByTag(9);
734 assert(sampleData[0]==5);
735 assert(sampleData[1]==4);
736 assert(sampleData[2]==2);
737 assert(sampleData[3]==3);
738
739 }
740
741 {
742 cout << "\tTest binaryOp multiplication of two DataTagged objects with default values only." << endl;
743
744 DataArrayView::ShapeType viewShape;
745 viewShape.push_back(3);
746
747 DataTagged::TagListType keys;
748
749 DataTagged::ValueListType values;
750
751 DataArrayView::ValueType viewData(3);
752 for (int i=0;i<viewShape[0];i++) {
753 viewData[i]=i;
754 }
755 DataArrayView myView(viewData,viewShape);
756
757 DataTagged myData(keys,values,myView,FunctionSpace());
758 DataTagged right(keys,values,myView,FunctionSpace());
759
760 binaryOp(myData,right,multiplies<double>());
761
762 //cout << myData.toString() << endl;
763
764 assert(myData.getNumSamples()==1);
765 assert(myData.getNumDPPSample()==1);
766
767 assert(myData.validSamplePointNo(0));
768 assert(myData.validSampleNo(0));
769 assert(!myData.validSamplePointNo(1));
770 assert(!myData.validSampleNo(1));
771
772 // data-point 0 has tag number 1 by default
773 assert(myData.getTagNumber(0)==1);
774
775 assert(!myData.isCurrentTag(1));
776
777 assert(myData.getTagLookup().size()==0);
778
779 assert(myData.getLength()==3);
780
781 assert(myData.getPointOffset(0,0)==0);
782
783 DataArrayView myDataView = myData.getDefaultValue();
784 assert(!myDataView.isEmpty());
785 assert(myDataView.getOffset()==0);
786 assert(myDataView.getRank()==1);
787 assert(myDataView.noValues()==3);
788 assert(myDataView.getShape().size()==1);
789 assert(myDataView(0)==0);
790 assert(myDataView(1)==1);
791 assert(myDataView(2)==4);
792
793 // use a non-existent tag so we get a pointer to
794 // the first element of the data array
795 double* sampleData=myData.getSampleDataByTag(9);
796 for (int i=0; i<myData.getLength(); i++) {
797 assert(sampleData[i]==i*i);
798 }
799
800 }
801
802 {
803 cout << "\tTest binaryOp multiplication of two DataTagged objects with overlapping tag sets." << endl;
804
805 DataTagged myData;
806 DataTagged right;
807
808 // it's important that default values are different, as we need to be able to
809 // verify that the tag values in each object are being added to the correct
810 // default values - since the tag lists don't match, the default values will
811 // be used for missing tags in each object
812 myData.getDefaultValue()()=2.0;
813 right.getDefaultValue()()=3.0;
814
815 DataArray vOne(1.0);
816 DataArray vTwo(2.0);
817 myData.addTaggedValue(1,vOne.getView());
818 myData.addTaggedValue(2,vOne.getView());
819 right.addTaggedValue(2,vTwo.getView());
820 right.addTaggedValue(3,vTwo.getView());
821
822 //cout << myData.toString() << endl;
823 //cout << right.toString() << endl;
824
825 binaryOp(myData,right,multiplies<double>());
826
827 //cout << myData.toString() << endl;
828
829 assert(myData.getNumSamples()==1);
830 assert(myData.getNumDPPSample()==1);
831
832 assert(myData.validSamplePointNo(0));
833 assert(myData.validSampleNo(0));
834 assert(!myData.validSamplePointNo(1));
835 assert(!myData.validSampleNo(1));
836
837 // data-point 0 has tag number 1 by default
838 assert(myData.getTagNumber(0)==1);
839
840 assert(myData.isCurrentTag(1));
841 assert(myData.isCurrentTag(2));
842 assert(myData.isCurrentTag(3));
843
844 assert(myData.getTagLookup().size()==3);
845
846 assert(myData.getLength()==4);
847
848 assert(myData.getPointOffset(0,0)==1);
849
850 // check result value for tag "1"
851 DataArrayView myDataView = myData.getDataPointByTag(1);
852 assert(!myDataView.isEmpty());
853 assert(myDataView.getOffset()==1);
854 assert(myDataView.getRank()==0);
855 assert(myDataView.noValues()==1);
856 assert(myDataView.getShape().size()==0);
857 assert(myDataView()==3.0);
858
859 // check result value for tag "2"
860 myDataView = myData.getDataPointByTag(2);
861 assert(!myDataView.isEmpty());
862 assert(myDataView.getOffset()==2);
863 assert(myDataView.getRank()==0);
864 assert(myDataView.noValues()==1);
865 assert(myDataView.getShape().size()==0);
866 assert(myDataView()==2.0);
867
868 // check result value for tag "3"
869 myDataView = myData.getDataPointByTag(3);
870 assert(!myDataView.isEmpty());
871 assert(myDataView.getOffset()==3);
872 assert(myDataView.getRank()==0);
873 assert(myDataView.noValues()==1);
874 assert(myDataView.getShape().size()==0);
875 assert(myDataView()==4.0);
876
877 // check result for default value
878 myDataView = myData.getDefaultValue();
879 assert(!myDataView.isEmpty());
880 assert(myDataView.getOffset()==0);
881 assert(myDataView.getRank()==0);
882 assert(myDataView.noValues()==1);
883 assert(myDataView.getShape().size()==0);
884 assert(myDataView()==6.0);
885
886 // use a non-existent tag so we get a pointer to
887 // the first element of the data array
888 double* sampleData=myData.getSampleDataByTag(9);
889 assert(sampleData[0]==6);
890 assert(sampleData[1]==3);
891 assert(sampleData[2]==2);
892 assert(sampleData[3]==4);
893
894 }
895
896 {
897 cout << "\tTest unaryOp negate on default DataTagged object." << endl;
898
899 DataTagged myData;
900
901 unaryOp(myData,negate<double>());
902
903 //cout << myData.toString() << endl;
904
905 assert(myData.getNumSamples()==1);
906 assert(myData.getNumDPPSample()==1);
907
908 assert(myData.validSamplePointNo(0));
909 assert(myData.validSampleNo(0));
910 assert(!myData.validSamplePointNo(1));
911 assert(!myData.validSampleNo(1));
912
913 // data-point 0 has tag number 1 by default
914 assert(myData.getTagNumber(0)==1);
915
916 assert(!myData.isCurrentTag(1));
917
918 assert(myData.getTagLookup().size()==0);
919
920 assert(myData.getLength()==1);
921
922 assert(myData.getPointOffset(0,0)==0);
923
924 DataArrayView myDataView = myData.getDataPoint(0,0);
925 assert(!myDataView.isEmpty());
926 assert(myDataView.getOffset()==0);
927 assert(myDataView.getRank()==0);
928 assert(myDataView.noValues()==1);
929 assert(myDataView.getShape().size()==0);
930 assert(myDataView()==0.0);
931
932 // Test non-existent tag returns the default value.
933 myDataView = myData.getDataPointByTag(1);
934 assert(!myDataView.isEmpty());
935 assert(myDataView.getOffset()==0);
936 assert(myDataView.getRank()==0);
937 assert(myDataView.noValues()==1);
938 assert(myDataView.getShape().size()==0);
939 assert(myDataView()==0.0);
940
941 myDataView = myData.getDefaultValue();
942 assert(!myDataView.isEmpty());
943 assert(myDataView.getOffset()==0);
944 assert(myDataView.getRank()==0);
945 assert(myDataView.noValues()==1);
946 assert(myDataView.getShape().size()==0);
947 assert(myDataView()==0.0);
948
949 // use a non-existent tag so we get a pointer to
950 // the first element of the data array
951 double* sampleData=myData.getSampleDataByTag(9);
952 for (int i=0; i<myData.getLength(); i++) {
953 assert(sampleData[i]==i);
954 }
955
956 }
957
958 {
959 cout << "\tTest unaryOp negate on DataTagged object with default value only." << endl;
960
961 DataArrayView::ShapeType viewShape;
962 viewShape.push_back(3);
963
964 DataTagged::TagListType keys;
965
966 DataTagged::ValueListType values;
967
968 DataArrayView::ValueType viewData(3);
969 for (int i=0;i<viewShape[0];i++) {
970 viewData[i]=i;
971 }
972 DataArrayView myView(viewData,viewShape);
973
974 DataTagged myData(keys,values,myView,FunctionSpace());
975
976 unaryOp(myData,negate<double>());
977
978 //cout << myData.toString() << endl;
979
980 assert(myData.getNumSamples()==1);
981 assert(myData.getNumDPPSample()==1);
982
983 assert(myData.validSamplePointNo(0));
984 assert(myData.validSampleNo(0));
985 assert(!myData.validSamplePointNo(1));
986 assert(!myData.validSampleNo(1));
987
988 // data-point 0 has tag number 1 by default
989 assert(myData.getTagNumber(0)==1);
990
991 assert(!myData.isCurrentTag(1));
992
993 assert(myData.getTagLookup().size()==0);
994
995 assert(myData.getLength()==3);
996
997 assert(myData.getPointOffset(0,0)==0);
998
999 DataArrayView myDataView = myData.getDefaultValue();
1000 assert(!myDataView.isEmpty());
1001 assert(myDataView.getOffset()==0);
1002 assert(myDataView.getRank()==1);
1003 assert(myDataView.noValues()==3);
1004 assert(myDataView.getShape().size()==1);
1005 assert(myDataView(0)==0);
1006 assert(myDataView(1)==-1);
1007 assert(myDataView(2)==-2);
1008
1009 // use a non-existent tag so we get a pointer to
1010 // the first element of the data array
1011 double* sampleData=myData.getSampleDataByTag(9);
1012 for (int i=0; i<myData.getLength(); i++) {
1013 assert(sampleData[i]==0-i);
1014 }
1015
1016 }
1017
1018 {
1019 cout << "\tTest unaryOp negate on DataTagged object with two tags." << endl;
1020
1021 DataTagged myData;
1022
1023 DataArray vOne(1.0);
1024 DataArray vTwo(2.0);
1025 myData.addTaggedValue(1,vOne.getView());
1026 myData.addTaggedValue(2,vTwo.getView());
1027
1028 unaryOp(myData,negate<double>());
1029
1030 assert(myData.getNumSamples()==1);
1031 assert(myData.getNumDPPSample()==1);
1032
1033 assert(myData.validSamplePointNo(0));
1034 assert(myData.validSampleNo(0));
1035 assert(!myData.validSamplePointNo(1));
1036 assert(!myData.validSampleNo(1));
1037
1038 // data-point 0 has tag number 1 by default
1039 assert(myData.getTagNumber(0)==1);
1040
1041 assert(myData.isCurrentTag(1));
1042 assert(myData.isCurrentTag(2));
1043
1044 assert(myData.getTagLookup().size()==2);
1045
1046 assert(myData.getLength()==3);
1047
1048 assert(myData.getPointOffset(0,0)==1);
1049
1050 // check result value for tag "1"
1051 DataArrayView myDataView = myData.getDataPointByTag(1);
1052 assert(!myDataView.isEmpty());
1053 assert(myDataView.getOffset()==1);
1054 assert(myDataView.getRank()==0);
1055 assert(myDataView.noValues()==1);
1056 assert(myDataView.getShape().size()==0);
1057 assert(myDataView()==-1.0);
1058
1059 // check result value for tag "2"
1060 myDataView = myData.getDataPointByTag(2);
1061 assert(!myDataView.isEmpty());
1062 assert(myDataView.getOffset()==2);
1063 assert(myDataView.getRank()==0);
1064 assert(myDataView.noValues()==1);
1065 assert(myDataView.getShape().size()==0);
1066 assert(myDataView()==-2.0);
1067
1068 // check result for default value
1069 myDataView = myData.getDefaultValue();
1070 assert(!myDataView.isEmpty());
1071 assert(myDataView.getOffset()==0);
1072 assert(myDataView.getRank()==0);
1073 assert(myDataView.noValues()==1);
1074 assert(myDataView.getShape().size()==0);
1075 assert(myDataView()==0.0);
1076
1077 // use a non-existent tag so we get a pointer to
1078 // the first element of the data array
1079 double* sampleData=myData.getSampleDataByTag(9);
1080 for (int i=0; i<myData.getLength(); i++) {
1081 assert(sampleData[i]==0-i);
1082 }
1083
1084 }
1085
1086 }
1087
1088 void DataTaggedTestCase::testAddTaggedValues() {
1089
1090 cout << endl;
1091
1092 {
1093
1094 cout << "\tTest adding one key with empty value list to default DataTagged." << endl;
1095 DataTagged myData;
1096
1097 DataTagged::TagListType keys;
1098 keys.push_back(1);
1099
1100 DataTagged::ValueListType values;
1101
1102 myData.addTaggedValues(keys,values);
1103
1104 assert(myData.isCurrentTag(1));
1105
1106 assert(myData.getTagLookup().size()==1);
1107
1108 assert(myData.getLength()==2);
1109
1110 // data-point 0 has tag number 1 by default
1111 assert(myData.getTagNumber(0)==1);
1112
1113 assert(myData.getPointOffset(0,0)==1);
1114
1115 DataArrayView myDataView = myData.getDataPoint(0,0);
1116 assert(!myDataView.isEmpty());
1117 assert(myDataView.getOffset()==1);
1118 assert(myDataView.getRank()==0);
1119 assert(myDataView.noValues()==1);
1120 assert(myDataView.getShape().size()==0);
1121 assert(myDataView()==0.0);
1122
1123 myDataView = myData.getDataPointByTag(1);
1124 assert(!myDataView.isEmpty());
1125 assert(myDataView.getOffset()==1);
1126 assert(myDataView.getRank()==0);
1127 assert(myDataView.noValues()==1);
1128 assert(myDataView.getShape().size()==0);
1129 assert(myDataView()==0.0);
1130
1131 myDataView = myData.getDefaultValue();
1132 assert(!myDataView.isEmpty());
1133 assert(myDataView.getOffset()==0);
1134 assert(myDataView.getRank()==0);
1135 assert(myDataView.noValues()==1);
1136 assert(myDataView.getShape().size()==0);
1137 assert(myDataView()==0.0);
1138
1139 // use a non-existent tag so we get a pointer to
1140 // the first element of the data array
1141 double* sampleData=myData.getSampleDataByTag(9);
1142 for (int i=0; i<myData.getLength(); i++) {
1143 assert(sampleData[i]==0);
1144 }
1145
1146 }
1147
1148 {
1149
1150 cout << "\tTest adding one key with one value to default DataTagged." << endl;
1151 DataTagged myData;
1152
1153 DataTagged::TagListType keys;
1154 keys.push_back(1);
1155
1156 DataTagged::ValueListType values;
1157
1158 DataArrayView::ShapeType viewShape;
1159 DataArrayView::ValueType viewData(1);
1160 viewData[0]=1.0;
1161 DataArrayView myView(viewData,viewShape);
1162 values.push_back(myView);
1163
1164 myData.addTaggedValues(keys,values);
1165
1166 assert(myData.isCurrentTag(1));
1167
1168 assert(myData.getTagLookup().size()==1);
1169
1170 assert(myData.getLength()==2);
1171
1172 // data-point 0 has tag number 1 by default
1173 assert(myData.getTagNumber(0)==1);
1174
1175 assert(myData.getPointOffset(0,0)==1);
1176
1177 DataArrayView myDataView = myData.getDataPoint(0,0);
1178 assert(!myDataView.isEmpty());
1179 assert(myDataView.getOffset()==1);
1180 assert(myDataView.getRank()==0);
1181 assert(myDataView.noValues()==1);
1182 assert(myDataView.getShape().size()==0);
1183 assert(myDataView()==1.0);
1184
1185 myDataView = myData.getDataPointByTag(1);
1186 assert(!myDataView.isEmpty());
1187 assert(myDataView.getOffset()==1);
1188 assert(myDataView.getRank()==0);
1189 assert(myDataView.noValues()==1);
1190 assert(myDataView.getShape().size()==0);
1191 assert(myDataView()==1.0);
1192
1193 myDataView = myData.getDefaultValue();
1194 assert(!myDataView.isEmpty());
1195 assert(myDataView.getOffset()==0);
1196 assert(myDataView.getRank()==0);
1197 assert(myDataView.noValues()==1);
1198 assert(myDataView.getShape().size()==0);
1199 assert(myDataView()==0.0);
1200
1201 // use a non-existent tag so we get a pointer to
1202 // the first element of the data array
1203 double* sampleData=myData.getSampleDataByTag(9);
1204 for (int i=0; i<myData.getLength(); i++) {
1205 assert(sampleData[i]==i);
1206 }
1207
1208 }
1209
1210 {
1211
1212 cout << "\tTest adding three keys with one value to default DataTagged." << endl;
1213 DataTagged myData;
1214
1215 DataTagged::TagListType keys;
1216 keys.push_back(1);
1217 keys.push_back(2);
1218 keys.push_back(3);
1219
1220 DataTagged::ValueListType values;
1221
1222 DataArrayView::ShapeType viewShape;
1223 DataArrayView::ValueType viewData(1);
1224 viewData[0]=1.0;
1225 DataArrayView myView(viewData,viewShape);
1226 values.push_back(myView);
1227
1228 myData.addTaggedValues(keys,values);
1229
1230 assert(myData.isCurrentTag(1));
1231 assert(myData.isCurrentTag(2));
1232 assert(myData.isCurrentTag(3));
1233
1234 assert(myData.getTagLookup().size()==3);
1235
1236 assert(myData.getLength()==4);
1237
1238 // data-point 0 has tag number 1 by default
1239 assert(myData.getTagNumber(0)==1);
1240
1241 assert(myData.getPointOffset(0,0)==1);
1242
1243 DataArrayView myDataView = myData.getDataPoint(0,0);
1244 assert(!myDataView.isEmpty());
1245 assert(myDataView.getOffset()==1);
1246 assert(myDataView.getRank()==0);
1247 assert(myDataView.noValues()==1);
1248 assert(myDataView.getShape().size()==0);
1249 assert(myDataView()==1.0);
1250
1251 myDataView = myData.getDataPointByTag(1);
1252 assert(!myDataView.isEmpty());
1253 assert(myDataView.getOffset()==1);
1254 assert(myDataView.getRank()==0);
1255 assert(myDataView.noValues()==1);
1256 assert(myDataView.getShape().size()==0);
1257 assert(myDataView()==1.0);
1258
1259 myDataView = myData.getDataPointByTag(2);
1260 assert(!myDataView.isEmpty());
1261 assert(myDataView.getOffset()==2);
1262 assert(myDataView.getRank()==0);
1263 assert(myDataView.noValues()==1);
1264 assert(myDataView.getShape().size()==0);
1265 assert(myDataView()==1.0);
1266
1267 myDataView = myData.getDataPointByTag(3);
1268 assert(!myDataView.isEmpty());
1269 assert(myDataView.getOffset()==3);
1270 assert(myDataView.getRank()==0);
1271 assert(myDataView.noValues()==1);
1272 assert(myDataView.getShape().size()==0);
1273 assert(myDataView()==1.0);
1274
1275 myDataView = myData.getDefaultValue();
1276 assert(!myDataView.isEmpty());
1277 assert(myDataView.getOffset()==0);
1278 assert(myDataView.getRank()==0);
1279 assert(myDataView.noValues()==1);
1280 assert(myDataView.getShape().size()==0);
1281 assert(myDataView()==0.0);
1282
1283 // use a non-existent tag so we get a pointer to
1284 // the first element of the data array
1285 double* sampleData=myData.getSampleDataByTag(9);
1286 for (int i=0; i<myData.getLength(); i++) {
1287 if (i==0) {
1288 assert(sampleData[i]==0);
1289 } else {
1290 assert(sampleData[i]==1);
1291 }
1292 }
1293
1294 }
1295
1296 {
1297
1298 cout << "\tTest adding three keys with three values to default DataTagged." << endl;
1299 DataTagged myData;
1300
1301 DataTagged::TagListType keys;
1302 keys.push_back(1);
1303 keys.push_back(2);
1304 keys.push_back(3);
1305
1306 DataTagged::ValueListType values;
1307
1308 DataArrayView::ShapeType viewShape;
1309 DataArrayView::ValueType viewData1(1);
1310 viewData1[0]=1.0;
1311 DataArrayView::ValueType viewData2(1);
1312 viewData2[0]=2.0;
1313 DataArrayView::ValueType viewData3(1);
1314 viewData3[0]=3.0;
1315 DataArrayView myView1(viewData1,viewShape);
1316 DataArrayView myView2(viewData2,viewShape);
1317 DataArrayView myView3(viewData3,viewShape);
1318 values.push_back(myView1);
1319 values.push_back(myView2);
1320 values.push_back(myView3);
1321
1322 myData.addTaggedValues(keys,values);
1323
1324 assert(myData.isCurrentTag(1));
1325 assert(myData.isCurrentTag(2));
1326 assert(myData.isCurrentTag(3));
1327
1328 assert(myData.getTagLookup().size()==3);
1329
1330 assert(myData.getLength()==4);
1331
1332 // data-point 0 has tag number 1 by default
1333 assert(myData.getTagNumber(0)==1);
1334
1335 assert(myData.getPointOffset(0,0)==1);
1336
1337 DataArrayView myDataView = myData.getDataPoint(0,0);
1338 assert(!myDataView.isEmpty());
1339 assert(myDataView.getOffset()==1);
1340 assert(myDataView.getRank()==0);
1341 assert(myDataView.noValues()==1);
1342 assert(myDataView.getShape().size()==0);
1343 assert(myDataView()==1.0);
1344
1345 myDataView = myData.getDataPointByTag(1);
1346 assert(!myDataView.isEmpty());
1347 assert(myDataView.getOffset()==1);
1348 assert(myDataView.getRank()==0);
1349 assert(myDataView.noValues()==1);
1350 assert(myDataView.getShape().size()==0);
1351 assert(myDataView()==1.0);
1352
1353 myDataView = myData.getDataPointByTag(2);
1354 assert(!myDataView.isEmpty());
1355 assert(myDataView.getOffset()==2);
1356 assert(myDataView.getRank()==0);
1357 assert(myDataView.noValues()==1);
1358 assert(myDataView.getShape().size()==0);
1359 assert(myDataView()==2.0);
1360
1361 myDataView = myData.getDataPointByTag(3);
1362 assert(!myDataView.isEmpty());
1363 assert(myDataView.getOffset()==3);
1364 assert(myDataView.getRank()==0);
1365 assert(myDataView.noValues()==1);
1366 assert(myDataView.getShape().size()==0);
1367 assert(myDataView()==3.0);
1368
1369 myDataView = myData.getDefaultValue();
1370 assert(!myDataView.isEmpty());
1371 assert(myDataView.getOffset()==0);
1372 assert(myDataView.getRank()==0);
1373 assert(myDataView.noValues()==1);
1374 assert(myDataView.getShape().size()==0);
1375 assert(myDataView()==0.0);
1376
1377 // use a non-existent tag so we get a pointer to
1378 // the first element of the data array
1379 double* sampleData=myData.getSampleDataByTag(9);
1380 for (int i=0; i<myData.getLength(); i++) {
1381 assert(sampleData[i]==i);
1382 }
1383
1384 }
1385
1386 {
1387
1388 cout << "\tTest adding one key with empty value list to DataTagged with default value only." << endl;
1389
1390 DataArrayView::ShapeType viewShape;
1391 viewShape.push_back(3);
1392
1393 DataTagged::TagListType keys;
1394
1395 DataTagged::ValueListType values;
1396
1397 DataArrayView::ValueType viewData(3);
1398 for (int i=0;i<viewShape[0];i++) {
1399 viewData[i]=i;
1400 }
1401 DataArrayView myView(viewData,viewShape);
1402
1403 DataTagged myData(keys,values,myView,FunctionSpace());
1404
1405 keys.push_back(1);
1406 values.clear();
1407
1408 myData.addTaggedValues(keys,values);
1409
1410 assert(myData.isCurrentTag(1));
1411
1412 assert(myData.getTagLookup().size()==1);
1413
1414 assert(myData.getLength()==6);
1415
1416 // data-point 0 has tag number 1 by default
1417 assert(myData.getTagNumber(0)==1);
1418
1419 assert(myData.getPointOffset(0,0)==3);
1420
1421 DataArrayView myDataView = myData.getDataPoint(0,0);
1422 assert(myDataView==myView);
1423 assert(!myDataView.isEmpty());
1424 assert(myDataView.getOffset()==3);
1425 assert(myDataView.getRank()==1);
1426 assert(myDataView.noValues()==3);
1427 assert(myDataView.getShape().size()==1);
1428 assert(myDataView(0)==0);
1429 assert(myDataView(1)==1);
1430 assert(myDataView(2)==2);
1431
1432 myDataView = myData.getDataPointByTag(1);
1433 assert(myDataView==myView);
1434 assert(!myDataView.isEmpty());
1435 assert(myDataView.getOffset()==3);
1436 assert(myDataView.getRank()==1);
1437 assert(myDataView.noValues()==3);
1438 assert(myDataView.getShape().size()==1);
1439 assert(myDataView(0)==0);
1440 assert(myDataView(1)==1);
1441 assert(myDataView(2)==2);
1442
1443 myDataView = myData.getDefaultValue();
1444 assert(myDataView==myView);
1445 assert(!myDataView.isEmpty());
1446 assert(myDataView.getOffset()==0);
1447 assert(myDataView.getRank()==1);
1448 assert(myDataView.noValues()==3);
1449 assert(myDataView.getShape().size()==1);
1450 assert(myDataView(0)==0);
1451 assert(myDataView(1)==1);
1452 assert(myDataView(2)==2);
1453
1454 // use a non-existent tag so we get a pointer to
1455 // the first element of the data array
1456 double* sampleData=myData.getSampleDataByTag(9);
1457 for (int i=0; i<myData.getLength(); i++) {
1458 assert(sampleData[i]==i%3);
1459 }
1460
1461 }
1462
1463 {
1464
1465 cout << "\tTest adding one key with one value to DataTagged with default value only." << endl;
1466
1467 DataArrayView::ShapeType viewShape;
1468 viewShape.push_back(3);
1469
1470 DataTagged::TagListType keys;
1471
1472 DataTagged::ValueListType values;
1473
1474 DataArrayView::ValueType viewData(3);
1475 for (int i=0;i<viewShape[0];i++) {
1476 viewData[i]=i;
1477 }
1478 DataArrayView myView(viewData,viewShape);
1479
1480 DataTagged myData(keys,values,myView,FunctionSpace());
1481
1482 keys.push_back(1);
1483
1484 DataArrayView::ValueType viewData1(3);
1485 for (int i=0;i<viewShape[0];i++) {
1486 viewData1[i]=i+3;
1487 }
1488 DataArrayView myView1(viewData1,viewShape);
1489 values.push_back(myView1);
1490
1491 myData.addTaggedValues(keys,values);
1492
1493 assert(myData.isCurrentTag(1));
1494
1495 assert(myData.getTagLookup().size()==1);
1496
1497 assert(myData.getLength()==6);
1498
1499 // data-point 0 has tag number 1 by default
1500 assert(myData.getTagNumber(0)==1);
1501
1502 assert(myData.getPointOffset(0,0)==3);
1503
1504 DataArrayView myDataView = myData.getDataPoint(0,0);
1505 assert(myDataView==myView1);
1506 assert(!myDataView.isEmpty());
1507 assert(myDataView.getOffset()==3);
1508 assert(myDataView.getRank()==1);
1509 assert(myDataView.noValues()==3);
1510 assert(myDataView.getShape().size()==1);
1511 assert(myDataView(0)==3);
1512 assert(myDataView(1)==4);
1513 assert(myDataView(2)==5);
1514
1515 myDataView = myData.getDataPointByTag(1);
1516 assert(myDataView==myView1);
1517 assert(!myDataView.isEmpty());
1518 assert(myDataView.getOffset()==3);
1519 assert(myDataView.getRank()==1);
1520 assert(myDataView.noValues()==3);
1521 assert(myDataView.getShape().size()==1);
1522 assert(myDataView(0)==3);
1523 assert(myDataView(1)==4);
1524 assert(myDataView(2)==5);
1525
1526 myDataView = myData.getDefaultValue();
1527 assert(myDataView==myView);
1528 assert(!myDataView.isEmpty());
1529 assert(myDataView.getOffset()==0);
1530 assert(myDataView.getRank()==1);
1531 assert(myDataView.noValues()==3);
1532 assert(myDataView.getShape().size()==1);
1533 assert(myDataView(0)==0);
1534 assert(myDataView(1)==1);
1535 assert(myDataView(2)==2);
1536
1537 // use a non-existent tag so we get a pointer to
1538 // the first element of the data array
1539 double* sampleData=myData.getSampleDataByTag(9);
1540 for (int i=0; i<myData.getLength(); i++) {
1541 assert(sampleData[i]==i);
1542 }
1543
1544 }
1545
1546 {
1547
1548 cout << "\tTest adding three keys with one value to DataTagged with default value only." << endl;
1549
1550 DataArrayView::ShapeType viewShape;
1551 viewShape.push_back(3);
1552
1553 DataTagged::TagListType keys;
1554
1555 DataTagged::ValueListType values;
1556
1557 DataArrayView::ValueType viewData(3);
1558 for (int i=0;i<viewShape[0];i++) {
1559 viewData[i]=i;
1560 }
1561 DataArrayView myView(viewData,viewShape);
1562
1563 DataTagged myData(keys,values,myView,FunctionSpace());
1564
1565 keys.push_back(1);
1566 keys.push_back(2);
1567 keys.push_back(3);
1568
1569 DataArrayView::ValueType viewData1(3);
1570 for (int i=0;i<viewShape[0];i++) {
1571 viewData1[i]=3;
1572 }
1573 DataArrayView myView1(viewData1,viewShape);
1574 values.push_back(myView1);
1575
1576 myData.addTaggedValues(keys,values);
1577
1578 assert(myData.isCurrentTag(1));
1579 assert(myData.isCurrentTag(2));
1580 assert(myData.isCurrentTag(3));
1581
1582 assert(myData.getTagLookup().size()==3);
1583
1584 assert(myData.getLength()==12);
1585
1586 // data-point 0 has tag number 1 by default
1587 assert(myData.getTagNumber(0)==1);
1588
1589 assert(myData.getPointOffset(0,0)==3);
1590
1591 DataArrayView myDataView = myData.getDataPoint(0,0);
1592 assert(myDataView==myView1);
1593 assert(!myDataView.isEmpty());
1594 assert(myDataView.getOffset()==3);
1595 assert(myDataView.getRank()==1);
1596 assert(myDataView.noValues()==3);
1597 assert(myDataView.getShape().size()==1);
1598 assert(myDataView(0)==3);
1599 assert(myDataView(1)==3);
1600 assert(myDataView(2)==3);
1601
1602 myDataView = myData.getDataPointByTag(1);
1603 assert(myDataView==myView1);
1604 assert(!myDataView.isEmpty());
1605 assert(myDataView.getOffset()==3);
1606 assert(myDataView.getRank()==1);
1607 assert(myDataView.noValues()==3);
1608 assert(myDataView.getShape().size()==1);
1609 assert(myDataView(0)==3);
1610 assert(myDataView(1)==3);
1611 assert(myDataView(2)==3);
1612
1613 myDataView = myData.getDataPointByTag(2);
1614 assert(myDataView==myView1);
1615 assert(!myDataView.isEmpty());
1616 assert(myDataView.getOffset()==6);
1617 assert(myDataView.getRank()==1);
1618 assert(myDataView.noValues()==3);
1619 assert(myDataView.getShape().size()==1);
1620 assert(myDataView(0)==3);
1621 assert(myDataView(1)==3);
1622 assert(myDataView(2)==3);
1623
1624 myDataView = myData.getDataPointByTag(3);
1625 assert(myDataView==myView1);
1626 assert(!myDataView.isEmpty());
1627 assert(myDataView.getOffset()==9);
1628 assert(myDataView.getRank()==1);
1629 assert(myDataView.noValues()==3);
1630 assert(myDataView.getShape().size()==1);
1631 assert(myDataView(0)==3);
1632 assert(myDataView(1)==3);
1633 assert(myDataView(2)==3);
1634
1635 myDataView = myData.getDefaultValue();
1636 assert(myDataView==myView);
1637 assert(!myDataView.isEmpty());
1638 assert(myDataView.getOffset()==0);
1639 assert(myDataView.getRank()==1);
1640 assert(myDataView.noValues()==3);
1641 assert(myDataView.getShape().size()==1);
1642 assert(myDataView(0)==0);
1643 assert(myDataView(1)==1);
1644 assert(myDataView(2)==2);
1645
1646 // use a non-existent tag so we get a pointer to
1647 // the first element of the data array
1648 double* sampleData=myData.getSampleDataByTag(9);
1649 for (int i=0; i<myData.getLength(); i++) {
1650 if (i<3) {
1651 assert(sampleData[i]==i);
1652 } else {
1653 assert(sampleData[i]==3);
1654 }
1655 }
1656
1657 }
1658
1659 {
1660
1661 cout << "\tTest adding three keys with three values to DataTagged with default value only." << endl;
1662
1663 DataArrayView::ShapeType viewShape;
1664 viewShape.push_back(3);
1665
1666 DataTagged::TagListType keys;
1667
1668 DataTagged::ValueListType values;
1669
1670 DataArrayView::ValueType viewData(3);
1671 for (int i=0;i<viewShape[0];i++) {
1672 viewData[i]=i;
1673 }
1674 DataArrayView myView(viewData,viewShape);
1675
1676 DataTagged myData(keys,values,myView,FunctionSpace());
1677
1678 keys.push_back(1);
1679 keys.push_back(2);
1680 keys.push_back(3);
1681
1682 DataArrayView::ValueType viewData1(3);
1683 for (int i=0;i<viewShape[0];i++) {
1684 viewData1[i]=i+1;
1685 }
1686 DataArrayView myView1(viewData1,viewShape);
1687 values.push_back(myView1);
1688
1689 DataArrayView::ValueType viewData2(3);
1690 for (int i=0;i<viewShape[0];i++) {
1691 viewData2[i]=i+2;
1692 }
1693 DataArrayView myView2(viewData2,viewShape);
1694 values.push_back(myView2);
1695
1696 DataArrayView::ValueType viewData3(3);
1697 for (int i=0;i<viewShape[0];i++) {
1698 viewData3[i]=i+3;
1699 }
1700 DataArrayView myView3(viewData3,viewShape);
1701 values.push_back(myView3);
1702
1703 myData.addTaggedValues(keys,values);
1704
1705 assert(myData.isCurrentTag(1));
1706 assert(myData.isCurrentTag(2));
1707 assert(myData.isCurrentTag(3));
1708
1709 assert(myData.getTagLookup().size()==3);
1710
1711 assert(myData.getLength()==12);
1712
1713 // data-point 0 has tag number 1 by default
1714 assert(myData.getTagNumber(0)==1);
1715
1716 assert(myData.getPointOffset(0,0)==3);
1717
1718 DataArrayView myDataView = myData.getDataPoint(0,0);
1719 assert(myDataView==myView1);
1720 assert(!myDataView.isEmpty());
1721 assert(myDataView.getOffset()==3);
1722 assert(myDataView.getRank()==1);
1723 assert(myDataView.noValues()==3);
1724 assert(myDataView.getShape().size()==1);
1725 assert(myDataView(0)==1);
1726 assert(myDataView(1)==2);
1727 assert(myDataView(2)==3);
1728
1729 myDataView = myData.getDataPointByTag(1);
1730 assert(myDataView==myView1);
1731 assert(!myDataView.isEmpty());
1732 assert(myDataView.getOffset()==3);
1733 assert(myDataView.getRank()==1);
1734 assert(myDataView.noValues()==3);
1735 assert(myDataView.getShape().size()==1);
1736 assert(myDataView(0)==1);
1737 assert(myDataView(1)==2);
1738 assert(myDataView(2)==3);
1739
1740 myDataView = myData.getDataPointByTag(2);
1741 assert(myDataView==myView2);
1742 assert(!myDataView.isEmpty());
1743 assert(myDataView.getOffset()==6);
1744 assert(myDataView.getRank()==1);
1745 assert(myDataView.noValues()==3);
1746 assert(myDataView.getShape().size()==1);
1747 assert(myDataView(0)==2);
1748 assert(myDataView(1)==3);
1749 assert(myDataView(2)==4);
1750
1751 myDataView = myData.getDataPointByTag(3);
1752 assert(myDataView==myView3);
1753 assert(!myDataView.isEmpty());
1754 assert(myDataView.getOffset()==9);
1755 assert(myDataView.getRank()==1);
1756 assert(myDataView.noValues()==3);
1757 assert(myDataView.getShape().size()==1);
1758 assert(myDataView(0)==3);
1759 assert(myDataView(1)==4);
1760 assert(myDataView(2)==5);
1761
1762 myDataView = myData.getDefaultValue();
1763 assert(myDataView==myView);
1764 assert(!myDataView.isEmpty());
1765 assert(myDataView.getOffset()==0);
1766 assert(myDataView.getRank()==1);
1767 assert(myDataView.noValues()==3);
1768 assert(myDataView.getShape().size()==1);
1769 assert(myDataView(0)==0);
1770 assert(myDataView(1)==1);
1771 assert(myDataView(2)==2);
1772
1773 // use a non-existent tag so we get a pointer to
1774 // the first element of the data array
1775 double* sampleData=myData.getSampleDataByTag(9);
1776 for (int i=0; i<myData.getLength(); i++) {
1777 if (i<3) {
1778 assert(sampleData[i]==i);
1779 } else if ((i>=3) && (i<6)) {
1780 assert(sampleData[i]==i-2);
1781 } else if ((i>=6) && (i<9)) {
1782 assert(sampleData[i]==i-4);
1783 } else {
1784 assert(sampleData[i]==i-6);
1785 }
1786 }
1787
1788 }
1789
1790 {
1791
1792 cout << "\tTest adding one key with empty value list to DataTagged with three tags." << endl;
1793
1794 DataTagged::TagListType keys;
1795 keys.push_back(1);
1796 keys.push_back(2);
1797 keys.push_back(3);
1798
1799 DataTagged::ValueListType values;
1800
1801 DataArrayView::ShapeType viewShape;
1802 viewShape.push_back(3);
1803
1804 // default value
1805 DataArrayView::ValueType viewData(3);
1806 for (int i=0;i<viewShape[0];i++) {
1807 viewData[i]=i;
1808 }
1809 DataArrayView myView(viewData,viewShape);
1810
1811 // value for tag "1"
1812 DataArray eOne(myView);
1813 for (int i=0;i<eOne.getView().getShape()[0];i++) {
1814 eOne.getView()(i)=i+1.0;
1815 }
1816 values.push_back(eOne.getView());
1817
1818 // value for tag "2"
1819 DataArray eTwo(myView);
1820 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
1821 eTwo.getView()(i)=i+2.0;
1822 }
1823 values.push_back(eTwo.getView());
1824
1825 // value for tag "3"
1826 DataArray eThree(myView);
1827 for (int i=0;i<eThree.getView().getShape()[0];i++) {
1828 eThree.getView()(i)=i+3.0;
1829 }
1830 values.push_back(eThree.getView());
1831
1832 DataTagged myData(keys,values,myView,FunctionSpace());
1833
1834 keys.clear();
1835 keys.push_back(4);
1836 values.clear();
1837
1838 myData.addTaggedValues(keys,values);
1839
1840 assert(myData.isCurrentTag(4));
1841
1842 assert(myData.getTagLookup().size()==4);
1843
1844 assert(myData.getLength()==15);
1845
1846 DataArrayView myDataView = myData.getDataPointByTag(4);
1847 assert(myDataView==myView);
1848 assert(!myDataView.isEmpty());
1849 assert(myDataView.getOffset()==12);
1850 assert(myDataView.getRank()==1);
1851 assert(myDataView.noValues()==3);
1852 assert(myDataView.getShape().size()==1);
1853 assert(myDataView(0)==0);
1854 assert(myDataView(1)==1);
1855 assert(myDataView(2)==2);
1856
1857 // use a non-existent tag so we get a pointer to
1858 // the first element of the data array
1859 double* sampleData=myData.getSampleDataByTag(9);
1860 for (int i=0; i<myData.getLength(); i++) {
1861 if (i<3) {
1862 assert(sampleData[i]==i);
1863 } else if ((i>=3) && (i<6)) {
1864 assert(sampleData[i]==i-2);
1865 } else if ((i>=6) && (i<9)) {
1866 assert(sampleData[i]==i-4);
1867 } else if ((i>=9) && (i<12)) {
1868 assert(sampleData[i]==i-6);
1869 } else {
1870 assert(sampleData[i]==i-12);
1871 }
1872 }
1873
1874 }
1875
1876 {
1877
1878 cout << "\tTest adding one key with one value to DataTagged with three tags." << endl;
1879
1880 DataTagged::TagListType keys;
1881 keys.push_back(1);
1882 keys.push_back(2);
1883 keys.push_back(3);
1884
1885 DataTagged::ValueListType values;
1886
1887 DataArrayView::ShapeType viewShape;
1888 viewShape.push_back(3);
1889
1890 // default value
1891 DataArrayView::ValueType viewData(3);
1892 for (int i=0;i<viewShape[0];i++) {
1893 viewData[i]=i;
1894 }
1895 DataArrayView myView(viewData,viewShape);
1896
1897 // value for tag "1"
1898 DataArray eOne(myView);
1899 for (int i=0;i<eOne.getView().getShape()[0];i++) {
1900 eOne.getView()(i)=i+1.0;
1901 }
1902 values.push_back(eOne.getView());
1903
1904 // value for tag "2"
1905 DataArray eTwo(myView);
1906 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
1907 eTwo.getView()(i)=i+2.0;
1908 }
1909 values.push_back(eTwo.getView());
1910
1911 // value for tag "3"
1912 DataArray eThree(myView);
1913 for (int i=0;i<eThree.getView().getShape()[0];i++) {
1914 eThree.getView()(i)=i+3.0;
1915 }
1916 values.push_back(eThree.getView());
1917
1918 DataTagged myData(keys,values,myView,FunctionSpace());
1919
1920 keys.clear();
1921 keys.push_back(4);
1922
1923 values.clear();
1924 // value for tag "4"
1925 DataArray eFour(myView);
1926 for (int i=0;i<eFour.getView().getShape()[0];i++) {
1927 eFour.getView()(i)=i+4.0;
1928 }
1929 values.push_back(eFour.getView());
1930
1931 myData.addTaggedValues(keys,values);
1932
1933 assert(myData.isCurrentTag(4));
1934
1935 assert(myData.getTagLookup().size()==4);
1936
1937 assert(myData.getLength()==15);
1938
1939 DataArrayView myDataView = myData.getDataPointByTag(4);
1940 assert(myDataView==eFour.getView());
1941 assert(!myDataView.isEmpty());
1942 assert(myDataView.getOffset()==12);
1943 assert(myDataView.getRank()==1);
1944 assert(myDataView.noValues()==3);
1945 assert(myDataView.getShape().size()==1);
1946 assert(myDataView(0)==4);
1947 assert(myDataView(1)==5);
1948 assert(myDataView(2)==6);
1949
1950 // use a non-existent tag so we get a pointer to
1951 // the first element of the data array
1952 double* sampleData=myData.getSampleDataByTag(9);
1953 for (int i=0; i<myData.getLength(); i++) {
1954 if (i<3) {
1955 assert(sampleData[i]==i);
1956 } else if ((i>=3) && (i<6)) {
1957 assert(sampleData[i]==i-2);
1958 } else if ((i>=6) && (i<9)) {
1959 assert(sampleData[i]==i-4);
1960 } else if ((i>=9) && (i<12)) {
1961 assert(sampleData[i]==i-6);
1962 } else {
1963 assert(sampleData[i]==i-8);
1964 }
1965 }
1966
1967 }
1968
1969 {
1970
1971 cout << "\tTest adding three keys with one value to DataTagged with three tags." << endl;
1972
1973 DataTagged::TagListType keys;
1974 keys.push_back(1);
1975 keys.push_back(2);
1976 keys.push_back(3);
1977
1978 DataTagged::ValueListType values;
1979
1980 DataArrayView::ShapeType viewShape;
1981 viewShape.push_back(3);
1982
1983 // default value
1984 DataArrayView::ValueType viewData(3);
1985 for (int i=0;i<viewShape[0];i++) {
1986 viewData[i]=i;
1987 }
1988 DataArrayView myView(viewData,viewShape);
1989
1990 // value for tag "1"
1991 DataArray eOne(myView);
1992 for (int i=0;i<eOne.getView().getShape()[0];i++) {
1993 eOne.getView()(i)=i+1.0;
1994 }
1995 values.push_back(eOne.getView());
1996
1997 // value for tag "2"
1998 DataArray eTwo(myView);
1999 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2000 eTwo.getView()(i)=i+2.0;
2001 }
2002 values.push_back(eTwo.getView());
2003
2004 // value for tag "3"
2005 DataArray eThree(myView);
2006 for (int i=0;i<eThree.getView().getShape()[0];i++) {
2007 eThree.getView()(i)=i+3.0;
2008 }
2009 values.push_back(eThree.getView());
2010
2011 DataTagged myData(keys,values,myView,FunctionSpace());
2012
2013 keys.clear();
2014 keys.push_back(4);
2015 keys.push_back(5);
2016 keys.push_back(6);
2017
2018 values.clear();
2019 // value for tags "4", "5" and "6"
2020 DataArray eFour(myView);
2021 for (int i=0;i<eFour.getView().getShape()[0];i++) {
2022 eFour.getView()(i)=i+4.0;
2023 }
2024 values.push_back(eFour.getView());
2025
2026 myData.addTaggedValues(keys,values);
2027
2028 assert(myData.isCurrentTag(4));
2029 assert(myData.isCurrentTag(5));
2030 assert(myData.isCurrentTag(6));
2031
2032 assert(myData.getTagLookup().size()==6);
2033
2034 assert(myData.getLength()==21);
2035
2036 DataArrayView myDataView = myData.getDataPointByTag(4);
2037 assert(myDataView==eFour.getView());
2038 assert(!myDataView.isEmpty());
2039 assert(myDataView.getOffset()==12);
2040 assert(myDataView.getRank()==1);
2041 assert(myDataView.noValues()==3);
2042 assert(myDataView.getShape().size()==1);
2043 assert(myDataView(0)==4);
2044 assert(myDataView(1)==5);
2045 assert(myDataView(2)==6);
2046
2047 myDataView = myData.getDataPointByTag(5);
2048 assert(myDataView==eFour.getView());
2049 assert(!myDataView.isEmpty());
2050 assert(myDataView.getOffset()==15);
2051 assert(myDataView.getRank()==1);
2052 assert(myDataView.noValues()==3);
2053 assert(myDataView.getShape().size()==1);
2054 assert(myDataView(0)==4);
2055 assert(myDataView(1)==5);
2056 assert(myDataView(2)==6);
2057
2058 myDataView = myData.getDataPointByTag(6);
2059 assert(myDataView==eFour.getView());
2060 assert(!myDataView.isEmpty());
2061 assert(myDataView.getOffset()==18);
2062 assert(myDataView.getRank()==1);
2063 assert(myDataView.noValues()==3);
2064 assert(myDataView.getShape().size()==1);
2065 assert(myDataView(0)==4);
2066 assert(myDataView(1)==5);
2067 assert(myDataView(2)==6);
2068
2069 // use a non-existent tag so we get a pointer to
2070 // the first element of the data array
2071 double* sampleData=myData.getSampleDataByTag(9);
2072 for (int i=0; i<myData.getLength(); i++) {
2073 if (i<3) {
2074 assert(sampleData[i]==i);
2075 } else if ((i>=3) && (i<6)) {
2076 assert(sampleData[i]==i-2);
2077 } else if ((i>=6) && (i<9)) {
2078 assert(sampleData[i]==i-4);
2079 } else if ((i>=9) && (i<12)) {
2080 assert(sampleData[i]==i-6);
2081 } else if ((i>=12) && (i<15)) {
2082 assert(sampleData[i]==i-8);
2083 } else if ((i>=15) && (i<18)) {
2084 assert(sampleData[i]==i-11);
2085 } else {
2086 assert(sampleData[i]==i-14);
2087 }
2088 }
2089
2090 }
2091
2092 {
2093
2094 cout << "\tTest adding three keys with three values to DataTagged with three tags." << endl;
2095
2096 DataTagged::TagListType keys;
2097 keys.push_back(1);
2098 keys.push_back(2);
2099 keys.push_back(3);
2100
2101 DataTagged::ValueListType values;
2102
2103 DataArrayView::ShapeType viewShape;
2104 viewShape.push_back(3);
2105
2106 // default value
2107 DataArrayView::ValueType viewData(3);
2108 for (int i=0;i<viewShape[0];i++) {
2109 viewData[i]=i;
2110 }
2111 DataArrayView myView(viewData,viewShape);
2112
2113 // value for tag "1"
2114 DataArray eOne(myView);
2115 for (int i=0;i<eOne.getView().getShape()[0];i++) {
2116 eOne.getView()(i)=i+1.0;
2117 }
2118 values.push_back(eOne.getView());
2119
2120 // value for tag "2"
2121 DataArray eTwo(myView);
2122 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2123 eTwo.getView()(i)=i+2.0;
2124 }
2125 values.push_back(eTwo.getView());
2126
2127 // value for tag "3"
2128 DataArray eThree(myView);
2129 for (int i=0;i<eThree.getView().getShape()[0];i++) {
2130 eThree.getView()(i)=i+3.0;
2131 }
2132 values.push_back(eThree.getView());
2133
2134 DataTagged myData(keys,values,myView,FunctionSpace());
2135
2136 keys.clear();
2137 keys.push_back(4);
2138 keys.push_back(5);
2139 keys.push_back(6);
2140
2141 values.clear();
2142
2143 // value for tag "4"
2144 DataArray eFour(myView);
2145 for (int i=0;i<eFour.getView().getShape()[0];i++) {
2146 eFour.getView()(i)=i+4.0;
2147 }
2148 values.push_back(eFour.getView());
2149
2150 // value for tag "5"
2151 DataArray eFive(myView);
2152 for (int i=0;i<eFive.getView().getShape()[0];i++) {
2153 eFive.getView()(i)=i+5.0;
2154 }
2155 values.push_back(eFive.getView());
2156
2157 // value for tag "6"
2158 DataArray eSix(myView);
2159 for (int i=0;i<eSix.getView().getShape()[0];i++) {
2160 eSix.getView()(i)=i+6.0;
2161 }
2162 values.push_back(eSix.getView());
2163
2164 myData.addTaggedValues(keys,values);
2165
2166 assert(myData.isCurrentTag(4));
2167 assert(myData.isCurrentTag(5));
2168 assert(myData.isCurrentTag(6));
2169
2170 assert(myData.getTagLookup().size()==6);
2171
2172 assert(myData.getLength()==21);
2173
2174 DataArrayView myDataView = myData.getDataPointByTag(4);
2175 assert(myDataView==eFour.getView());
2176 assert(!myDataView.isEmpty());
2177 assert(myDataView.getOffset()==12);
2178 assert(myDataView.getRank()==1);
2179 assert(myDataView.noValues()==3);
2180 assert(myDataView.getShape().size()==1);
2181 assert(myDataView(0)==4);
2182 assert(myDataView(1)==5);
2183 assert(myDataView(2)==6);
2184
2185 myDataView = myData.getDataPointByTag(5);
2186 assert(myDataView==eFive.getView());
2187 assert(!myDataView.isEmpty());
2188 assert(myDataView.getOffset()==15);
2189 assert(myDataView.getRank()==1);
2190 assert(myDataView.noValues()==3);
2191 assert(myDataView.getShape().size()==1);
2192 assert(myDataView(0)==5);
2193 assert(myDataView(1)==6);
2194 assert(myDataView(2)==7);
2195
2196 myDataView = myData.getDataPointByTag(6);
2197 assert(myDataView==eSix.getView());
2198 assert(!myDataView.isEmpty());
2199 assert(myDataView.getOffset()==18);
2200 assert(myDataView.getRank()==1);
2201 assert(myDataView.noValues()==3);
2202 assert(myDataView.getShape().size()==1);
2203 assert(myDataView(0)==6);
2204 assert(myDataView(1)==7);
2205 assert(myDataView(2)==8);
2206
2207 // use a non-existent tag so we get a pointer to
2208 // the first element of the data array
2209 double* sampleData=myData.getSampleDataByTag(9);
2210 for (int i=0; i<myData.getLength(); i++) {
2211 if (i<3) {
2212 assert(sampleData[i]==i);
2213 } else if ((i>=3) && (i<6)) {
2214 assert(sampleData[i]==i-2);
2215 } else if ((i>=6) && (i<9)) {
2216 assert(sampleData[i]==i-4);
2217 } else if ((i>=9) && (i<12)) {
2218 assert(sampleData[i]==i-6);
2219 } else if ((i>=12) && (i<15)) {
2220 assert(sampleData[i]==i-8);
2221 } else if ((i>=15) && (i<18)) {
2222 assert(sampleData[i]==i-10);
2223 } else {
2224 assert(sampleData[i]==i-12);
2225 }
2226 }
2227
2228 }
2229
2230 }
2231
2232 void DataTaggedTestCase::testSetTaggedValue() {
2233
2234 cout << endl;
2235
2236 {
2237
2238 cout << "\tTest setting key in DataTagged with three tags." << endl;
2239
2240 DataTagged::TagListType keys;
2241 keys.push_back(1);
2242 keys.push_back(2);
2243 keys.push_back(3);
2244
2245 DataTagged::ValueListType values;
2246
2247 DataArrayView::ShapeType viewShape;
2248 viewShape.push_back(3);
2249
2250 // default value
2251 DataArrayView::ValueType viewData(3);
2252 for (int i=0;i<viewShape[0];i++) {
2253 viewData[i]=i;
2254 }
2255 DataArrayView myView(viewData,viewShape);
2256
2257 // value for tag "1"
2258 DataArray eOne(myView);
2259 for (int i=0;i<eOne.getView().getShape()[0];i++) {
2260 eOne.getView()(i)=i+1.0;
2261 }
2262 values.push_back(eOne.getView());
2263
2264 // value for tag "2"
2265 DataArray eTwo(myView);
2266 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2267 eTwo.getView()(i)=i+2.0;
2268 }
2269 values.push_back(eTwo.getView());
2270
2271 // value for tag "3"
2272 DataArray eThree(myView);
2273 for (int i=0;i<eThree.getView().getShape()[0];i++) {
2274 eThree.getView()(i)=i+3.0;
2275 }
2276 values.push_back(eThree.getView());
2277
2278 DataTagged myData(keys,values,myView,FunctionSpace());
2279
2280 // new value for tag "2"
2281 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2282 eTwo.getView()(i)=i+5.0;
2283 }
2284
2285 myData.setTaggedValue(2,eTwo.getView());
2286
2287 assert(myData.isCurrentTag(2));
2288
2289 assert(myData.getTagLookup().size()==3);
2290
2291 assert(myData.getLength()==12);
2292
2293 DataArrayView myDataView = myData.getDataPointByTag(2);
2294 assert(myDataView==eTwo.getView());
2295 assert(!myDataView.isEmpty());
2296 assert(myDataView.getOffset()==6);
2297 assert(myDataView.getRank()==1);
2298 assert(myDataView.noValues()==3);
2299 assert(myDataView.getShape().size()==1);
2300 assert(myDataView(0)==5);
2301 assert(myDataView(1)==6);
2302 assert(myDataView(2)==7);
2303
2304 // use a non-existent tag so we get a pointer to
2305 // the first element of the data array
2306 double* sampleData=myData.getSampleDataByTag(9);
2307 for (int i=0; i<myData.getLength(); i++) {
2308 if (i<3) {
2309 assert(sampleData[i]==i);
2310 } else if ((i>=3) && (i<6)) {
2311 assert(sampleData[i]==i-2);
2312 } else if ((i>=6) && (i<9)) {
2313 assert(sampleData[i]==i-1);
2314 } else {
2315 assert(sampleData[i]==i-6);
2316 }
2317 }
2318
2319 }
2320
2321 }
2322
2323 void DataTaggedTestCase::testAll() {
2324
2325 cout << endl;
2326
2327 {
2328
2329 cout << "\tTest default DataTagged." << endl;
2330 DataTagged myData;
2331
2332 //cout << myData.toString() << endl;
2333
2334 assert(myData.getNumSamples()==1);
2335 assert(myData.getNumDPPSample()==1);
2336
2337 assert(myData.validSamplePointNo(0));
2338 assert(myData.validSampleNo(0));
2339 assert(!myData.validSamplePointNo(1));
2340 assert(!myData.validSampleNo(1));
2341
2342 // data-point 0 has tag number 1 by default
2343 assert(myData.getTagNumber(0)==1);
2344
2345 assert(!myData.isCurrentTag(1));
2346
2347 assert(myData.getTagLookup().size()==0);
2348
2349 assert(myData.getLength()==1);
2350
2351 assert(myData.getPointOffset(0,0)==0);
2352
2353 DataArrayView myDataView = myData.getDataPoint(0,0);
2354 assert(!myDataView.isEmpty());
2355 assert(myDataView.getOffset()==0);
2356 assert(myDataView.getRank()==0);
2357 assert(myDataView.noValues()==1);
2358 assert(myDataView.getShape().size()==0);
2359 assert(myDataView()==0.0);
2360
2361 // Test non-existent tag returns the default value.
2362 myDataView = myData.getDataPointByTag(1);
2363 assert(!myDataView.isEmpty());
2364 assert(myDataView.getOffset()==0);
2365 assert(myDataView.getRank()==0);
2366 assert(myDataView.noValues()==1);
2367 assert(myDataView.getShape().size()==0);
2368 assert(myDataView()==0.0);
2369
2370 myDataView = myData.getDefaultValue();
2371 assert(!myDataView.isEmpty());
2372 assert(myDataView.getOffset()==0);
2373 assert(myDataView.getRank()==0);
2374 assert(myDataView.noValues()==1);
2375 assert(myDataView.getShape().size()==0);
2376 assert(myDataView()==0.0);
2377
2378 // use a non-existent tag so we get a pointer to
2379 // the first element of the data array
2380 double* sampleData=myData.getSampleDataByTag(9);
2381 for (int i=0; i<myData.getLength(); i++) {
2382 assert(sampleData[i]==i);
2383 }
2384 sampleData=myData.getSampleData(0);
2385 for (int i=0; i<myDataView.noValues(); i++) {
2386 assert(sampleData[i]==i);
2387 }
2388
2389 }
2390
2391 {
2392
2393 cout << "\tTest DataTagged with default value only." << endl;
2394
2395 DataArrayView::ShapeType viewShape;
2396 viewShape.push_back(3);
2397
2398 DataTagged::TagListType keys;
2399
2400 DataTagged::ValueListType values;
2401
2402 DataArrayView::ValueType viewData(3);
2403 for (int i=0;i<viewShape[0];i++) {
2404 viewData[i]=i;
2405 }
2406 DataArrayView myView(viewData,viewShape);
2407
2408 DataTagged myData(keys,values,myView,FunctionSpace());
2409
2410 //cout << myData.toString() << endl;
2411
2412 assert(myData.getNumSamples()==1);
2413 assert(myData.getNumDPPSample()==1);
2414
2415 assert(myData.validSamplePointNo(0));
2416 assert(myData.validSampleNo(0));
2417 assert(!myData.validSamplePointNo(1));
2418 assert(!myData.validSampleNo(1));
2419
2420 // data-point 0 has tag number 1 by default
2421 assert(myData.getTagNumber(0)==1);
2422
2423 assert(!myData.isCurrentTag(1));
2424
2425 assert(myData.getTagLookup().size()==0);
2426
2427 assert(myData.getLength()==3);
2428
2429 assert(myData.getPointOffset(0,0)==0);
2430
2431 DataArrayView myDataView = myData.getDataPoint(0,0);
2432 assert(myDataView==myView);
2433 assert(!myDataView.isEmpty());
2434 assert(myDataView.getOffset()==0);
2435 assert(myDataView.getRank()==1);
2436 assert(myDataView.noValues()==3);
2437 assert(myDataView.getShape().size()==1);
2438 assert(myDataView(0)==0);
2439 assert(myDataView(1)==1);
2440 assert(myDataView(2)==2);
2441
2442 // Test non-existent tag returns the default value.
2443 myDataView = myData.getDataPointByTag(1);
2444 assert(myDataView==myView);
2445 assert(!myDataView.isEmpty());
2446 assert(myDataView.getOffset()==0);
2447 assert(myDataView.getRank()==1);
2448 assert(myDataView.noValues()==3);
2449 assert(myDataView.getShape().size()==1);
2450 assert(myDataView(0)==0);
2451 assert(myDataView(1)==1);
2452 assert(myDataView(2)==2);
2453
2454 myDataView = myData.getDefaultValue();
2455 assert(myDataView==myView);
2456 assert(!myDataView.isEmpty());
2457 assert(myDataView.getOffset()==0);
2458 assert(myDataView.getRank()==1);
2459 assert(myDataView.noValues()==3);
2460 assert(myDataView.getShape().size()==1);
2461 assert(myDataView(0)==0);
2462 assert(myDataView(1)==1);
2463 assert(myDataView(2)==2);
2464
2465 // use a non-existent tag so we get a pointer to
2466 // the first element of the data array
2467 double* sampleData=myData.getSampleDataByTag(9);
2468 for (int i=0; i<myData.getLength(); i++) {
2469 assert(sampleData[i]==i);
2470 }
2471 sampleData=myData.getSampleDataByTag(0);
2472 for (int i=0; i<myDataView.noValues(); i++) {
2473 assert(sampleData[i]==i);
2474 }
2475
2476 }
2477
2478 {
2479
2480 cout << "\tTest DataTagged with one tag." << endl;
2481
2482 // the one data-point has tag value "1"
2483
2484 DataTagged::TagListType keys;
2485 keys.push_back(1);
2486
2487 DataTagged::ValueListType values;
2488
2489 DataArrayView::ShapeType viewShape;
2490 viewShape.push_back(3);
2491
2492 // default value
2493 DataArrayView::ValueType viewData(3);
2494 for (int i=0;i<viewShape[0];i++) {
2495 viewData[i]=i;
2496 }
2497 DataArrayView myView(viewData,viewShape);
2498
2499 // value for tag "1"
2500 DataArray eOne(myView);
2501 for (int i=0;i<eOne.getView().getShape()[0];i++) {
2502 eOne.getView()(i)=i+1.0;
2503 }
2504 values.push_back(eOne.getView());
2505
2506 DataTagged myData(keys,values,myView,FunctionSpace());
2507
2508 //cout << myData.toString() << endl;
2509
2510 assert(myData.getNumSamples()==1);
2511 assert(myData.getNumDPPSample()==1);
2512
2513 assert(myData.validSamplePointNo(0));
2514 assert(myData.validSampleNo(0));
2515 assert(!myData.validSamplePointNo(1));
2516 assert(!myData.validSampleNo(1));
2517
2518 // data-point 0 has tag number 1 by default
2519 assert(myData.getTagNumber(0)==1);
2520
2521 assert(!myData.isCurrentTag(0));
2522 assert(myData.isCurrentTag(1));
2523
2524 assert(myData.getTagLookup().size()==1);
2525
2526 assert(myData.getLength()==6);
2527
2528 assert(myData.getPointOffset(0,0)==3);
2529
2530 DataArrayView myDataView = myData.getDataPoint(0,0);
2531 assert(myDataView==eOne.getView());
2532 assert(!myDataView.isEmpty());
2533 assert(myDataView.getOffset()==3);
2534 assert(myDataView.getRank()==1);
2535 assert(myDataView.noValues()==3);
2536 assert(myDataView.getShape().size()==1);
2537 assert(myDataView(0)==1);
2538 assert(myDataView(1)==2);
2539 assert(myDataView(2)==3);
2540
2541 myDataView = myData.getDataPointByTag(1);
2542 assert(myDataView==eOne.getView());
2543 assert(!myDataView.isEmpty());
2544 assert(myDataView.getOffset()==3);
2545 assert(myDataView.getRank()==1);
2546 assert(myDataView.noValues()==3);
2547 assert(myDataView.getShape().size()==1);
2548 assert(myDataView(0)==1);
2549 assert(myDataView(1)==2);
2550 assert(myDataView(2)==3);
2551
2552 // Test non-existent tag returns the default value.
2553 myDataView = myData.getDataPointByTag(9);
2554 assert(myDataView==myView);
2555 assert(!myDataView.isEmpty());
2556 assert(myDataView.getOffset()==0);
2557 assert(myDataView.getRank()==1);
2558 assert(myDataView.noValues()==3);
2559 assert(myDataView.getShape().size()==1);
2560 assert(myDataView(0)==0);
2561 assert(myDataView(1)==1);
2562 assert(myDataView(2)==2);
2563
2564 myDataView = myData.getDefaultValue();
2565 assert(myDataView==myView);
2566 assert(!myDataView.isEmpty());
2567 assert(myDataView.getOffset()==0);
2568 assert(myDataView.getRank()==1);
2569 assert(myDataView.noValues()==3);
2570 assert(myDataView.getShape().size()==1);
2571 assert(myDataView(0)==0);
2572 assert(myDataView(1)==1);
2573 assert(myDataView(2)==2);
2574
2575 // use a non-existent tag so we get a pointer to
2576 // the first element of the data array
2577 double* sampleData=myData.getSampleDataByTag(9);
2578 for (int i=0; i<myData.getLength(); i++) {
2579 if (i<3) {
2580 assert(sampleData[i]==i);
2581 } else {
2582 assert(sampleData[i]==i-2);
2583 }
2584 }
2585 sampleData=myData.getSampleData(0);
2586 for (int i=0; i<myDataView.noValues(); i++) {
2587 assert(sampleData[i]==i+1);
2588 }
2589
2590 }
2591
2592 {
2593
2594 cout << "\tTest DataTagged with multiple tags." << endl;
2595
2596 // the one data-point has tag value "1"
2597
2598 DataTagged::TagListType keys;
2599 keys.push_back(1);
2600 keys.push_back(2);
2601 keys.push_back(3);
2602
2603 DataTagged::ValueListType values;
2604
2605 DataArrayView::ShapeType viewShape;
2606 viewShape.push_back(3);
2607
2608 // default value
2609 DataArrayView::ValueType viewData(3);
2610 for (int i=0;i<viewShape[0];i++) {
2611 viewData[i]=i;
2612 }
2613 DataArrayView myView(viewData,viewShape);
2614
2615 // value for tag "1"
2616 DataArray eOne(myView);
2617 for (int i=0;i<eOne.getView().getShape()[0];i++) {
2618 eOne.getView()(i)=i+1.0;
2619 }
2620 values.push_back(eOne.getView());
2621
2622 // value for tag "2"
2623 DataArray eTwo(myView);
2624 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2625 eTwo.getView()(i)=i+2.0;
2626 }
2627 values.push_back(eTwo.getView());
2628
2629 // value for tag "3"
2630 DataArray eThree(myView);
2631 for (int i=0;i<eThree.getView().getShape()[0];i++) {
2632 eThree.getView()(i)=i+3.0;
2633 }
2634 values.push_back(eThree.getView());
2635
2636 DataTagged myData(keys,values,myView,FunctionSpace());
2637
2638 //cout << myData.toString() << endl;
2639
2640 assert(myData.getNumSamples()==1);
2641 assert(myData.getNumDPPSample()==1);
2642
2643 assert(myData.validSamplePointNo(0));
2644 assert(myData.validSampleNo(0));
2645 assert(!myData.validSamplePointNo(1));
2646 assert(!myData.validSampleNo(1));
2647
2648 // data-point 0 has tag number 1 by default
2649 assert(myData.getTagNumber(0)==1);
2650
2651 assert(!myData.isCurrentTag(0));
2652 assert(myData.isCurrentTag(1));
2653 assert(myData.isCurrentTag(2));
2654 assert(myData.isCurrentTag(3));
2655
2656 assert(myData.getTagLookup().size()==3);
2657
2658 assert(myData.getLength()==12);
2659
2660 assert(myData.getPointOffset(0,0)==3);
2661
2662 DataArrayView myDataView = myData.getDataPoint(0,0);
2663 assert(myDataView==eOne.getView());
2664 assert(!myDataView.isEmpty());
2665 assert(myDataView.getOffset()==3);
2666 assert(myDataView.getRank()==1);
2667 assert(myDataView.noValues()==3);
2668 assert(myDataView.getShape().size()==1);
2669 assert(myDataView(0)==1);
2670 assert(myDataView(1)==2);
2671 assert(myDataView(2)==3);
2672
2673 myDataView = myData.getDataPointByTag(1);
2674 assert(myDataView==eOne.getView());
2675 assert(!myDataView.isEmpty());
2676 assert(myDataView.getOffset()==3);
2677 assert(myDataView.getRank()==1);
2678 assert(myDataView.noValues()==3);
2679 assert(myDataView.getShape().size()==1);
2680 assert(myDataView(0)==1);
2681 assert(myDataView(1)==2);
2682 assert(myDataView(2)==3);
2683
2684 // Test non-existent tag returns the default value.
2685 myDataView = myData.getDataPointByTag(0);
2686 assert(myDataView==myView);
2687 assert(!myDataView.isEmpty());
2688 assert(myDataView.getOffset()==0);
2689 assert(myDataView.getRank()==1);
2690 assert(myDataView.noValues()==3);
2691 assert(myDataView.getShape().size()==1);
2692 assert(myDataView(0)==0);
2693 assert(myDataView(1)==1);
2694 assert(myDataView(2)==2);
2695
2696 myDataView = myData.getDefaultValue();
2697 assert(myDataView==myView);
2698 assert(!myDataView.isEmpty());
2699 assert(myDataView.getOffset()==0);
2700 assert(myDataView.getRank()==1);
2701 assert(myDataView.noValues()==3);
2702 assert(myDataView.getShape().size()==1);
2703 assert(myDataView(0)==0);
2704 assert(myDataView(1)==1);
2705 assert(myDataView(2)==2);
2706
2707 // Test data-points held for remaining tags
2708 myDataView = myData.getDataPointByTag(2);
2709 assert(myDataView==eTwo.getView());
2710 assert(!myDataView.isEmpty());
2711 assert(myDataView.getOffset()==6);
2712 assert(myDataView.getRank()==1);
2713 assert(myDataView.noValues()==3);
2714 assert(myDataView.getShape().size()==1);
2715 assert(myDataView(0)==2);
2716 assert(myDataView(1)==3);
2717 assert(myDataView(2)==4);
2718
2719 myDataView = myData.getDataPointByTag(3);
2720 assert(myDataView==eThree.getView());
2721 assert(!myDataView.isEmpty());
2722 assert(myDataView.getOffset()==9);
2723 assert(myDataView.getRank()==1);
2724 assert(myDataView.noValues()==3);
2725 assert(myDataView.getShape().size()==1);
2726 assert(myDataView(0)==3);
2727 assert(myDataView(1)==4);
2728 assert(myDataView(2)==5);
2729
2730 // use a non-existent tag so we get a pointer to
2731 // the first element of the data array
2732 double* sampleData=myData.getSampleDataByTag(9);
2733 for (int i=0; i<myData.getLength(); i++) {
2734 if (i<3) {
2735 assert(sampleData[i]==i);
2736 } else if ((i>=3) && (i<6)) {
2737 assert(sampleData[i]==i-2);
2738 } else if ((i>=6) && (i<9)) {
2739 assert(sampleData[i]==i-4);
2740 } else {
2741 assert(sampleData[i]==i-6);
2742 }
2743 }
2744 sampleData=myData.getSampleData(0);
2745 for (int i=0; i<myDataView.noValues(); i++) {
2746 assert(sampleData[i]==i+1);
2747 }
2748
2749 }
2750
2751 }
2752
2753 void DataTaggedTestCase::testCopyConstructors() {
2754
2755 cout << endl;
2756
2757 {
2758
2759 cout << "\tTest DataTagged copy constructor for DataTagged with multiple tags." << endl;
2760
2761 // the one data-point has tag value "1"
2762
2763 DataTagged::TagListType keys;
2764 keys.push_back(1);
2765 keys.push_back(2);
2766 keys.push_back(3);
2767
2768 DataTagged::ValueListType values;
2769
2770 DataArrayView::ShapeType viewShape;
2771 viewShape.push_back(3);
2772
2773 // default value
2774 DataArrayView::ValueType viewData(3);
2775 for (int i=0;i<viewShape[0];i++) {
2776 viewData[i]=i;
2777 }
2778 DataArrayView myView(viewData,viewShape);
2779
2780 // value for tag "1"
2781 DataArray eOne(myView);
2782 for (int i=0;i<eOne.getView().getShape()[0];i++) {
2783 eOne.getView()(i)=i+1.0;
2784 }
2785 values.push_back(eOne.getView());
2786
2787 // value for tag "2"
2788 DataArray eTwo(myView);
2789 for (int i=0;i<eTwo.getView().getShape()[0];i++) {
2790 eTwo.getView()(i)=i+2.0;
2791 }
2792 values.push_back(eTwo.getView());
2793
2794 // value for tag "3"
2795 DataArray eThree(myView);
2796 for (int i=0;i<eThree.getView().getShape()[0];i++) {
2797 eThree.getView()(i)=i+3.0;
2798 }
2799 values.push_back(eThree.getView());
2800
2801 DataTagged myData(keys,values,myView,FunctionSpace());
2802
2803 DataTagged myDataCopy(myData);
2804
2805 //cout << myDataCopy.toString() << endl;
2806
2807 assert(myDataCopy.getNumSamples()==1);
2808 assert(myDataCopy.getNumDPPSample()==1);
2809
2810 assert(myDataCopy.validSamplePointNo(0));
2811 assert(myDataCopy.validSampleNo(0));
2812 assert(!myDataCopy.validSamplePointNo(1));
2813 assert(!myDataCopy.validSampleNo(1));
2814
2815 // data-point 0 has tag number 1 by default
2816 assert(myDataCopy.getTagNumber(0)==1);
2817
2818 assert(!myDataCopy.isCurrentTag(0));
2819 assert(myDataCopy.isCurrentTag(1));
2820 assert(myDataCopy.isCurrentTag(2));
2821 assert(myDataCopy.isCurrentTag(3));
2822
2823 assert(myDataCopy.getTagLookup().size()==3);
2824
2825 assert(myDataCopy.getLength()==12);
2826
2827 assert(myDataCopy.getPointOffset(0,0)==3);
2828
2829 DataArrayView myDataView = myDataCopy.getDataPoint(0,0);
2830 assert(myDataView==eOne.getView());
2831 assert(!myDataView.isEmpty());
2832 assert(myDataView.getOffset()==3);
2833 assert(myDataView.getRank()==1);
2834 assert(myDataView.noValues()==3);
2835 assert(myDataView.getShape().size()==1);
2836 assert(myDataView(0)==1);
2837 assert(myDataView(1)==2);
2838 assert(myDataView(2)==3);
2839
2840 myDataView = myDataCopy.getDataPointByTag(1);
2841 assert(myDataView==eOne.getView());
2842 assert(!myDataView.isEmpty());
2843 assert(myDataView.getOffset()==3);
2844 assert(myDataView.getRank()==1);
2845 assert(myDataView.noValues()==3);
2846 assert(myDataView.getShape().size()==1);
2847 assert(myDataView(0)==1);
2848 assert(myDataView(1)==2);
2849 assert(myDataView(2)==3);
2850
2851 // Test non-existent tag returns the default value.
2852 myDataView = myDataCopy.getDataPointByTag(0);
2853 assert(myDataView==myView);
2854 assert(!myDataView.isEmpty());
2855 assert(myDataView.getOffset()==0);
2856 assert(myDataView.getRank()==1);
2857 assert(myDataView.noValues()==3);
2858 assert(myDataView.getShape().size()==1);
2859 assert(myDataView(0)==0);
2860 assert(myDataView(1)==1);
2861 assert(myDataView(2)==2);
2862
2863 myDataView = myDataCopy.getDefaultValue();
2864 assert(myDataView==myView);
2865 assert(!myDataView.isEmpty());
2866 assert(myDataView.getOffset()==0);
2867 assert(myDataView.getRank()==1);
2868 assert(myDataView.noValues()==3);
2869 assert(myDataView.getShape().size()==1);
2870 assert(myDataView(0)==0);
2871 assert(myDataView(1)==1);
2872 assert(myDataView(2)==2);
2873
2874 // Test data-points held for remaining tags
2875 myDataView = myDataCopy.getDataPointByTag(2);
2876 assert(myDataView==eTwo.getView());
2877 assert(!myDataView.isEmpty());
2878 assert(myDataView.getOffset()==6);
2879 assert(myDataView.getRank()==1);
2880 assert(myDataView.noValues()==3);
2881 assert(myDataView.getShape().size()==1);
2882 assert(myDataView(0)==2);
2883 assert(myDataView(1)==3);
2884 assert(myDataView(2)==4);
2885
2886 myDataView = myDataCopy.getDataPointByTag(3);
2887 assert(myDataView==eThree.getView());
2888 assert(!myDataView.isEmpty());
2889 assert(myDataView.getOffset()==9);
2890 assert(myDataView.getRank()==1);
2891 assert(myDataView.noValues()==3);
2892 assert(myDataView.getShape().size()==1);
2893 assert(myDataView(0)==3);
2894 assert