/[escript]/trunk/escript/src/Data.cpp
ViewVC logotype

Diff of /trunk/escript/src/Data.cpp

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

revision 1332 by matt, Tue Oct 23 03:28:51 2007 UTC revision 1358 by gross, Wed Dec 5 03:41:06 2007 UTC
# Line 427  Data::tag() Line 427  Data::tag()
427  Data  Data
428  Data::oneOver() const  Data::oneOver() const
429  {  {
430    return escript::unaryOp(*this,bind1st(divides<double>(),1.));    return C_TensorUnaryOperation(*this, bind1st(divides<double>(),1.));
431  }  }
432    
433  Data  Data
434  Data::wherePositive() const  Data::wherePositive() const
435  {  {
436    return escript::unaryOp(*this,bind2nd(greater<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(greater<double>(),0.0));
437  }  }
438    
439  Data  Data
440  Data::whereNegative() const  Data::whereNegative() const
441  {  {
442    return escript::unaryOp(*this,bind2nd(less<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(less<double>(),0.0));
443  }  }
444    
445  Data  Data
446  Data::whereNonNegative() const  Data::whereNonNegative() const
447  {  {
448    return escript::unaryOp(*this,bind2nd(greater_equal<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(greater_equal<double>(),0.0));
449  }  }
450    
451  Data  Data
452  Data::whereNonPositive() const  Data::whereNonPositive() const
453  {  {
454    return escript::unaryOp(*this,bind2nd(less_equal<double>(),0.0));    return C_TensorUnaryOperation(*this, bind2nd(less_equal<double>(),0.0));
455  }  }
456    
457  Data  Data
458  Data::whereZero(double tol) const  Data::whereZero(double tol) const
459  {  {
460    Data dataAbs=abs();    Data dataAbs=abs();
461    return escript::unaryOp(dataAbs,bind2nd(less_equal<double>(),tol));    return C_TensorUnaryOperation(dataAbs, bind2nd(less_equal<double>(),tol));
462  }  }
463    
464  Data  Data
465  Data::whereNonZero(double tol) const  Data::whereNonZero(double tol) const
466  {  {
467    Data dataAbs=abs();    Data dataAbs=abs();
468    return escript::unaryOp(dataAbs,bind2nd(greater<double>(),tol));    return C_TensorUnaryOperation(dataAbs, bind2nd(greater<double>(),tol));
469  }  }
470    
471  Data  Data
# Line 904  Data::integrate() const Line 904  Data::integrate() const
904  Data  Data
905  Data::sin() const  Data::sin() const
906  {  {
907    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sin);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::sin);
908  }  }
909    
910  Data  Data
911  Data::cos() const  Data::cos() const
912  {  {
913    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cos);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::cos);
914  }  }
915    
916  Data  Data
917  Data::tan() const  Data::tan() const
918  {  {
919    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tan);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::tan);
920  }  }
921    
922  Data  Data
923  Data::asin() const  Data::asin() const
924  {  {
925    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asin);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::asin);
926  }  }
927    
928  Data  Data
929  Data::acos() const  Data::acos() const
930  {  {
931    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acos);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::acos);
932  }  }
933    
934    
935  Data  Data
936  Data::atan() const  Data::atan() const
937  {  {
938    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atan);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::atan);
939  }  }
940    
941  Data  Data
942  Data::sinh() const  Data::sinh() const
943  {  {
944    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sinh);      return C_TensorUnaryOperation<double (*)(double)>(*this, ::sinh);
945    
946  }  }
947    
948  Data  Data
949  Data::cosh() const  Data::cosh() const
950  {  {
951    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::cosh);      return C_TensorUnaryOperation<double (*)(double)>(*this, ::cosh);
952  }  }
953    
954  Data  Data
955  Data::tanh() const  Data::tanh() const
956  {  {
957    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::tanh);      return C_TensorUnaryOperation<double (*)(double)>(*this, ::tanh);
958  }  }
959    
960    
# Line 963  Data::erf() const Line 964  Data::erf() const
964  #ifdef _WIN32  #ifdef _WIN32
965    throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");    throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");
966  #else  #else
967    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::erf);    return C_TensorUnaryOperation(*this, ::erf);
968  #endif  #endif
969  }  }
970    
# Line 971  Data Line 972  Data
972  Data::asinh() const  Data::asinh() const
973  {  {
974  #ifdef _WIN32  #ifdef _WIN32
975    return escript::unaryOp(*this,escript::asinh_substitute);    return C_TensorUnaryOperation(*this, escript::asinh_substitute);
976  #else  #else
977    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::asinh);    return C_TensorUnaryOperation(*this, ::asinh);
978  #endif  #endif
979  }  }
980    
# Line 981  Data Line 982  Data
982  Data::acosh() const  Data::acosh() const
983  {  {
984  #ifdef _WIN32  #ifdef _WIN32
985    return escript::unaryOp(*this,escript::acosh_substitute);    return C_TensorUnaryOperation(*this, escript::acosh_substitute);
986  #else  #else
987    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::acosh);    return C_TensorUnaryOperation(*this, ::acosh);
988  #endif  #endif
989  }  }
990    
# Line 991  Data Line 992  Data
992  Data::atanh() const  Data::atanh() const
993  {  {
994  #ifdef _WIN32  #ifdef _WIN32
995    return escript::unaryOp(*this,escript::atanh_substitute);    return C_TensorUnaryOperation(*this, escript::atanh_substitute);
996  #else  #else
997    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::atanh);    return C_TensorUnaryOperation(*this, ::atanh);
998  #endif  #endif
999  }  }
1000    
1001  Data  Data
1002  Data::log10() const  Data::log10() const
1003  {  {
1004    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log10);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::log10);
1005  }  }
1006    
1007  Data  Data
1008  Data::log() const  Data::log() const
1009  {  {
1010    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::log);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::log);
1011  }  }
1012    
1013  Data  Data
1014  Data::sign() const  Data::sign() const
1015  {  {
1016    return escript::unaryOp(*this,escript::fsign);    return C_TensorUnaryOperation(*this, escript::fsign);
1017  }  }
1018    
1019  Data  Data
1020  Data::abs() const  Data::abs() const
1021  {  {
1022    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::fabs);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::fabs);
1023  }  }
1024    
1025  Data  Data
1026  Data::neg() const  Data::neg() const
1027  {  {
1028    return escript::unaryOp(*this,negate<double>());    return C_TensorUnaryOperation(*this, negate<double>());
1029  }  }
1030    
1031  Data  Data
# Line 1039  Data::pos() const Line 1040  Data::pos() const
1040  Data  Data
1041  Data::exp() const  Data::exp() const
1042  {  {
1043    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::exp);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::exp);
1044  }  }
1045    
1046  Data  Data
1047  Data::sqrt() const  Data::sqrt() const
1048  {  {
1049    return escript::unaryOp(*this,(Data::UnaryDFunPtr)::sqrt);    return C_TensorUnaryOperation<double (*)(double)>(*this, ::sqrt);
1050  }  }
1051    
1052  double  double
# Line 1510  Data::powO(const boost::python::object& Line 1511  Data::powO(const boost::python::object&
1511    return powD(tmp);    return powD(tmp);
1512  }  }
1513    
 /* Data */  
 /* Data::powD(const Data& right) const */  
 /* { */  
 /*   Data result; */  
 /*   if (getDataPointRank()<right.getDataPointRank()) { */  
 /*      result.copy(right); */  
 /*      result.binaryOp(*this,escript::rpow); */  
 /*   } else { */  
 /*      result.copy(*this); */  
 /*      result.binaryOp(right,(Data::BinaryDFunPtr)::pow); */  
 /*   } */  
 /*   return result; */  
 /* } */  
   
1514  Data  Data
1515  Data::powD(const Data& right) const  Data::powD(const Data& right) const
1516  {  {
1517    return C_TensorBinaryOperation(*this, right, ::pow);    return C_TensorBinaryOperation<double (*)(double, double)>(*this, right, ::pow);
1518  }  }
1519    
1520  //  //
# Line 1781  Data::setTaggedValue(int tagKey, Line 1768  Data::setTaggedValue(int tagKey,
1768    }    }
1769    //    //
1770    // Ensure underlying data object is of type DataTagged    // Ensure underlying data object is of type DataTagged
1771    tag();    if (isConstant()) tag();
   
   if (!isTagged()) {  
     throw DataException("Error - DataTagged conversion failed!!");  
   }  
1772    
1773    numeric::array asNumArray(value);    numeric::array asNumArray(value);
1774    
# Line 1816  Data::setTaggedValueFromCPP(int tagKey, Line 1799  Data::setTaggedValueFromCPP(int tagKey,
1799    }    }
1800    //    //
1801    // Ensure underlying data object is of type DataTagged    // Ensure underlying data object is of type DataTagged
1802    tag();    if (isConstant()) tag();
   
   if (!isTagged()) {  
     throw DataException("Error - DataTagged conversion failed!!");  
   }  
1803    
1804    //    //
1805    // Call DataAbstract::setTaggedValue    // Call DataAbstract::setTaggedValue
# Line 1830  Data::setTaggedValueFromCPP(int tagKey, Line 1809  Data::setTaggedValueFromCPP(int tagKey,
1809  int  int
1810  Data::getTagNumber(int dpno)  Data::getTagNumber(int dpno)
1811  {  {
1812    return m_data->getTagNumber(dpno);    return getFunctionSpace().getTagFromSampleNo(dpno);
1813  }  }
1814    
1815  void  void

Legend:
Removed from v.1332  
changed lines
  Added in v.1358

  ViewVC Help
Powered by ViewVC 1.1.26