/[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 147 by jgs, Fri Aug 12 01:45:47 2005 UTC trunk/escript/src/Data.h revision 562 by jgs, Thu Feb 23 05:03:16 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 150  class Data { Line 145  class Data {
145       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
146       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
147                         the appropriate values.                         the appropriate values.
148        ==>*
149    */    */
150    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
151         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
# Line 206  class Data { Line 202  class Data {
202         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
203         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
204         bool expanded=false);         bool expanded=false);
205      /**
206         \brief
207         Destructor
208      */
209      ~Data();
210    
211    /**    /**
212       \brief       \brief
# Line 226  class Data { Line 227  class Data {
227    convertToNumArray();    convertToNumArray();
228    
229    /**    /**
      \brief fills the expanded Data object from values of a  python numarray object.  
   
   */  
   void  
   fillFromNumArray(const boost::python::numeric::array);  
   /**  
230       \brief       \brief
231       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.
232    */    */
# Line 248  class Data { Line 243  class Data {
243    
244    /**    /**
245       \brief       \brief
246         Fills the expanded Data object from values of a python numarray object.
247      */
248      void
249      fillFromNumArray(const boost::python::numeric::array);
250    
251      /**
252         \brief
253         Return the tag number associated with the given data-point.
254    
255         The data-point number here corresponds to the data-point number in the
256         numarray returned by convertToNumArray.
257      */
258      int
259      getTagNumber(int dpno);
260    
261      /**
262         \brief
263       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
264    */    */
265    escriptDataC    escriptDataC
# Line 296  class Data { Line 308  class Data {
308       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
309       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
310       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
311        ==>*
312    */    */
313    void    void
314    tag();    tag();
# Line 514  class Data { Line 527  class Data {
527       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
528       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
529       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
530        ==>*
531    */    */
532    void    void
533    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 526  class Data { Line 540  class Data {
540       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
541       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
542       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
543        ==>*
544    */    */
545    void    void
546    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
# Line 684  class Data { Line 699  class Data {
699    const boost::python::tuple    const boost::python::tuple
700    mindp() const;    mindp() const;
701    
702    /**    void
703       \brief    calc_mindp(int& SampleNo,
704       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;  
705    
706    /**    /**
707       \brief       \brief
# Line 746  class Data { Line 756  class Data {
756    
757    /**    /**
758       \brief       \brief
759         Return the asin of each data point of this Data object.
760         *
761      */
762      Data
763      asin() const;
764    
765      /**
766         \brief
767         Return the acos of each data point of this Data object.
768         *
769      */
770      Data
771      acos() const;
772    
773      /**
774         \brief
775         Return the atan of each data point of this Data object.
776         *
777      */
778      Data
779      atan() const;
780    
781      /**
782         \brief
783         Return the sinh of each data point of this Data object.
784         *
785      */
786      Data
787      sinh() const;
788    
789      /**
790         \brief
791         Return the cosh of each data point of this Data object.
792         *
793      */
794      Data
795      cosh() const;
796    
797      /**
798         \brief
799         Return the tanh of each data point of this Data object.
800         *
801      */
802      Data
803      tanh() const;
804    
805      /**
806         \brief
807         Return the asinh of each data point of this Data object.
808         *
809      */
810      Data
811      asinh() const;
812    
813      /**
814         \brief
815         Return the acosh of each data point of this Data object.
816         *
817      */
818      Data
819      acosh() const;
820    
821      /**
822         \brief
823         Return the atanh of each data point of this Data object.
824         *
825      */
826      Data
827      atanh() const;
828    
829      /**
830         \brief
831       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.
832       *       *
833    */    */
834    Data    Data
835    log() const;    log10() const;
836    
837    /**    /**
838       \brief       \brief
# Line 758  class Data { Line 840  class Data {
840       *       *
841    */    */
842    Data    Data
843    ln() const;    log() const;
844    
845    /**    /**
846       \brief       \brief
# Line 1400  inline Line 1482  inline
1482  Data  Data
1483  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1484  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1485    if (isExpanded()) {    if (isExpanded()) {
1486        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1487      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1488      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1489      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1490      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1491      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1492        return result;
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        DataArrayView::ShapeType viewShape;
1496        DataArrayView::ValueType viewData(1);
1497        viewData[0]=0;
1498        DataArrayView defaultValue(viewData,viewShape);
1499        DataTagged::TagListType keys;
1500        DataTagged::ValueListType values;
1501        DataTagged::DataMapType::const_iterator i;
1502        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1503          keys.push_back(i->first);
1504          values.push_back(defaultValue);
1505        }
1506        Data result(keys,values,defaultValue,getFunctionSpace());
1507      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1508      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1509      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1510      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1511        return result;
1512    } else if (isConstant()) {    } else if (isConstant()) {
1513        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1514      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1515      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1516      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1517      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1518      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1519        return result;
1520    }    }
1521    return result;    Data falseRetVal; // to keep compiler quiet
1522      return falseRetVal;
1523  }  }
1524    
1525  }  }

Legend:
Removed from v.147  
changed lines
  Added in v.562

  ViewVC Help
Powered by ViewVC 1.1.26