/[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 549 by jgs, Wed Feb 22 00:45:48 2006 UTC revision 563 by jgs, Thu Feb 23 05:09:47 2006 UTC
# Line 731  void DataTestCase::testOperations() { Line 731  void DataTestCase::testOperations() {
731      }      }
732    }    }
733    
734    Data base(dataView);    Data baseEx(dataView,FunctionSpace(),true);
735      Data baseCon(dataView,FunctionSpace(),false);
736      Data baseTag(dataView,FunctionSpace(),false);
737      baseTag.tag();
738    
739      assert(baseEx.isExpanded());
740      assert(baseCon.isConstant());
741      assert(baseTag.isTagged());
742    
743      Data resultEx;
744      Data resultCon;
745      Data resultTag;
746    
747    // test unary operations    // test unary operations
748    
749    cout << "\tTest Data::pow." << endl;    cout << "\tTest Data::pow." << endl;
750    Data power(3.0,shape,FunctionSpace(),true);    Data power(3.0,shape,FunctionSpace(),true);
751    Data result(base.powD(power));    resultEx.copy(baseEx.powD(power));
752      resultCon.copy(baseCon.powD(power));
753      resultTag.copy(baseTag.powD(power));
754    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
755      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
756        assert(result.getPointDataView()(i,j) == pow(dataView.index(i,j),3.0));        assert(resultEx.getPointDataView()(i,j) == pow(dataView.index(i,j),3.0));
757          assert(resultCon.getPointDataView()(i,j) == pow(dataView.index(i,j),3.0));
758          assert(resultTag.getPointDataView()(i,j) == pow(dataView.index(i,j),3.0));
759      }      }
760    }    }
761    
762    cout << "\tTest Data::sin." << endl;    cout << "\tTest Data::sin." << endl;
763    result.copy(base.sin());    resultEx.copy(baseEx.sin());
764      resultCon.copy(baseCon.sin());
765      resultTag.copy(baseTag.sin());
766    assert(true);    assert(true);
767    
768    cout << "\tTest Data::cos." << endl;    cout << "\tTest Data::cos." << endl;
769    result.copy(base.cos());    resultEx.copy(baseEx.cos());
770      resultCon.copy(baseCon.cos());
771      resultTag.copy(baseTag.cos());
772    assert(true);    assert(true);
773    
774    cout << "\tTest Data::tan." << endl;    cout << "\tTest Data::tan." << endl;
775    result.copy(base.tan());    resultEx.copy(baseEx.tan());
776      resultCon.copy(baseCon.tan());
777      resultTag.copy(baseTag.tan());
778    assert(true);    assert(true);
779    
780    cout << "\tTest Data::asin." << endl;    cout << "\tTest Data::asin." << endl;
781    result.copy(base.asin());    resultEx.copy(baseEx.asin());
782      resultCon.copy(baseCon.asin());
783      resultTag.copy(baseTag.asin());
784    assert(true);    assert(true);
785    
786    cout << "\tTest Data::acos." << endl;    cout << "\tTest Data::acos." << endl;
787    result.copy(base.acos());    resultEx.copy(baseEx.acos());
788      resultCon.copy(baseCon.acos());
789      resultTag.copy(baseTag.acos());
790    assert(true);    assert(true);
791    
792    cout << "\tTest Data::atan." << endl;    cout << "\tTest Data::atan." << endl;
793    result.copy(base.atan());    resultEx.copy(baseEx.atan());
794      resultCon.copy(baseCon.atan());
795      resultTag.copy(baseTag.atan());
796    assert(true);    assert(true);
797    
798    cout << "\tTest Data::sinh." << endl;    cout << "\tTest Data::sinh." << endl;
799    result.copy(base.sinh());    resultEx.copy(baseEx.sinh());
800      resultCon.copy(baseCon.sinh());
801      resultTag.copy(baseTag.sinh());
802    assert(true);    assert(true);
803    
804    cout << "\tTest Data::cosh." << endl;    cout << "\tTest Data::cosh." << endl;
805    result.copy(base.cosh());    resultEx.copy(baseEx.cosh());
806      resultCon.copy(baseCon.cosh());
807      resultTag.copy(baseTag.cosh());
808    assert(true);    assert(true);
809    
810    cout << "\tTest Data::tanh." << endl;    cout << "\tTest Data::tanh." << endl;
811    result.copy(base.tanh());    resultEx.copy(baseEx.tanh());
812      resultCon.copy(baseCon.tanh());
813      resultTag.copy(baseTag.tanh());
814    assert(true);    assert(true);
815    
816    cout << "\tTest Data::asinh." << endl;    cout << "\tTest Data::asinh." << endl;
817    result.copy(base.asinh());    resultEx.copy(baseEx.asinh());
818      resultCon.copy(baseCon.asinh());
819      resultTag.copy(baseTag.asinh());
820    assert(true);    assert(true);
821    
822    cout << "\tTest Data::acosh." << endl;    cout << "\tTest Data::acosh." << endl;
823    result.copy(base.acosh());    resultEx.copy(baseEx.acosh());
824      resultCon.copy(baseCon.acosh());
825      resultTag.copy(baseTag.acosh());
826    assert(true);    assert(true);
827    
828    cout << "\tTest Data::atanh." << endl;    cout << "\tTest Data::atanh." << endl;
829    result.copy(base.atanh());    resultEx.copy(baseEx.atanh());
830      resultCon.copy(baseCon.atanh());
831      resultTag.copy(baseTag.atanh());
832    assert(true);    assert(true);
833    
834    cout << "\tTest Data::log." << endl;    cout << "\tTest Data::log." << endl;
835    result.copy(base.log());    resultEx.copy(baseEx.log());
836      resultCon.copy(baseCon.log());
837      resultTag.copy(baseTag.log());
838    assert(true);    assert(true);
839    
   //cout << "\tTest Data::ln." << endl;  
   //result.copy(base.ln());  
   //assert(true);  
   
840    cout << "\tTest Data::abs." << endl;    cout << "\tTest Data::abs." << endl;
841    result.copy(base.abs());    resultEx.copy(baseEx.abs());
842      resultCon.copy(baseCon.abs());
843      resultTag.copy(baseTag.abs());
844    assert(true);    assert(true);
845    
846    cout << "\tTest Data::sign." << endl;    cout << "\tTest Data::sign." << endl;
847    result.copy(base.sign());    resultEx.copy(baseEx.sign());
848      resultCon.copy(baseCon.sign());
849      resultTag.copy(baseTag.sign());
850    assert(true);    assert(true);
851    
852    cout << "\tTest Data::exp." << endl;    cout << "\tTest Data::exp." << endl;
853    result.copy(base.exp());    resultEx.copy(baseEx.exp());
854      resultCon.copy(baseCon.exp());
855      resultTag.copy(baseTag.exp());
856    assert(true);    assert(true);
857    
858    cout << "\tTest Data::sqrt." << endl;    cout << "\tTest Data::sqrt." << endl;
859    result.copy(base.sqrt());    resultEx.copy(baseEx.sqrt());
860      resultCon.copy(baseCon.sqrt());
861      resultTag.copy(baseTag.sqrt());
862    assert(true);    assert(true);
863    
864    cout << "\tTest Data::neg." << endl;    cout << "\tTest Data::neg." << endl;
865    result.copy(base.neg());    resultEx.copy(baseEx.neg());
866      resultCon.copy(baseCon.neg());
867      resultTag.copy(baseTag.neg());
868    assert(true);    assert(true);
869    
870    cout << "\tTest Data::pos." << endl;    cout << "\tTest Data::pos." << endl;
871    result.copy(base.pos());    resultEx.copy(baseEx.pos());
872      resultCon.copy(baseCon.pos());
873      resultTag.copy(baseTag.pos());
874    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
875      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
876        assert(result.getPointDataView()(i,j) == dataView.index(i,j));        assert(resultEx.getPointDataView()(i,j) == dataView.index(i,j));
877          assert(resultCon.getPointDataView()(i,j) == dataView.index(i,j));
878          assert(resultTag.getPointDataView()(i,j) == dataView.index(i,j));
879      }      }
880    }    }
881    
882    // test reduction operations    // test reduction operations
883    
884    cout << "\tTest Data::Lsup." << endl;    cout << "\tTest Data::Lsup." << endl;
885    assert(base.Lsup() == 5);    assert(baseEx.Lsup() == 5);
886      assert(baseCon.Lsup() == 5);
887      assert(baseTag.Lsup() == 5);
888    
889    cout << "\tTest Data::sup." << endl;    cout << "\tTest Data::sup." << endl;
890    assert(base.sup() == 5);    assert(baseEx.sup() == 5);
891      assert(baseCon.sup() == 5);
892      assert(baseTag.sup() == 5);
893    
894    cout << "\tTest Data::inf." << endl;    cout << "\tTest Data::inf." << endl;
895    assert(base.inf() == 0);    assert(baseEx.inf() == 0);
896      assert(baseCon.inf() == 0);
897      assert(baseTag.inf() == 0);
898    
899    // test data-point reduction operations    // test data-point reduction operations
900    
901    cout << "\tTest Data::minval." << endl;    cout << "\tTest Data::minval." << endl;
902    result.copy(base.minval());    resultEx.copy(baseEx.minval());
903    assert(result.getPointDataView()() == 0);    resultCon.copy(baseCon.minval());
904      resultTag.copy(baseTag.minval());
905      assert(resultEx.getPointDataView()() == 0);
906      assert(resultCon.getPointDataView()() == 0);
907      assert(resultTag.getPointDataView()() == 0);
908    
909    cout << "\tTest Data::maxval." << endl;    cout << "\tTest Data::maxval." << endl;
910    result.copy(base.maxval());    resultEx.copy(baseEx.maxval());
911    assert(result.getPointDataView()() == 5);    resultCon.copy(baseCon.maxval());
912      resultTag.copy(baseTag.maxval());
913    //cout << "\tTest Data::length." << endl;    assert(resultEx.getPointDataView()() == 5);
914    //result.copy(base.length());    assert(resultCon.getPointDataView()() == 5);
915    //assert(pow(result.getPointDataView()(),2.0) == 55);    assert(resultTag.getPointDataView()() == 5);
916    
917    cout << "\tTest Data::trace." << endl;    cout << "\tTest Data::trace." << endl;
918    result.copy(base.trace());    resultEx.copy(baseEx.trace());
919    assert(result.getPointDataView()() == 15);    resultCon.copy(baseCon.trace());
920      resultTag.copy(baseTag.trace());
921    //result.copy(base.transpose(0));    assert(resultEx.getPointDataView()() == 15);
922    //assert(true);    assert(resultCon.getPointDataView()() == 15);
923      assert(resultTag.getPointDataView()() == 15);
924    
925  }  }
926    

Legend:
Removed from v.549  
changed lines
  Added in v.563

  ViewVC Help
Powered by ViewVC 1.1.26