/[escript]/branches/arrayview_from_1695_trunk/escript/test/DataArrayViewTestCase.cpp
ViewVC logotype

Diff of /branches/arrayview_from_1695_trunk/escript/test/DataArrayViewTestCase.cpp

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

trunk/esys2/escript/test/DataArrayView/DataArrayViewTestCase.cpp revision 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/test/DataArrayView/DataArrayViewTestCase.cpp revision 468 by jgs, Wed Jan 25 06:50:39 2006 UTC
# Line 14  Line 14 
14  #include "escript/Data/DataArray.h"  #include "escript/Data/DataArray.h"
15  #include "escript/Data/DataArrayView.h"  #include "escript/Data/DataArrayView.h"
16  #include "escript/Data/DataAlgorithm.h"  #include "escript/Data/DataAlgorithm.h"
17  #include "esysUtils/EsysException.h"  #include "EsysException.h"
18    
19  #include "DataArrayViewTestCase.h"  #include "DataArrayViewTestCase.h"
20    
# Line 1735  void DataArrayViewTestCase::testUnaryOp( Line 1735  void DataArrayViewTestCase::testUnaryOp(
1735      // constructor      // constructor
1736      DataArrayView dataView(data,shape);      DataArrayView dataView(data,shape);
1737    
1738        double tmp;
1739      // step the view along each data point in the underlying data      // step the view along each data point in the underlying data
1740      for (int p=0;p<npoints;p++) {      for (int p=0;p<npoints;p++) {
1741    
# Line 1745  void DataArrayViewTestCase::testUnaryOp( Line 1746  void DataArrayViewTestCase::testUnaryOp(
1746        dataView.unaryOp((UnaryDFunPtr)std::sin);        dataView.unaryOp((UnaryDFunPtr)std::sin);
1747    
1748        // check the results        // check the results
1749        assert(dataView()==std::sin((double)p));        tmp = std::sin((double)p);
1750          assert(dataView()==tmp);
1751    
1752        if (p<npoints-1) {        if (p<npoints-1) {
1753          dataView.incrOffset();          dataView.incrOffset();
# Line 2071  void DataArrayViewTestCase::testBinaryOp Line 2073  void DataArrayViewTestCase::testBinaryOp
2073        // apply a binary operation to the data point        // apply a binary operation to the data point
2074        dataView.binaryOp(5.8,multiplies<double>());        dataView.binaryOp(5.8,multiplies<double>());
2075    
2076          double tmp;
2077        // check the results        // check the results
2078        for (int i=0;i<shape[0];i++) {        for (int i=0;i<shape[0];i++) {
2079          for (int j=0;j<shape[1];j++) {          for (int j=0;j<shape[1];j++) {
2080            assert(dataView(i,j)==5.8*dataView.index(i,j));            tmp=5.8*dataView.index(i,j);
2081              assert(dataView(i,j)==tmp);
2082          }          }
2083        }        }
2084    
# Line 2121  void DataArrayViewTestCase::testBinaryOp Line 2125  void DataArrayViewTestCase::testBinaryOp
2125        // apply a binary operation to the data point        // apply a binary operation to the data point
2126        dataView.binaryOp(5.4,multiplies<double>());        dataView.binaryOp(5.4,multiplies<double>());
2127    
2128          double tmp;
2129        // check the results        // check the results
2130        for (int i=0;i<shape[0];i++) {        for (int i=0;i<shape[0];i++) {
2131          for (int j=0;j<shape[1];j++) {          for (int j=0;j<shape[1];j++) {
2132            for (int k=0;k<shape[2];k++) {            for (int k=0;k<shape[2];k++) {
2133              for (int l=0;l<shape[3];l++) {              for (int l=0;l<shape[3];l++) {
2134                assert(dataView(i,j,k,l)==5.4*dataView.index(i,j,k,l));                tmp=5.4*dataView.index(i,j,k,l);
2135                  assert(dataView(i,j,k,l)==tmp);
2136              }              }
2137            }            }
2138          }          }
# Line 2168  void DataArrayViewTestCase::testReductio Line 2174  void DataArrayViewTestCase::testReductio
2174        dataView()=p;        dataView()=p;
2175    
2176        // apply a reduction operation to this data point and check the results        // apply a reduction operation to this data point and check the results
2177        assert(dataView.reductionOp(DataAlgorithmAdapter<FMax>(numeric_limits<double>::max()*-1))==p);        FMax fmax_func;
2178          assert(dataView.reductionOp(fmax_func,numeric_limits<double>::max()*-1)==p);
2179    
2180        if (p<npoints-1) {        if (p<npoints-1) {
2181          dataView.incrOffset();          dataView.incrOffset();
# Line 2205  void DataArrayViewTestCase::testReductio Line 2212  void DataArrayViewTestCase::testReductio
2212        }        }
2213    
2214        // apply a reduction operation to this data point and check the results        // apply a reduction operation to this data point and check the results
2215        assert(dataView.reductionOp(DataAlgorithmAdapter<FMin>(numeric_limits<double>::max()))==dataView.index(0,0));        FMin fmin_func;
2216          assert(dataView.reductionOp(fmin_func,numeric_limits<double>::max())==dataView.index(0,0));
2217    
2218        if (p<npoints-1) {        if (p<npoints-1) {
2219          dataView.incrOffset();          dataView.incrOffset();
# Line 2248  void DataArrayViewTestCase::testReductio Line 2256  void DataArrayViewTestCase::testReductio
2256        }        }
2257    
2258        // apply a reduction operation to this data point and check the results        // apply a reduction operation to this data point and check the results
2259        assert(dataView.reductionOp(DataAlgorithmAdapter<AbsMax>(0))==dataView.index(8,7,4,10));        AbsMax absmax_func;
2260          assert(dataView.reductionOp(absmax_func,0)==dataView.index(8,7,4,10));
2261    
2262        if (p<npoints-1) {        if (p<npoints-1) {
2263          dataView.incrOffset();          dataView.incrOffset();

Legend:
Removed from v.121  
changed lines
  Added in v.468

  ViewVC Help
Powered by ViewVC 1.1.26