/[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 126 by jgs, Fri Jul 22 03:53:08 2005 UTC trunk/escript/src/Data.h revision 480 by jgs, Wed Feb 1 05:15:12 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 "DataAlgorithm.h"
23  #include "escript/Data/DataAlgorithm.h"  #include "FunctionSpace.h"
24  #include "escript/Data/FunctionSpace.h"  #include "BinaryOp.h"
25  #include "escript/Data/BinaryOp.h"  #include "UnaryOp.h"
26  #include "escript/Data/UnaryOp.h"  #include "DataException.h"
 #include "escript/Data/DataException.h"  
27    
28  extern "C" {  extern "C" {
29  #include "escript/Data/DataC.h"  #include "DataC.h"
30  }  }
31    
 #include <iostream>  
32  #include <string>  #include <string>
 #include <memory>  
33  #include <algorithm>  #include <algorithm>
34    
35  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
36  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
 #include <boost/python/list.hpp>  
37  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
38  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
39    
40  namespace escript {  namespace escript {
41    
42  //  //
43  // Forward declaration for various implimentations of Data.  // Forward declaration for various implementations of Data.
 class DataEmpty;  
44  class DataConstant;  class DataConstant;
45  class DataTagged;  class DataTagged;
46  class DataExpanded;  class DataExpanded;
# Line 206  class Data { Line 201  class Data {
201         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
202         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
203         bool expanded=false);         bool expanded=false);
204      /**
205         \brief
206         Destructor
207      */
208      ~Data();
209    
210    /**    /**
211       \brief       \brief
# Line 226  class Data { Line 226  class Data {
226    convertToNumArray();    convertToNumArray();
227    
228    /**    /**
      \brief fills the expanded Data object from values of a  python numarray object.  
   
   */  
   void  
   fillFromNumArray(const boost::python::numeric::array);  
   /**  
229       \brief       \brief
230       Return the values of all data-points for the given sample as a single python numarray object.       Return the values of all data-points for the given sample as a single python numarray object.
231    */    */
# Line 248  class Data { Line 242  class Data {
242    
243    /**    /**
244       \brief       \brief
245         Fills the expanded Data object from values of a python numarray object.
246      */
247      void
248      fillFromNumArray(const boost::python::numeric::array);
249    
250      /**
251         \brief
252         Return the tag number associated with the given data-point.
253    
254         The data-point number here corresponds to the data-point number in the
255         numarray returned by convertToNumArray.
256      */
257      int
258      getTagNumber(int dpno);
259    
260      /**
261         \brief
262       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
263    */    */
264    escriptDataC    escriptDataC
# Line 684  class Data { Line 695  class Data {
695    const boost::python::tuple    const boost::python::tuple
696    mindp() const;    mindp() const;
697    
698    /**    void
699       \brief    calc_mindp(int& SampleNo,
700       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;  
701    
702    /**    /**
703       \brief       \brief
# Line 746  class Data { Line 752  class Data {
752    
753    /**    /**
754       \brief       \brief
755         Return the asin of each data point of this Data object.
756         *
757      */
758      Data
759      asin() const;
760    
761      /**
762         \brief
763         Return the acos of each data point of this Data object.
764         *
765      */
766      Data
767      acos() const;
768    
769      /**
770         \brief
771         Return the atan of each data point of this Data object.
772         *
773      */
774      Data
775      atan() const;
776    
777      /**
778         \brief
779         Return the sinh of each data point of this Data object.
780         *
781      */
782      Data
783      sinh() const;
784    
785      /**
786         \brief
787         Return the cosh of each data point of this Data object.
788         *
789      */
790      Data
791      cosh() const;
792    
793      /**
794         \brief
795         Return the tanh of each data point of this Data object.
796         *
797      */
798      Data
799      tanh() const;
800    
801      /**
802         \brief
803         Return the asinh of each data point of this Data object.
804         *
805      */
806      Data
807      asinh() const;
808    
809      /**
810         \brief
811         Return the acosh of each data point of this Data object.
812         *
813      */
814      Data
815      acosh() const;
816    
817      /**
818         \brief
819         Return the atanh of each data point of this Data object.
820         *
821      */
822      Data
823      atanh() const;
824    
825      /**
826         \brief
827       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.
828       *       *
829    */    */
830    Data    Data
831    log() const;    log10() const;
832    
833    /**    /**
834       \brief       \brief
# Line 758  class Data { Line 836  class Data {
836       *       *
837    */    */
838    Data    Data
839    ln() const;    log() const;
840    
841    /**    /**
842       \brief       \brief
# Line 983  class Data { Line 1061  class Data {
1061       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
1062       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.
1063    */    */
1064    template <class UnaryFunction>    template <class BinaryFunction>
1065    inline    inline
1066    double    double
1067    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1068                double initial_value) const;
1069    
1070    /**    /**
1071       \brief       \brief
# Line 995  class Data { Line 1074  class Data {
1074       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
1075       this Data object       this Data object
1076    */    */
1077    template <class UnaryFunction>    template <class BinaryFunction>
1078    inline    inline
1079    Data    Data
1080    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1081                   double initial_value) const;
1082    
1083    /**    /**
1084       \brief       \brief
# Line 1364  Data::unaryOp(UnaryFunction operation) Line 1444  Data::unaryOp(UnaryFunction operation)
1444    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.
1445    Calls escript::algorithm.    Calls escript::algorithm.
1446  */  */
1447  template <class UnaryFunction>  template <class BinaryFunction>
1448  inline  inline
1449  double  double
1450  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1451  {  {
1452    if (isExpanded()) {    if (isExpanded()) {
1453      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1454      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1455      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1456    } else if (isTagged()) {    } else if (isTagged()) {
1457      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1458      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1459      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1460    } else if (isConstant()) {    } else if (isConstant()) {
1461      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1462      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1463      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1464    }    }
1465    return 0;    return 0;
1466  }  }
# Line 1393  Data::algorithm(UnaryFunction operation) Line 1473  Data::algorithm(UnaryFunction operation)
1473    rank 0 Data object.    rank 0 Data object.
1474    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1475  */  */
1476  template <class UnaryFunction>  template <class BinaryFunction>
1477  inline  inline
1478  Data  Data
1479  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1480  {  {
1481    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1482    if (isExpanded()) {    if (isExpanded()) {
# Line 1404  Data::dp_algorithm(UnaryFunction operati Line 1484  Data::dp_algorithm(UnaryFunction operati
1484      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1485      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1486      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1487      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1488    } else if (isTagged()) {    } else if (isTagged()) {
1489      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1490      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1491      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1492      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1493      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1494    } else if (isConstant()) {    } else if (isConstant()) {
1495      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1496      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1497      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1498      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1499      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1500    }    }
1501    return result;    return result;
1502  }  }

Legend:
Removed from v.126  
changed lines
  Added in v.480

  ViewVC Help
Powered by ViewVC 1.1.26