/[escript]/branches/more_shared_ptrs_from_1812/escript/src/Data.h
ViewVC logotype

Diff of /branches/more_shared_ptrs_from_1812/escript/src/Data.h

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

revision 121 by jgs, Fri May 6 04:26:16 2005 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 20  Line 20 
20    
21  #include "escript/Data/DataAbstract.h"  #include "escript/Data/DataAbstract.h"
22  #include "escript/Data/DataTagged.h"  #include "escript/Data/DataTagged.h"
23    #include "escript/Data/DataAlgorithm.h"
24  #include "escript/Data/FunctionSpace.h"  #include "escript/Data/FunctionSpace.h"
25  #include "escript/Data/BinaryOp.h"  #include "escript/Data/BinaryOp.h"
26  #include "escript/Data/UnaryOp.h"  #include "escript/Data/UnaryOp.h"
# Line 225  class Data { Line 226  class Data {
226    convertToNumArray();    convertToNumArray();
227    
228    /**    /**
229         \brief fills the expanded Data object from values of a  python numarray object.
230    
231      */
232      void
233      fillFromNumArray(const boost::python::numeric::array);
234      /**
235       \brief       \brief
236       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.
237    */    */
# Line 540  class Data { Line 547  class Data {
547       \brief       \brief
548       Interpolates this onto the given functionspace and returns       Interpolates this onto the given functionspace and returns
549       the result as a Data object.       the result as a Data object.
550         *
551    */    */
552    Data    Data
553    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
# Line 548  class Data { Line 556  class Data {
556       \brief       \brief
557       Calculates the gradient of the data at the data points of functionspace.       Calculates the gradient of the data at the data points of functionspace.
558       If functionspace is not present the function space of Function(getDomain()) is used.       If functionspace is not present the function space of Function(getDomain()) is used.
559         *
560    */    */
561    Data    Data
562    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
# Line 558  class Data { Line 567  class Data {
567    /**    /**
568       \brief       \brief
569       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
570         *
571    */    */
572    boost::python::numeric::array    boost::python::numeric::array
573    integrate() const;    integrate() const;
# Line 565  class Data { Line 575  class Data {
575    /**    /**
576       \brief       \brief
577       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.
578         *
579    */    */
580    Data    Data
581    wherePositive() const;    wherePositive() const;
# Line 572  class Data { Line 583  class Data {
583    /**    /**
584       \brief       \brief
585       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.
586         *
587    */    */
588    Data    Data
589    whereNegative() const;    whereNegative() const;
# Line 579  class Data { Line 591  class Data {
591    /**    /**
592       \brief       \brief
593       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.
594         *
595    */    */
596    Data    Data
597    whereNonNegative() const;    whereNonNegative() const;
# Line 586  class Data { Line 599  class Data {
599    /**    /**
600       \brief       \brief
601       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.
602         *
603    */    */
604    Data    Data
605    whereNonPositive() const;    whereNonPositive() const;
# Line 593  class Data { Line 607  class Data {
607    /**    /**
608       \brief       \brief
609       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.
610         *
611    */    */
612    Data    Data
613    whereZero() const;    whereZero() const;
# Line 600  class Data { Line 615  class Data {
615    /**    /**
616       \brief       \brief
617       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.
618         *
619    */    */
620    Data    Data
621    whereNonZero() const;    whereNonZero() const;
622    
623    /**    /**
624       \brief       \brief
      Return the sin of each data point of this Data object.  
   */  
   Data  
   sin() const;  
   
   /**  
      \brief  
      Return the cos of each data point of this Data object.  
   */  
   Data  
   cos() const;  
   
   /**  
      \brief  
      Return the tan of each data point of this Data object.  
   */  
   Data  
   tan() const;  
   
   /**  
      \brief  
      Return the log to base 10 of each data point of this Data object.  
   */  
   Data  
   log() const;  
   
   /**  
      \brief  
      Return the natural log of each data point of this Data object.  
   */  
   Data  
   ln() const;  
   
   /**  
      \brief  
625       Return the maximum absolute value of this Data object.       Return the maximum absolute value of this Data object.
626         *
627    */    */
628    double    double
629    Lsup() const;    Lsup() const;
# Line 649  class Data { Line 631  class Data {
631    /**    /**
632       \brief       \brief
633       Return the minimum absolute value of this Data object.       Return the minimum absolute value of this Data object.
634         *
635    */    */
636    double    double
637    Linf() const;    Linf() const;
# Line 656  class Data { Line 639  class Data {
639    /**    /**
640       \brief       \brief
641       Return the maximum value of this Data object.       Return the maximum value of this Data object.
642         *
643    */    */
644    double    double
645    sup() const;    sup() const;
# Line 663  class Data { Line 647  class Data {
647    /**    /**
648       \brief       \brief
649       Return the minimum value of this Data object.       Return the minimum value of this Data object.
650         *
651    */    */
652    double    double
653    inf() const;    inf() const;
# Line 670  class Data { Line 655  class Data {
655    /**    /**
656       \brief       \brief
657       Return the absolute value of each data point of this Data object.       Return the absolute value of each data point of this Data object.
658         *
659    */    */
660    Data    Data
661    abs() const;    abs() const;
# Line 677  class Data { Line 663  class Data {
663    /**    /**
664       \brief       \brief
665       Return the maximum value of each data point of this Data object.       Return the maximum value of each data point of this Data object.
666         *
667    */    */
668    Data    Data
669    maxval() const;    maxval() const;
# Line 684  class Data { Line 671  class Data {
671    /**    /**
672       \brief       \brief
673       Return the minimum value of each data point of this Data object.       Return the minimum value of each data point of this Data object.
674         *
675    */    */
676    Data    Data
677    minval() const;    minval() const;
# Line 700  class Data { Line 688  class Data {
688       \brief       \brief
689       Return the length of each data point of this Data object.       Return the length of each data point of this Data object.
690       sqrt(sum(A[i,j,k,l]^2))       sqrt(sum(A[i,j,k,l]^2))
691         *
692    */    */
693    Data    Data
694    length() const;    length() const;
# Line 708  class Data { Line 697  class Data {
697       \brief       \brief
698       Return the sign of each data point of this Data object.       Return the sign of each data point of this Data object.
699       -1 for negative values, zero for zero values, 1 for positive values.       -1 for negative values, zero for zero values, 1 for positive values.
700         *
701    */    */
702    Data    Data
703    sign() const;    sign() const;
704    
705    /**    /**
706      \brief       \brief
707      Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
708      --* not implemented yet *--       --* not implemented yet *--
709         *
710    */    */
711    Data    Data
712    transpose(int axis) const;    transpose(int axis) const;
713    
714    /**    /**
715      \brief       \brief
716      Calculate the trace of each data point of this Data object.       Calculate the trace of each data point of this Data object.
717      sum(A[i,i,i,i])       sum(A[i,i,i,i])
718         *
719    */    */
720    Data    Data
721    trace() const;    trace() const;
722    
723    /**    /**
724      \brief       \brief
725      Return the exponential function of each data point of this Data object.       Return the sin of each data point of this Data object.
726         *
727      */
728      Data
729      sin() const;
730    
731      /**
732         \brief
733         Return the cos of each data point of this Data object.
734         *
735      */
736      Data
737      cos() const;
738    
739      /**
740         \brief
741         Return the tan of each data point of this Data object.
742         *
743      */
744      Data
745      tan() const;
746    
747      /**
748         \brief
749         Return the log to base 10 of each data point of this Data object.
750         *
751      */
752      Data
753      log() const;
754    
755      /**
756         \brief
757         Return the natural log of each data point of this Data object.
758         *
759      */
760      Data
761      ln() const;
762    
763      /**
764         \brief
765         Return the exponential function of each data point of this Data object.
766         *
767    */    */
768    Data    Data
769    exp() const;    exp() const;
770    
771    /**    /**
772      \brief       \brief
773      Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
774         *
775    */    */
776    Data    Data
777    sqrt() const;    sqrt() const;
778    
779    /**    /**
780      \brief       \brief
781      Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
782         *
783    */    */
784    Data    Data
785    neg() const;    neg() const;
786    
787    /**    /**
788      \brief       \brief
789      Return the identity of each data point of this Data object.       Return the identity of each data point of this Data object.
790      Simply returns this object unmodified.       Simply returns this object unmodified.
791         *
792    */    */
793    Data    Data
794    pos() const;    pos() const;
# Line 762  class Data { Line 798  class Data {
798       Return the given power of each data point of this Data object.       Return the given power of each data point of this Data object.
799    
800       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
801         *
802    */    */
803    Data    Data
804    powD(const Data& right) const;    powD(const Data& right) const;
805    
806    /**    /**
807     * \brief       \brief
808     * Return the given power of each data point of this boost python object.       Return the given power of each data point of this boost python object.
809     *      
810     * \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
811         *
812     */     */
813    Data    Data
814    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
815    
816    /**    /**
817      \brief       \brief
818      writes the object to a file in the DX file format       writes the object to a file in the DX file format
819    */    */
820    void    void
821    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
822    
823    /**    /**
824      \brief       \brief
825      writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
826    */    */
827    void    void
828    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
# Line 793  class Data { Line 831  class Data {
831       \brief       \brief
832       Overloaded operator +=       Overloaded operator +=
833       \param right - Input - The right hand side.       \param right - Input - The right hand side.
834         *
835    */    */
836    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
837    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
# Line 801  class Data { Line 840  class Data {
840       \brief       \brief
841       Overloaded operator -=       Overloaded operator -=
842       \param right - Input - The right hand side.       \param right - Input - The right hand side.
843         *
844    */    */
845    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
846    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
# Line 809  class Data { Line 849  class Data {
849       \brief       \brief
850       Overloaded operator *=       Overloaded operator *=
851       \param right - Input - The right hand side.       \param right - Input - The right hand side.
852         *
853    */    */
854    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
855    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
# Line 817  class Data { Line 858  class Data {
858       \brief       \brief
859       Overloaded operator /=       Overloaded operator /=
860       \param right - Input - The right hand side.       \param right - Input - The right hand side.
861         *
862    */    */
863    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
864    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
# Line 882  class Data { Line 924  class Data {
924       Return a Data object containing the specified slice of       Return a Data object containing the specified slice of
925       this Data object.       this Data object.
926       \param region - Input - Region to copy.       \param region - Input - Region to copy.
927         *
928    */    */
929    Data    Data
930    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 892  class Data { Line 935  class Data {
935       Data object.       Data object.
936       \param value - Input - Data to copy from.       \param value - Input - Data to copy from.
937       \param region - Input - Region to copy.       \param region - Input - Region to copy.
938         *
939    */    */
940    void    void
941    setSlice(const Data& value,    setSlice(const Data& value,
# Line 939  class Data { Line 983  class Data {
983       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
984       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.
985    */    */
986    template <class UnaryFunction>    template <class BinaryFunction>
987    inline    inline
988    double    double
989    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
990                double initial_value) const;
991    
992    /**    /**
993       \brief       \brief
# Line 951  class Data { Line 996  class Data {
996       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
997       this Data object       this Data object
998    */    */
999    template <class UnaryFunction>    template <class BinaryFunction>
1000    inline    inline
1001    Data    Data
1002    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1003                   double initial_value) const;
1004    
1005    /**    /**
1006       \brief       \brief
# Line 1021  class Data { Line 1067  class Data {
1067    // pointer to the actual data object    // pointer to the actual data object
1068    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1069    
1070      //
1071      // pointer to the internal profiling data
1072      struct profDataEntry *profData;
1073    
1074  };  };
1075    
1076  template <class IValueType>  template <class IValueType>
# Line 1316  Data::unaryOp(UnaryFunction operation) Line 1366  Data::unaryOp(UnaryFunction operation)
1366    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.
1367    Calls escript::algorithm.    Calls escript::algorithm.
1368  */  */
1369  template <class UnaryFunction>  template <class BinaryFunction>
1370  inline  inline
1371  double  double
1372  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1373  {  {
1374    if (isExpanded()) {    if (isExpanded()) {
1375      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1376      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1377      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1378    } else if (isTagged()) {    } else if (isTagged()) {
1379      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1380      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1381      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1382    } else if (isConstant()) {    } else if (isConstant()) {
1383      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1384      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1385      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1386    }    }
1387    return 0;    return 0;
1388  }  }
# Line 1345  Data::algorithm(UnaryFunction operation) Line 1395  Data::algorithm(UnaryFunction operation)
1395    rank 0 Data object.    rank 0 Data object.
1396    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1397  */  */
1398  template <class UnaryFunction>  template <class BinaryFunction>
1399  inline  inline
1400  Data  Data
1401  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1402  {  {
1403    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1404    if (isExpanded()) {    if (isExpanded()) {
# Line 1356  Data::dp_algorithm(UnaryFunction operati Line 1406  Data::dp_algorithm(UnaryFunction operati
1406      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1407      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1408      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1409      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1410    } else if (isTagged()) {    } else if (isTagged()) {
1411      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1412      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1413      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1414      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1415      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1416    } else if (isConstant()) {    } else if (isConstant()) {
1417      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1418      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1419      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1420      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1421      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1422    }    }
1423    return result;    return result;
1424  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26