Intrepid
test_01.cpp
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
51 #include "Teuchos_oblackholestream.hpp"
52 #include "Teuchos_RCP.hpp"
53 #include "Teuchos_GlobalMPISession.hpp"
54 
55 
56 using namespace Intrepid;
57 
58 int main(int argc, char *argv[]) {
59 
60  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
61 
62  // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
63  int iprint = argc - 1;
64 
65  Teuchos::RCP<std::ostream> outStream;
66  Teuchos::oblackholestream bhs; // outputs nothing
67 
68  if (iprint > 0)
69  outStream = Teuchos::rcp(&std::cout, false);
70  else
71  outStream = Teuchos::rcp(&bhs, false);
72 
73  // Save the format state of the original std::cout.
74  Teuchos::oblackholestream oldFormatState;
75  oldFormatState.copyfmt(std::cout);
76 
77  *outStream \
78  << "===============================================================================\n" \
79  << "| |\n" \
80  << "| Unit Test FieldContainer |\n" \
81  << "| |\n" \
82  << "| 1) Value accesss by multi-index and enumeration, setting values |\n" \
83  << "| |\n" \
84  << "| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \
85  << "| Denis Ridzal (dridzal@sandia.gov). |\n" \
86  << "| |\n" \
87  << "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
88  << "| Trilinos website: http://trilinos.sandia.gov |\n" \
89  << "| |\n" \
90  << "===============================================================================\n";
91 
92  int errorFlag = 0;
93 
94  // Define variables to construct and use FieldContainer:
95  Teuchos::Array<double> dataArray;
96  Teuchos::Array<int> dimension;
97  Teuchos::Array<int> multiIndex;
98  int dim0, dim1, dim2, dim3, dim4;
99  int containerSize;
100  int containerRank;
101  int dataSize;
102  int counter;
103 
104 
105  *outStream \
106  << "\n"
107  << "===============================================================================\n"\
108  << "| TEST 1: Rank-1 FieldContainer |\n"\
109  << "===============================================================================\n";
110 
111  // Adjust for rank-1 containers
112  dimension.resize(1);
113  multiIndex.resize(1);
114  dim0 = 267;
115 
116  // Set dimensions
117  dimension[0] = dim0;
118 
119  // Define Teuchos::Array with dimension equal to FieldContainer capacity (determined from dimension)
120  dataSize = dimension[0];
121  dataArray.resize(dataSize);
122 
123  // Fill with data
124  counter = 0;
125  for(int i=0; i < dimension[0]; i++){
126  dataArray[counter] = (double)counter;
127  counter++;
128  }
129 
130  *outStream \
131  << "\n"
132  << "===============================================================================\n"\
133  << "| TEST 1-a: Compare constructors with array and list of dimensions |\n"\
134  << "===============================================================================\n";
135  try{
136 
137  // Using ctor with array of dimensions and array of data
138  FieldContainer<double> rank1Container(dimension, dataArray);
139 
140  // Using ctor with list of dimensions and no data
141  FieldContainer<double> rank1ContainerAlt(dim0);
142 
143  // Initialize variables
144  containerSize = rank1Container.size();
145  containerRank = rank1Container.rank();
146  multiIndex.resize(containerRank);
147 
148  if( rank1Container.size() != rank1ContainerAlt.size() ) {
149  errorFlag++;
150  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
151  *outStream << " Size using ctor with array of dimensions = " << rank1Container.size() << "\n";
152  *outStream << " Size using ctor with list of dimensions = " << rank1ContainerAlt.size() << "\n";
153  }
154 
155  if( rank1Container.rank() != rank1ContainerAlt.rank() ) {
156  errorFlag++;
157  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
158  *outStream << " Rank using ctor with array of dimensions = " << rank1Container.rank() << "\n";
159  *outStream << " Rank using ctor with list of dimensions = " << rank1ContainerAlt.rank() << "\n";
160  }
161 
162  for(int dim = 0; dim < rank1Container.rank(); dim ++ ) {
163  if( rank1Container.dimension(dim) != rank1ContainerAlt.dimension(dim) ) {
164  errorFlag++;
165  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
166  *outStream << " Dimension " << dim << " using ctor with array of dimensions = " << rank1Container.dimension(dim) << "\n";
167  *outStream << " Dimension " << dim << " using ctor with list of dimensions = " << rank1ContainerAlt.dimension(dim) << "\n";
168  }
169  }
170 
171  *outStream \
172  << "\n"
173  << "===============================================================================\n"\
174  << "| TEST 1-b: Access by enumeration, multi-index array and multi-index list |\n"\
175  << "===============================================================================\n";
176 
177  // Loop over container by enumeration
178  for(int enumeration = 0; enumeration < containerSize; enumeration++) {
179  int i0;
180 
181  // Convert enumeration to multi-index array and multi-index list and compare values
182  rank1Container.getMultiIndex(multiIndex, enumeration);
183  rank1Container.getMultiIndex(i0, enumeration);
184  if( (multiIndex[0] != i0) ) {
185  errorFlag++;
186  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
187  *outStream << " Multi-index as array = ["
188  << multiIndex[0] << "]\n";
189  *outStream << " Multi-index as list = (" << i0 << ")\n";
190  }
191 
192  // Check if access by enumeration gives the same value as access by multi-index array
193  if( rank1Container[enumeration] != rank1Container.getValue(multiIndex) ) {
194  errorFlag++;
195  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
196  *outStream << " Value by enumeration = " << rank1Container[enumeration] << "\n";
197  *outStream << " Value by multi-index array = " << rank1Container.getValue(multiIndex) << "\n";
198  }
199 
200  // Check if access by multi-index list gives the same value as access by multi-index array
201  if( rank1Container(i0) != rank1Container.getValue(multiIndex) ) {
202  errorFlag++;
203  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
204  *outStream << " Value by multi-index list = " << rank1Container(i0) << "\n";
205  *outStream << " Value by multi-index array = " << rank1Container.getValue(multiIndex) << "\n";
206  }
207 
208  // Check if access by multi-index list gives the same value as access by [] (only for rank-1!)
209  if( rank1Container(i0) != rank1Container[i0] ) {
210  errorFlag++;
211  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
212  *outStream << " Value by multi-index list = " << rank1Container(i0) << "\n";
213  *outStream << " Value by overloaded [] = " << rank1Container[i0] << "\n";
214  }
215  }
216 
217  *outStream \
218  << "\n"
219  << "===============================================================================\n"\
220  << "| TEST 1-c: Access by multi-index array and list & compare with data array |\n"\
221  << "===============================================================================\n";
222 
223  // Loop over container by multi-index
224  for(int i=0; i < dimension[0]; i++){
225  multiIndex[0] = i;
226 
227  // Method that takes array of multi-indices
228  int enumeration = rank1Container.getEnumeration(multiIndex);
229 
230  // Compare with method that takes a list of multi-indices
231  if( enumeration != rank1Container.getEnumeration(i) ) {
232  errorFlag++;
233  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
234  *outStream << " Enumeration from multi-index array = " << enumeration << "\n";
235  *outStream << " Enumeration from multi-index list = " << rank1Container.getEnumeration(i) << "\n";
236  }
237 
238  // Check if access by multi-index array matches values in original dataArray
239  if(dataArray[enumeration] != rank1Container.getValue(multiIndex)) {
240  errorFlag++;
241  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
242  *outStream << " Value by multi-index array = " << rank1Container.getValue(multiIndex) << "\n";
243  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
244  }
245 
246  // Check if access by multi-index list matches values in original dataArray
247  if(dataArray[enumeration] != rank1Container(i)) {
248  errorFlag++;
249  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
250  *outStream << " Value by multi-index list = " << rank1Container(i) << "\n";
251  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
252  }
253 
254  // Check if access by multi-index array matches access by multi-index list
255  if( rank1Container(i) != rank1Container.getValue(multiIndex)) {
256  errorFlag++;
257  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
258  *outStream << " Value by multi-index array = " << rank1Container.getValue(multiIndex) << "\n";
259  *outStream << " Value by multi-index list = " << rank1Container(i) << "\n";
260  }
261  }
262 
263  *outStream \
264  << "\n"
265  << "===============================================================================\n"\
266  << "| TEST 1-d: Store zeroes and empty container |\n"\
267  << "===============================================================================\n";
268 
269  rank1Container.initialize();
270  double sum = 0.0;
271  for (int i=0; i<rank1Container.size(); i++) {
272  sum += rank1Container[i];
273  }
274  if( (sum != 0.0) ) {
275  errorFlag++;
276  *outStream << " Container size = " << rank1Container.size() << "\n";
277  *outStream << " Container rank = " << rank1Container.rank() << "\n";
278  }
279 
280  rank1Container.clear();
281  if( !(rank1Container.size() == 0 && rank1Container.rank() == 0)) {
282  errorFlag++;
283  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
284  *outStream << " Container size = " << rank1Container.size() << "\n";
285  *outStream << " Container rank = " << rank1Container.rank() << "\n";
286  }
287  } //try
288 
289  catch (std::logic_error err) {
290  *outStream << err.what() << "\n";
291  errorFlag = -1000;
292  };
293 
294 
295  *outStream \
296  << "\n"
297  << "===============================================================================\n"\
298  << "| TEST 2: Rank-2 FieldContainer |\n"\
299  << "===============================================================================\n";
300 
301  // Adjust for rank-2 containers
302  dimension.resize(2);
303  multiIndex.resize(2);
304  dim0 = 1;
305  dim1 = 55;
306 
307  // Set dimensions
308  dimension[0] = dim0;
309  dimension[1] = dim1;
310 
311  // Define Teuchos::Array with dimension equal to FieldContainer capacity (determined from dimension)
312  dataSize = dimension[0];
313  for(int r = 1; r < (int)dimension.size(); r++){
314  dataSize *= dimension[r];
315  }
316  dataArray.resize(dataSize);
317 
318  // Fill with data
319  counter = 0;
320  for(int i=0; i < dimension[0]; i++){
321  for(int j=0; j < dimension[1]; j++){
322  dataArray[counter] = (double)counter;
323  counter++;
324  }
325  }
326 
327  *outStream \
328  << "\n"
329  << "===============================================================================\n"\
330  << "| TEST 2-a: Compare constructors with array and list of dimensions |\n"\
331  << "===============================================================================\n";
332  try{
333 
334  // Using ctor with array of dimensions and array of data
335  FieldContainer<double> rank2Container(dimension, dataArray);
336 
337  // Using ctor with list of dimensions and no data
338  FieldContainer<double> rank2ContainerAlt(dim0, dim1);
339 
340  // Initialize variables
341  containerSize = rank2Container.size();
342  containerRank = rank2Container.rank();
343  multiIndex.resize(containerRank);
344 
345  if( rank2Container.size() != rank2ContainerAlt.size() ) {
346  errorFlag++;
347  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
348  *outStream << " Size using ctor with array of dimensions = " << rank2Container.size() << "\n";
349  *outStream << " Size using ctor with list of dimensions = " << rank2ContainerAlt.size() << "\n";
350  }
351 
352  if( rank2Container.rank() != rank2ContainerAlt.rank() ) {
353  errorFlag++;
354  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
355  *outStream << " Rank using ctor with array of dimensions = " << rank2Container.rank() << "\n";
356  *outStream << " Rank using ctor with list of dimensions = " << rank2ContainerAlt.rank() << "\n";
357  }
358 
359  for(int dim = 0; dim < rank2Container.rank(); dim ++ ) {
360  if( rank2Container.dimension(dim) != rank2ContainerAlt.dimension(dim) ) {
361  errorFlag++;
362  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
363  *outStream << " Dimension " << dim << " using ctor with array of dimensions = " << rank2Container.dimension(dim) << "\n";
364  *outStream << " Dimension " << dim << " using ctor with list of dimensions = " << rank2ContainerAlt.dimension(dim) << "\n";
365  }
366  }
367 
368  *outStream \
369  << "\n"
370  << "===============================================================================\n"\
371  << "| TEST 2-b: Access by enumeration, multi-index array and multi-index list |\n"\
372  << "===============================================================================\n";
373 
374  // Loop over container by enumeration
375  for(int enumeration = 0; enumeration < containerSize; enumeration++) {
376  int i0,i1;
377 
378  // Convert enumeration to multi-index array and multi-index list and compare values
379  rank2Container.getMultiIndex(multiIndex, enumeration);
380  rank2Container.getMultiIndex(i0, i1, enumeration);
381  if( (multiIndex[0] != i0) ||
382  (multiIndex[1] != i1) ) {
383  errorFlag++;
384  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
385  *outStream << " Multi-index as array = ["
386  << multiIndex[0] << multiIndex[1] << "]\n";
387  *outStream << " Multi-index as list = (" << i0 << "," << i1 << ")\n";
388  }
389 
390  // Check if access by enumeration gives the same value as access by multi-index array
391  if( rank2Container[enumeration] != rank2Container.getValue(multiIndex) ) {
392  errorFlag++;
393  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
394  *outStream << " Value by enumeration = " << rank2Container[enumeration] << "\n";
395  *outStream << " Value by multi-index array = " << rank2Container.getValue(multiIndex) << "\n";
396  }
397 
398  // Check if access by multi-index list gives the same value as access by multi-index array
399  if( rank2Container(i0,i1) != rank2Container.getValue(multiIndex) ) {
400  errorFlag++;
401  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
402  *outStream << " Value by multi-index list = " << rank2Container(i0,i1) << "\n";
403  *outStream << " Value by multi-index array = " << rank2Container.getValue(multiIndex) << "\n";
404  }
405  }
406 
407  *outStream \
408  << "\n"
409  << "===============================================================================\n"\
410  << "| TEST 2-c: Access by multi-index array and list & compare with data array |\n"\
411  << "===============================================================================\n";
412 
413  // Loop over container by multi-index
414  for(int i=0; i < dimension[0]; i++){
415  multiIndex[0] = i;
416  for(int j=0; j < dimension[1]; j++){
417  multiIndex[1] = j;
418 
419  // Method that takes array of multi-indices
420  int enumeration = rank2Container.getEnumeration(multiIndex);
421 
422  // Compare with method that takes a list of multi-indices
423  if( enumeration != rank2Container.getEnumeration(i,j) ) {
424  errorFlag++;
425  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
426  *outStream << " Enumeration from multi-index array = " << enumeration << "\n";
427  *outStream << " Enumeration from multi-index list = " << rank2Container.getEnumeration(i,j) << "\n";
428  }
429 
430  // Check if access by multi-index array matches values in original dataArray
431  if(dataArray[enumeration] != rank2Container.getValue(multiIndex)) {
432  errorFlag++;
433  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
434  *outStream << " Value by multi-index array = " << rank2Container.getValue(multiIndex) << "\n";
435  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
436  }
437 
438  // Check if access by multi-index list matches values in original dataArray
439  if(dataArray[enumeration] != rank2Container(i,j)) {
440  errorFlag++;
441  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
442  *outStream << " Value by multi-index list = " << rank2Container(i,j) << "\n";
443  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
444  }
445 
446  // Check if access by multi-index array matches access by multi-index list
447  if( rank2Container(i,j) != rank2Container.getValue(multiIndex)) {
448  errorFlag++;
449  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
450  *outStream << " Value by multi-index array = " << rank2Container.getValue(multiIndex) << "\n";
451  *outStream << " Value by multi-index list = " << rank2Container(i,j) << "\n";
452  }
453  }
454  }
455 
456  *outStream \
457  << "\n"
458  << "===============================================================================\n"\
459  << "| TEST 2-d: Store zeroes and empty container |\n"\
460  << "===============================================================================\n";
461 
462  rank2Container.initialize();
463  double sum = 0.0;
464  for (int i=0; i<rank2Container.size(); i++) {
465  sum += rank2Container[i];
466  }
467  if( (sum != 0.0) ) {
468  errorFlag++;
469  *outStream << " Container size = " << rank2Container.size() << "\n";
470  *outStream << " Container rank = " << rank2Container.rank() << "\n";
471  }
472 
473  rank2Container.clear();
474  if( !(rank2Container.size() == 0 && rank2Container.rank() == 0)) {
475  errorFlag++;
476  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
477  *outStream << " Container size = " << rank2Container.size() << "\n";
478  *outStream << " Container rank = " << rank2Container.rank() << "\n";
479  }
480  } //try
481 
482  catch (std::logic_error err) {
483  *outStream << err.what() << "\n";
484  errorFlag = -1000;
485  };
486 
487 
488 
489  *outStream \
490  << "\n"
491  << "===============================================================================\n"\
492  << "| TEST 3: Rank-3 FieldContainer |\n"\
493  << "===============================================================================\n";
494 
495  // Adjust for rank-3 containers
496  dimension.resize(3);
497  multiIndex.resize(3);
498  dim0 = 17;
499  dim1 = 55;
500  dim2 = 10;
501 
502  // Set dimensions
503  dimension[0] = dim0;
504  dimension[1] = dim1;
505  dimension[2] = dim2;
506 
507  // Define Teuchos::Array with dimension equal to FieldContainer capacity (determined from dimension)
508  dataSize = dimension[0];
509  for(int r = 1; r < (int)dimension.size(); r++){
510  dataSize *= dimension[r];
511  }
512  dataArray.resize(dataSize);
513 
514  // Fill with data
515  counter = 0;
516  for(int i=0; i < dimension[0]; i++){
517  for(int j=0; j < dimension[1]; j++){
518  for(int k=0; k < dimension[2]; k++){
519  dataArray[counter] = (double)counter;
520  counter++;
521  }
522  }
523  }
524 
525  *outStream \
526  << "\n"
527  << "===============================================================================\n"\
528  << "| TEST 3-a: Compare constructors with array and list of dimensions |\n"\
529  << "===============================================================================\n";
530  try{
531 
532  // Using ctor with array of dimensions and array of data
533  FieldContainer<double> rank3Container(dimension, dataArray);
534 
535  // Using ctor with list of dimensions and no data
536  FieldContainer<double> rank3ContainerAlt(dim0, dim1, dim2);
537 
538  // Initialize variables
539  containerSize = rank3Container.size();
540  containerRank = rank3Container.rank();
541  multiIndex.resize(containerRank);
542 
543  if( rank3Container.size() != rank3ContainerAlt.size() ) {
544  errorFlag++;
545  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
546  *outStream << " Size using ctor with array of dimensions = " << rank3Container.size() << "\n";
547  *outStream << " Size using ctor with list of dimensions = " << rank3ContainerAlt.size() << "\n";
548  }
549 
550  if( rank3Container.rank() != rank3ContainerAlt.rank() ) {
551  errorFlag++;
552  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
553  *outStream << " Rank using ctor with array of dimensions = " << rank3Container.rank() << "\n";
554  *outStream << " Rank using ctor with list of dimensions = " << rank3ContainerAlt.rank() << "\n";
555  }
556 
557  for(int dim = 0; dim < rank3Container.rank(); dim ++ ) {
558  if( rank3Container.dimension(dim) != rank3ContainerAlt.dimension(dim) ) {
559  errorFlag++;
560  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
561  *outStream << " Dimension " << dim << " using ctor with array of dimensions = " << rank3Container.dimension(dim) << "\n";
562  *outStream << " Dimension " << dim << " using ctor with list of dimensions = " << rank3ContainerAlt.dimension(dim) << "\n";
563  }
564  }
565 
566  *outStream \
567  << "\n"
568  << "===============================================================================\n"\
569  << "| TEST 3-b: Access by enumeration, multi-index array and multi-index list |\n"\
570  << "===============================================================================\n";
571 
572  // Loop over container by enumeration
573  for(int enumeration = 0; enumeration < containerSize; enumeration++) {
574  int i0,i1,i2;
575 
576  // Convert enumeration to multi-index array and multi-index list and compare values
577  rank3Container.getMultiIndex(multiIndex, enumeration);
578  rank3Container.getMultiIndex(i0, i1, i2, enumeration);
579  if( (multiIndex[0] != i0) ||
580  (multiIndex[1] != i1) ||
581  (multiIndex[2] != i2) ) {
582  errorFlag++;
583  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
584  *outStream << " Multi-index as array = ["
585  << multiIndex[0] << multiIndex[1] << multiIndex[2] << "]\n";
586  *outStream << " Multi-index as list = (" << i0 << "," << i1 << "," << i2 << ")\n";
587  }
588 
589  // Check if access by enumeration gives the same value as access by multi-index array
590  if( rank3Container[enumeration] != rank3Container.getValue(multiIndex) ) {
591  errorFlag++;
592  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
593  *outStream << " Value by enumeration = " << rank3Container[enumeration] << "\n";
594  *outStream << " Value by multi-index array = " << rank3Container.getValue(multiIndex) << "\n";
595  }
596 
597  // Check if access by multi-index list gives the same value as access by multi-index array
598  if( rank3Container(i0,i1,i2) != rank3Container.getValue(multiIndex) ) {
599  errorFlag++;
600  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
601  *outStream << " Value by multi-index list = " << rank3Container(i0,i1,i2) << "\n";
602  *outStream << " Value by multi-index array = " << rank3Container.getValue(multiIndex) << "\n";
603  }
604  }
605 
606  *outStream \
607  << "\n"
608  << "===============================================================================\n"\
609  << "| TEST 3-c: Access by multi-index array and list & compare with data array |\n"\
610  << "===============================================================================\n";
611 
612  // Loop over container by multi-index
613  for(int i=0; i < dimension[0]; i++){
614  multiIndex[0] = i;
615  for(int j=0; j < dimension[1]; j++){
616  multiIndex[1] = j;
617  for(int k=0; k < dimension[2]; k++){
618  multiIndex[2] = k;
619 
620  // Method that takes array of multi-indices
621  int enumeration = rank3Container.getEnumeration(multiIndex);
622 
623  // Compare with method that takes a list of multi-indices
624  if( enumeration != rank3Container.getEnumeration(i,j,k) ) {
625  errorFlag++;
626  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
627  *outStream << " Enumeration from multi-index array = " << enumeration << "\n";
628  *outStream << " Enumeration from multi-index list = " << rank3Container.getEnumeration(i,j,k) << "\n";
629  }
630 
631  // Check if access by multi-index array matches values in original dataArray
632  if(dataArray[enumeration] != rank3Container.getValue(multiIndex)) {
633  errorFlag++;
634  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
635  *outStream << " Value by multi-index array = " << rank3Container.getValue(multiIndex) << "\n";
636  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
637  }
638 
639  // Check if access by multi-index list matches values in original dataArray
640  if(dataArray[enumeration] != rank3Container(i,j,k)) {
641  errorFlag++;
642  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
643  *outStream << " Value by multi-index list = " << rank3Container(i,j,k) << "\n";
644  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
645  }
646 
647  // Check if access by multi-index array matches access by multi-index list
648  if( rank3Container(i,j,k) != rank3Container.getValue(multiIndex)) {
649  errorFlag++;
650  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
651  *outStream << " Value by multi-index array = " << rank3Container.getValue(multiIndex) << "\n";
652  *outStream << " Value by multi-index list = " << rank3Container(i,j,k) << "\n";
653  }
654  }
655  }
656  }
657 
658  *outStream \
659  << "\n"
660  << "===============================================================================\n"\
661  << "| TEST 3-d: Store zeroes and empty container |\n"\
662  << "===============================================================================\n";
663 
664  rank3Container.initialize();
665  double sum = 0.0;
666  for (int i=0; i<rank3Container.size(); i++) {
667  sum += rank3Container[i];
668  }
669  if( (sum != 0.0) ) {
670  errorFlag++;
671  *outStream << " Container size = " << rank3Container.size() << "\n";
672  *outStream << " Container rank = " << rank3Container.rank() << "\n";
673  }
674 
675  rank3Container.clear();
676  if( !(rank3Container.size() == 0 && rank3Container.rank() == 0)) {
677  errorFlag++;
678  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
679  *outStream << " Container size = " << rank3Container.size() << "\n";
680  *outStream << " Container rank = " << rank3Container.rank() << "\n";
681  }
682  } //try
683 
684  catch (std::logic_error err) {
685  *outStream << err.what() << "\n";
686  errorFlag = -1000;
687  };
688 
689 
690 
691  *outStream \
692  << "\n"
693  << "===============================================================================\n"\
694  << "| TEST 4: Rank-4 FieldContainer |\n"\
695  << "===============================================================================\n";
696 
697  // Adjust for rank-4 containers
698  dimension.resize(4);
699  multiIndex.resize(4);
700  dim0 = 27;
701  dim1 = 4;
702  dim2 = 11;
703  dim3 = 6;
704 
705  // Set dimensions
706  dimension[0] = dim0;
707  dimension[1] = dim1;
708  dimension[2] = dim2;
709  dimension[3] = dim3;
710 
711  // Define Teuchos::Array with dimension equal to FieldContainer capacity (determined from dimension)
712  dataSize = dimension[0];
713  for(int r = 1; r < (int)dimension.size(); r++){
714  dataSize *= dimension[r];
715  }
716  dataArray.resize(dataSize);
717 
718  // Fill with data
719  counter = 0;
720  for(int i=0; i < dimension[0]; i++){
721  for(int j=0; j < dimension[1]; j++){
722  for(int k=0; k < dimension[2]; k++){
723  for(int l = 0; l < dimension[3]; l++){
724  dataArray[counter] = (double)counter;
725  counter++;
726  }
727  }
728  }
729  }
730 
731  *outStream \
732  << "\n"
733  << "===============================================================================\n"\
734  << "| TEST 4-a: Compare constructors with array and list of dimensions |\n"\
735  << "===============================================================================\n";
736  try{
737 
738  // Using ctor with array of dimensions and array of data
739  FieldContainer<double> rank4Container(dimension, dataArray);
740 
741  // Using ctor with list of dimensions and no data
742  FieldContainer<double> rank4ContainerAlt(dim0, dim1, dim2, dim3);
743 
744  // Initialize variables
745  containerSize = rank4Container.size();
746  containerRank = rank4Container.rank();
747  multiIndex.resize(containerRank);
748 
749  if( rank4Container.size() != rank4ContainerAlt.size() ) {
750  errorFlag++;
751  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
752  *outStream << " Size using ctor with array of dimensions = " << rank4Container.size() << "\n";
753  *outStream << " Size using ctor with list of dimensions = " << rank4ContainerAlt.size() << "\n";
754  }
755 
756  if( rank4Container.rank() != rank4ContainerAlt.rank() ) {
757  errorFlag++;
758  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
759  *outStream << " Rank using ctor with array of dimensions = " << rank4Container.rank() << "\n";
760  *outStream << " Rank using ctor with list of dimensions = " << rank4ContainerAlt.rank() << "\n";
761  }
762 
763  for(int dim = 0; dim < rank4Container.rank(); dim ++ ) {
764  if( rank4Container.dimension(dim) != rank4ContainerAlt.dimension(dim) ) {
765  errorFlag++;
766  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
767  *outStream << " Dimension " << dim << " using ctor with array of dimensions = " << rank4Container.dimension(dim) << "\n";
768  *outStream << " Dimension " << dim << " using ctor with list of dimensions = " << rank4ContainerAlt.dimension(dim) << "\n";
769  }
770  }
771 
772  *outStream \
773  << "\n"
774  << "===============================================================================\n"\
775  << "| TEST 4-b: Access by enumeration, multi-index array and multi-index list |\n"\
776  << "===============================================================================\n";
777 
778  // Loop over container by enumeration
779  for(int enumeration = 0; enumeration < containerSize; enumeration++) {
780  int i0,i1,i2,i3;
781 
782  // Convert enumeration to multi-index array and multi-index list and compare values
783  rank4Container.getMultiIndex(multiIndex, enumeration);
784  rank4Container.getMultiIndex(i0, i1, i2, i3, enumeration);
785  if( (multiIndex[0] != i0) ||
786  (multiIndex[1] != i1) ||
787  (multiIndex[2] != i2) ||
788  (multiIndex[3] != i3) ) {
789  errorFlag++;
790  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
791  *outStream << " Multi-index as array = ["
792  << multiIndex[0] << multiIndex[1] << multiIndex[2] << multiIndex[3] << "]\n";
793  *outStream << " Multi-index as list = (" << i0 << "," << i1 << "," << i2 << "," << i3 << ")\n";
794  }
795 
796  // Check if access by enumeration gives the same value as access by multi-index array
797  if( rank4Container[enumeration] != rank4Container.getValue(multiIndex) ) {
798  errorFlag++;
799  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
800  *outStream << " Value by enumeration = " << rank4Container[enumeration] << "\n";
801  *outStream << " Value by multi-index array = " << rank4Container.getValue(multiIndex) << "\n";
802  }
803 
804  // Check if access by multi-index list gives the same value as access by multi-index array
805  if( rank4Container(i0,i1,i2,i3) != rank4Container.getValue(multiIndex) ) {
806  errorFlag++;
807  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
808  *outStream << " Value by multi-index list = " << rank4Container(i0,i1,i2,i3) << "\n";
809  *outStream << " Value by multi-index array = " << rank4Container.getValue(multiIndex) << "\n";
810  }
811  }
812 
813  *outStream \
814  << "\n"
815  << "===============================================================================\n"\
816  << "| TEST 4-c: Access by multi-index array and list & compare with data array |\n"\
817  << "===============================================================================\n";
818 
819  // Loop over container by multi-index
820  for(int i=0; i < dimension[0]; i++){
821  multiIndex[0] = i;
822  for(int j=0; j < dimension[1]; j++){
823  multiIndex[1] = j;
824  for(int k=0; k < dimension[2]; k++){
825  multiIndex[2] = k;
826  for(int l = 0; l < dimension[3]; l++){
827  multiIndex[3] = l;
828 
829  // Method that takes array of multi-indices
830  int enumeration = rank4Container.getEnumeration(multiIndex);
831 
832  // Compare with method that takes a list of multi-indices
833  if( enumeration != rank4Container.getEnumeration(i,j,k,l) ) {
834  errorFlag++;
835  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
836  *outStream << " Enumeration from multi-index array = " << enumeration << "\n";
837  *outStream << " Enumeration from multi-index list = " << rank4Container.getEnumeration(i,j,k,l) << "\n";
838  }
839 
840  // Check if access by multi-index array matches values in original dataArray
841  if(dataArray[enumeration] != rank4Container.getValue(multiIndex)) {
842  errorFlag++;
843  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
844  *outStream << " Value by multi-index array = " << rank4Container.getValue(multiIndex) << "\n";
845  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
846  }
847 
848  // Check if access by multi-index list matches values in original dataArray
849  if(dataArray[enumeration] != rank4Container(i,j,k,l)) {
850  errorFlag++;
851  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
852  *outStream << " Value by multi-index list = " << rank4Container(i,j,k,l) << "\n";
853  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
854  }
855 
856  // Check if access by multi-index array matches access by multi-index list
857  if( rank4Container(i,j,k,l) != rank4Container.getValue(multiIndex)) {
858  errorFlag++;
859  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
860  *outStream << " Value by multi-index array = " << rank4Container.getValue(multiIndex) << "\n";
861  *outStream << " Value by multi-index list = " << rank4Container(i,j,k,l) << "\n";
862  }
863  }
864  }
865  }
866  }
867 
868  *outStream \
869  << "\n"
870  << "===============================================================================\n"\
871  << "| TEST 4-d: Store zeroes and empty container |\n"\
872  << "===============================================================================\n";
873 
874  rank4Container.initialize();
875  double sum = 0.0;
876  for (int i=0; i<rank4Container.size(); i++) {
877  sum += rank4Container[i];
878  }
879  if( (sum != 0.0) ) {
880  errorFlag++;
881  *outStream << " Container size = " << rank4Container.size() << "\n";
882  *outStream << " Container rank = " << rank4Container.rank() << "\n";
883  }
884 
885  rank4Container.clear();
886  if( !(rank4Container.size() == 0 && rank4Container.rank() == 0)) {
887  errorFlag++;
888  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
889  *outStream << " Container size = " << rank4Container.size() << "\n";
890  *outStream << " Container rank = " << rank4Container.rank() << "\n";
891  }
892  } //try
893 
894  catch (std::logic_error err) {
895  *outStream << err.what() << "\n";
896  errorFlag = -1000;
897  };
898 
899 
900  *outStream \
901  << "\n"
902  << "===============================================================================\n"\
903  << "| TEST 5: Rank-5 FieldContainer |\n"\
904  << "===============================================================================\n";
905 
906  // Adjust for rank-5 containers
907  dimension.resize(5);
908  multiIndex.resize(5);
909  dim0 = 3;
910  dim1 = 7;
911  dim2 = 11;
912  dim3 = 5;
913  dim4 = 6;
914 
915  // Set dimensions
916  dimension[0] = dim0;
917  dimension[1] = dim1;
918  dimension[2] = dim2;
919  dimension[3] = dim3;
920  dimension[4] = dim4;
921 
922  // Define Teuchos::Array with dimension equal to FieldContainer capacity (determined from dimension)
923  dataSize = dimension[0];
924  for(int r = 1; r < (int)dimension.size(); r++){
925  dataSize *= dimension[r];
926  }
927  dataArray.resize(dataSize);
928 
929  // Fill with data
930  counter = 0;
931  for(int i=0; i < dimension[0]; i++){
932  for(int j=0; j < dimension[1]; j++){
933  for(int k=0; k < dimension[2]; k++){
934  for(int l = 0; l < dimension[3]; l++){
935  for(int m = 0; m < dimension[4]; m++){
936  dataArray[counter] = (double)counter;
937  counter++;
938  }
939  }
940  }
941  }
942  }
943 
944  *outStream \
945  << "\n"
946  << "===============================================================================\n"\
947  << "| TEST 5-a: Compare constructors with array and list of dimensions |\n"\
948  << "===============================================================================\n";
949  try{
950 
951  // Using ctor with array of dimensions and array of data
952  FieldContainer<double> rank5Container(dimension, dataArray);
953 
954  // Using ctor with list of dimensions and no data
955  FieldContainer<double> rank5ContainerAlt(dim0, dim1, dim2, dim3, dim4);
956 
957  // Initialize variables
958  containerSize = rank5Container.size();
959  containerRank = rank5Container.rank();
960  multiIndex.resize(containerRank);
961 
962  if( rank5Container.size() != rank5ContainerAlt.size() ) {
963  errorFlag++;
964  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
965  *outStream << " Size using ctor with array of dimensions = " << rank5Container.size() << "\n";
966  *outStream << " Size using ctor with list of dimensions = " << rank5ContainerAlt.size() << "\n";
967  }
968 
969  if( rank5Container.rank() != rank5ContainerAlt.rank() ) {
970  errorFlag++;
971  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
972  *outStream << " Rank using ctor with array of dimensions = " << rank5Container.rank() << "\n";
973  *outStream << " Rank using ctor with list of dimensions = " << rank5ContainerAlt.rank() << "\n";
974  }
975 
976  for(int dim = 0; dim < rank5Container.rank(); dim ++ ) {
977  if( rank5Container.dimension(dim) != rank5ContainerAlt.dimension(dim) ) {
978  errorFlag++;
979  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
980  *outStream << " Dimension " << dim << " using ctor with array of dimensions = " << rank5Container.dimension(dim) << "\n";
981  *outStream << " Dimension " << dim << " using ctor with list of dimensions = " << rank5ContainerAlt.dimension(dim) << "\n";
982  }
983  }
984 
985  *outStream \
986  << "\n"
987  << "===============================================================================\n"\
988  << "| TEST 5-b: Access by enumeration, multi-index array and multi-index list |\n"\
989  << "===============================================================================\n";
990 
991  // Loop over container by enumeration
992  for(int enumeration = 0; enumeration < containerSize; enumeration++) {
993  int i0,i1,i2,i3,i4;
994 
995  // Convert enumeration to multi-index array and multi-index list and compare values
996  rank5Container.getMultiIndex(multiIndex, enumeration);
997  rank5Container.getMultiIndex(i0, i1, i2, i3, i4, enumeration);
998  if( (multiIndex[0] != i0) ||
999  (multiIndex[1] != i1) ||
1000  (multiIndex[2] != i2) ||
1001  (multiIndex[3] != i3) ||
1002  (multiIndex[4] != i4) ) {
1003  errorFlag++;
1004  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1005  *outStream << " Multi-index as array = ["
1006  << multiIndex[0] << multiIndex[1] << multiIndex[2] << multiIndex[3] << multiIndex[4] << "]\n";
1007  *outStream << " Multi-index as list = (" << i0 << "," << i1 << "," << i2 << "," << i3 << "," << i4 << ")\n";
1008  }
1009 
1010  // Check if access by enumeration gives the same value as access by multi-index array
1011  if( rank5Container[enumeration] != rank5Container.getValue(multiIndex) ) {
1012  errorFlag++;
1013  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1014  *outStream << " Value by enumeration = " << rank5Container[enumeration] << "\n";
1015  *outStream << " Value by multi-index array = " << rank5Container.getValue(multiIndex) << "\n";
1016  }
1017 
1018  // Check if access by multi-index list gives the same value as access by multi-index array
1019  if( rank5Container(i0,i1,i2,i3,i4) != rank5Container.getValue(multiIndex) ) {
1020  errorFlag++;
1021  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1022  *outStream << " Value by multi-index list = " << rank5Container(i0,i1,i2,i3,i4) << "\n";
1023  *outStream << " Value by multi-index array = " << rank5Container.getValue(multiIndex) << "\n";
1024  }
1025  }
1026 
1027  *outStream \
1028  << "\n"
1029  << "===============================================================================\n"\
1030  << "| TEST 5-c: Access by multi-index array and list & compare with data array |\n"\
1031  << "===============================================================================\n";
1032 
1033  // Loop over container by multi-index
1034  for(int i=0; i < dimension[0]; i++){
1035  multiIndex[0] = i;
1036  for(int j=0; j < dimension[1]; j++){
1037  multiIndex[1] = j;
1038  for(int k=0; k < dimension[2]; k++){
1039  multiIndex[2] = k;
1040  for(int l = 0; l < dimension[3]; l++){
1041  multiIndex[3] = l;
1042  for(int m = 0; m < dimension[4]; m++){
1043  multiIndex[4] = m;
1044 
1045  // Method that takes array of multi-indices
1046  int enumeration = rank5Container.getEnumeration(multiIndex);
1047 
1048  // Compare with method that takes a list of multi-indices
1049  if( enumeration != rank5Container.getEnumeration(i,j,k,l,m) ) {
1050  errorFlag++;
1051  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1052  *outStream << " Enumeration from multi-index array = " << enumeration << "\n";
1053  *outStream << " Enumeration from multi-index list = " << rank5Container.getEnumeration(i,j,k,l,m) << "\n";
1054  }
1055 
1056  // Check if access by multi-index array matches values in original dataArray
1057  if(dataArray[enumeration] != rank5Container.getValue(multiIndex)) {
1058  errorFlag++;
1059  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1060  *outStream << " Value by multi-index array = " << rank5Container.getValue(multiIndex) << "\n";
1061  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
1062  }
1063 
1064  // Check if access by multi-index list matches values in original dataArray
1065  if(dataArray[enumeration] != rank5Container(i,j,k,l,m)) {
1066  errorFlag++;
1067  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1068  *outStream << " Value by multi-index list = " << rank5Container(i,j,k,l,m) << "\n";
1069  *outStream << " Value from data array = " << dataArray[enumeration] << "\n";
1070  }
1071 
1072  // Check if access by multi-index array matches access by multi-index list
1073  if( rank5Container(i,j,k,l,m) != rank5Container.getValue(multiIndex)) {
1074  errorFlag++;
1075  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1076  *outStream << " Value by multi-index array = " << rank5Container.getValue(multiIndex) << "\n";
1077  *outStream << " Value by multi-index list = " << rank5Container(i,j,k,l,m) << "\n";
1078  }
1079  }
1080  }
1081  }
1082  }
1083  }
1084 
1085  *outStream \
1086  << "\n"
1087  << "===============================================================================\n"\
1088  << "| TEST 5-d: Store zeroes and empty container |\n"\
1089  << "===============================================================================\n";
1090 
1091  rank5Container.initialize();
1092  double sum = 0.0;
1093  for (int i=0; i<rank5Container.size(); i++) {
1094  sum += rank5Container[i];
1095  }
1096  if( (sum != 0.0) ) {
1097  errorFlag++;
1098  *outStream << " Container size = " << rank5Container.size() << "\n";
1099  *outStream << " Container rank = " << rank5Container.rank() << "\n";
1100  }
1101 
1102  rank5Container.clear();
1103  if( !(rank5Container.size() == 0 && rank5Container.rank() == 0)) {
1104  errorFlag++;
1105  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1106  *outStream << " Container size = " << rank5Container.size() << "\n";
1107  *outStream << " Container rank = " << rank5Container.rank() << "\n";
1108  }
1109  } //try
1110 
1111  catch (std::logic_error err) {
1112  *outStream << err.what() << "\n";
1113  errorFlag = -1000;
1114  };
1115 
1116  *outStream \
1117  << "\n"
1118  << "===============================================================================\n"\
1119  << "| TEST 6: Resize container based on another container |\n"\
1120  << "===============================================================================\n";
1121 
1122  try{
1123  FieldContainer<double> myContainer(1,2,3);
1124  FieldContainer<double> hisContainer(5,4,3,2);
1125 
1126  hisContainer.resize(myContainer);
1127  if ( hisContainer.rank() != myContainer.rank() ) {
1128  errorFlag++;
1129  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1130  *outStream << " Rank of target container = " << hisContainer.rank() << "\n";
1131  *outStream << " Rank of argument container = " << myContainer.rank() << "\n";
1132  }
1133 
1134  for(int dim = 0; dim < myContainer.rank(); dim++){
1135  if ( hisContainer.dimension(dim) != myContainer.dimension(dim) ) {
1136  errorFlag++;
1137  *outStream << std::setw(70) << "^^^^----FAILURE!" << "\n";
1138  *outStream << " Dimension " << dim << " of target container = " << hisContainer.dimension(dim) << "\n";
1139  *outStream << " Dimension " << dim << " of argument container = " << myContainer.dimension(dim) << "\n";
1140  }
1141  }
1142  }// try
1143 
1144  catch (std::logic_error err) {
1145  *outStream << err.what() << "\n";
1146  errorFlag = -1000;
1147  };
1148 
1149 
1150 
1151 
1152 
1153 
1154  if (errorFlag != 0)
1155  std::cout << "End Result: TEST FAILED\n";
1156  else
1157  std::cout << "End Result: TEST PASSED\n";
1158 
1159  // reset format state of std::cout
1160  std::cout.copyfmt(oldFormatState);
1161 
1162  return errorFlag;
1163 }
Header file for utility class to provide multidimensional containers.