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

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

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

revision 1026 by phornby, Tue Mar 13 08:25:00 2007 UTC revision 1455 by phornby, Thu Feb 28 17:19:44 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /* $Id$ */
3   *****************************************************************************  
4   *                                                                           *  /*******************************************************
5   *       COPYRIGHT  ACcESS  -  All Rights Reserved                           *   *
6   *                                                                           *   *           Copyright 2003-2007 by ACceSS MNRF
7   * This software is the property of ACcESS. No part of this code             *   *       Copyright 2007 by University of Queensland
8   * may be copied in any form or by any means without the expressed written   *   *
9   * consent of ACcESS.  Copying, use or modification of this software         *   *                http://esscc.uq.edu.au
10   * by any unauthorised person is illegal unless that person has a software   *   *        Primary Business: Queensland, Australia
11   * license agreement with ACcESS.                                            *   *  Licensed under the Open Software License version 3.0
12   *                                                                           *   *     http://www.opensource.org/licenses/osl-3.0.php
13   *****************************************************************************   *
14  */   *******************************************************/
15    
16  #include <iostream>  #include <iostream>
17  #if (defined _WIN32) && (defined __INTEL_COMPILER)  #if (defined _WIN32) && (defined __INTEL_COMPILER)
18  #include <mathimf.h>  #include <mathimf.h>
# Line 545  void DataTestCase::testDataTagged() { Line 546  void DataTestCase::testDataTagged() {
546      DataArrayView defaultValue(viewData,viewShape);      DataArrayView defaultValue(viewData,viewShape);
547    
548      bool expanded=false;      bool expanded=false;
549      
550      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);
551    
552      // cout << myData.toString() << endl;      // cout << myData.toString() << endl;
# Line 590  void DataTestCase::testDataTagged() { Line 591  void DataTestCase::testDataTagged() {
591      cout << "\tTest setting of a tag and associated value." << endl;      cout << "\tTest setting of a tag and associated value." << endl;
592    
593      // value for tag "1"      // value for tag "1"
594      DataArray eTwo(defaultValue);      DataArrayView::ValueType eTwoData(viewData);
595      for (int i=0;i<eTwo.getView().getShape()[0];i++) {      DataArrayView eTwoView(eTwoData, viewShape);
596        eTwo.getView()(i)=i+2.0;      for (int i=0;i<eTwoView.getShape()[0];i++) {
597          eTwoView(i)=i+2.0;
598      }      }
599    
600      myData.setTaggedValueFromCPP(1,eTwo.getView());      myData.setTaggedValueFromCPP(1,eTwoView);
601    
602      assert(myData.getLength()==6);      assert(myData.getLength()==6);
603    
604      myDataView = myData.getDataPoint(0,0);      myDataView = myData.getDataPoint(0,0);
605      assert(myDataView==eTwo.getView());      assert(myDataView==eTwoView);
606      assert(!myDataView.isEmpty());      assert(!myDataView.isEmpty());
607      assert(myDataView.getOffset()==3);      assert(myDataView.getOffset()==3);
608      assert(myDataView.getRank()==1);      assert(myDataView.getRank()==1);
# Line 680  void DataTestCase::testDataTaggedExcepti Line 682  void DataTestCase::testDataTaggedExcepti
682        myData.getSampleDataByTag(0);;        myData.getSampleDataByTag(0);;
683        assert(false);        assert(false);
684    }    }
685    catch (EsysException& e) {    catch (EsysException&) {
686        //cout << e.what() << endl;        //cout << e.what() << endl;
687        assert(true);        assert(true);
688    }    }
# Line 689  void DataTestCase::testDataTaggedExcepti Line 691  void DataTestCase::testDataTaggedExcepti
691        myData.setTaggedValueFromCPP(0,myView);;        myData.setTaggedValueFromCPP(0,myView);;
692        assert(false);        assert(false);
693    }    }
694    catch (EsysException& e) {    catch (EsysException&) {
695        //cout << e.what() << endl;        //cout << e.what() << endl;
696        assert(true);        assert(true);
697    }    }
# Line 758  void DataTestCase::testOperations() { Line 760  void DataTestCase::testOperations() {
760    resultTag.copy(baseTag.powD(power));    resultTag.copy(baseTag.powD(power));
761    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
762      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
763        tmp=pow(dataView.index(i,j),3.0);        tmp=pow((double)dataView.index(i,j),(double)3.0);
764        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));
765        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));
766        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));

Legend:
Removed from v.1026  
changed lines
  Added in v.1455

  ViewVC Help
Powered by ViewVC 1.1.26