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

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

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

trunk/esys2/escript/src/Data/Data.h revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/escript/src/Data.h revision 474 by jgs, Mon Jan 30 04:23:44 2006 UTC
# Line 18  Line 18 
18  #ifndef DATA_H  #ifndef DATA_H
19  #define DATA_H  #define DATA_H
20    
21  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
22  #include "escript/Data/DataTagged.h"  #include "DataTagged.h"
23  #include "escript/Data/DataAlgorithm.h"  #include "DataAlgorithm.h"
24  #include "escript/Data/FunctionSpace.h"  #include "FunctionSpace.h"
25  #include "escript/Data/BinaryOp.h"  #include "BinaryOp.h"
26  #include "escript/Data/UnaryOp.h"  #include "UnaryOp.h"
27  #include "escript/Data/DataException.h"  #include "DataException.h"
28    
29  extern "C" {  extern "C" {
30  #include "escript/Data/DataC.h"  #include "DataC.h"
31  }  }
32    
33  #include <iostream>  #include <iostream>
# Line 44  extern "C" { Line 44  extern "C" {
44  namespace escript {  namespace escript {
45    
46  //  //
47  // Forward declaration for various implimentations of Data.  // Forward declaration for various implementations of Data.
48  class DataEmpty;  class DataEmpty;
49  class DataConstant;  class DataConstant;
50  class DataTagged;  class DataTagged;
# Line 206  class Data { Line 206  class Data {
206         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
207         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
208         bool expanded=false);         bool expanded=false);
209      /**
210         \brief
211         Destructor
212      */
213      ~Data();
214    
215    /**    /**
216       \brief       \brief
# Line 242  class Data { Line 247  class Data {
247    
248    /**    /**
249       \brief       \brief
250         Fills the expanded Data object from values of a python numarray object.
251      */
252      void
253      fillFromNumArray(const boost::python::numeric::array);
254    
255      /**
256         \brief
257         Return the tag number associated with the given data-point.
258    
259         The data-point number here corresponds to the data-point number in the
260         numarray returned by convertToNumArray.
261      */
262      int
263      getTagNumber(int dpno);
264    
265      /**
266         \brief
267       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
268    */    */
269    escriptDataC    escriptDataC
# Line 678  class Data { Line 700  class Data {
700    const boost::python::tuple    const boost::python::tuple
701    mindp() const;    mindp() const;
702    
703    /**    void
704       \brief    calc_mindp(int& SampleNo,
705       Return the length of each data point of this Data object.               int& DataPointNo) const;
      sqrt(sum(A[i,j,k,l]^2))  
      *  
   */  
   Data  
   length() const;  
706    
707    /**    /**
708       \brief       \brief
# Line 740  class Data { Line 757  class Data {
757    
758    /**    /**
759       \brief       \brief
760         Return the asin of each data point of this Data object.
761         *
762      */
763      Data
764      asin() const;
765    
766      /**
767         \brief
768         Return the acos of each data point of this Data object.
769         *
770      */
771      Data
772      acos() const;
773    
774      /**
775         \brief
776         Return the atan of each data point of this Data object.
777         *
778      */
779      Data
780      atan() const;
781    
782      /**
783         \brief
784         Return the sinh of each data point of this Data object.
785         *
786      */
787      Data
788      sinh() const;
789    
790      /**
791         \brief
792         Return the cosh of each data point of this Data object.
793         *
794      */
795      Data
796      cosh() const;
797    
798      /**
799         \brief
800         Return the tanh of each data point of this Data object.
801         *
802      */
803      Data
804      tanh() const;
805    
806      /**
807         \brief
808         Return the asinh of each data point of this Data object.
809         *
810      */
811      Data
812      asinh() const;
813    
814      /**
815         \brief
816         Return the acosh of each data point of this Data object.
817         *
818      */
819      Data
820      acosh() const;
821    
822      /**
823         \brief
824         Return the atanh of each data point of this Data object.
825         *
826      */
827      Data
828      atanh() const;
829    
830      /**
831         \brief
832       Return the log to base 10 of each data point of this Data object.       Return the log to base 10 of each data point of this Data object.
833       *       *
834    */    */
835    Data    Data
836    log() const;    log10() const;
837    
838    /**    /**
839       \brief       \brief
# Line 752  class Data { Line 841  class Data {
841       *       *
842    */    */
843    Data    Data
844    ln() const;    log() const;
845    
846    /**    /**
847       \brief       \brief
# Line 977  class Data { Line 1066  class Data {
1066       Perform the specified reduction algorithm on every element of every data point in       Perform the specified reduction algorithm on every element of every data point in
1067       this Data object according to the given function and return the single value result.       this Data object according to the given function and return the single value result.
1068    */    */
1069    template <class UnaryFunction>    template <class BinaryFunction>
1070    inline    inline
1071    double    double
1072    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1073                double initial_value) const;
1074    
1075    /**    /**
1076       \brief       \brief
# Line 989  class Data { Line 1079  class Data {
1079       one value - the result of the reduction operation on the corresponding data-point in       one value - the result of the reduction operation on the corresponding data-point in
1080       this Data object       this Data object
1081    */    */
1082    template <class UnaryFunction>    template <class BinaryFunction>
1083    inline    inline
1084    Data    Data
1085    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1086                   double initial_value) const;
1087    
1088    /**    /**
1089       \brief       \brief
# Line 1358  Data::unaryOp(UnaryFunction operation) Line 1449  Data::unaryOp(UnaryFunction operation)
1449    object (*this) is a rank n Data object, and returned object is a scalar.    object (*this) is a rank n Data object, and returned object is a scalar.
1450    Calls escript::algorithm.    Calls escript::algorithm.
1451  */  */
1452  template <class UnaryFunction>  template <class BinaryFunction>
1453  inline  inline
1454  double  double
1455  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1456  {  {
1457    if (isExpanded()) {    if (isExpanded()) {
1458      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1459      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1460      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1461    } else if (isTagged()) {    } else if (isTagged()) {
1462      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1463      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1464      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1465    } else if (isConstant()) {    } else if (isConstant()) {
1466      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1467      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1468      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1469    }    }
1470    return 0;    return 0;
1471  }  }
# Line 1387  Data::algorithm(UnaryFunction operation) Line 1478  Data::algorithm(UnaryFunction operation)
1478    rank 0 Data object.    rank 0 Data object.
1479    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1480  */  */
1481  template <class UnaryFunction>  template <class BinaryFunction>
1482  inline  inline
1483  Data  Data
1484  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1485  {  {
1486    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1487    if (isExpanded()) {    if (isExpanded()) {
# Line 1398  Data::dp_algorithm(UnaryFunction operati Line 1489  Data::dp_algorithm(UnaryFunction operati
1489      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1490      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1491      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1492      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1493    } else if (isTagged()) {    } else if (isTagged()) {
1494      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1495      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1496      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1497      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1498      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1499    } else if (isConstant()) {    } else if (isConstant()) {
1500      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1501      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1502      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1503      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1504      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1505    }    }
1506    return result;    return result;
1507  }  }

Legend:
Removed from v.123  
changed lines
  Added in v.474

  ViewVC Help
Powered by ViewVC 1.1.26