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

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

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

trunk/esys2/escript/src/Data/DataArrayView.h revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC trunk/escript/src/Data/DataArrayView.h revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC
# Line 497  class DataArrayView { Line 497  class DataArrayView {
497       \param key - Input -       \param key - Input -
498                      python slice object specifying region to be returned.                      python slice object specifying region to be returned.
499    
      \description  
   
500       The slice object is a tuple of n python slice specifiers, where       The slice object is a tuple of n python slice specifiers, where
501       n <= the rank of this Data object. Each slice specifier specifies the       n <= the rank of this Data object. Each slice specifier specifies the
502       range of indexes to be sliced from the corresponding dimension. The       range of indexes to be sliced from the corresponding dimension. The
# Line 747  class DataArrayView { Line 745  class DataArrayView {
745       \param operation - Input -       \param operation - Input -
746                    Operation to apply. Must be a pointer to a function.                    Operation to apply. Must be a pointer to a function.
747    */    */
748    template <class UnaryFunction>    template <class BinaryFunction>
749    double    double
750    reductionOp(UnaryFunction operation) const;    reductionOp(BinaryFunction operation,
751                  double initial_value) const;
752    
753    /**    /**
754       \brief       \brief
# Line 765  class DataArrayView { Line 764  class DataArrayView {
764       \param operation - Input -       \param operation - Input -
765                    Operation to apply. Must be a pointer to a function.                    Operation to apply. Must be a pointer to a function.
766    */    */
767    template <class UnaryFunction>    template <class BinaryFunction>
768    double    double
769    reductionOp(ValueType::size_type offset,    reductionOp(ValueType::size_type offset,
770                UnaryFunction operation) const;                BinaryFunction operation,
771                  double initial_value) const;
772    
773    /**    /**
774       \brief       \brief
775       Perform a matrix multiply of the given views.       Perform a matrix multiply of the given views.
776       This is purely a utility method and has no bearing on this view.       This is purely a utility method and has no bearing on this view.
777    
778         NB: Only multiplies together the two given views, ie: two data-points,
779         would need to call this over all data-points to multiply the entire
780         Data objects involved.
781    
782       \param left - Input - The left hand side.       \param left - Input - The left hand side.
783       \param right - Input - The right hand side.       \param right - Input - The right hand side.
784       \param result - Output - The result of the operation.       \param result - Output - The result of the operation.
# Line 938  DataArrayView::binaryOp(ValueType::size_ Line 942  DataArrayView::binaryOp(ValueType::size_
942    }    }
943  }  }
944    
945  template <class UnaryFunction>  template <class BinaryFunction>
946  inline  inline
947  double  double
948  DataArrayView::reductionOp(UnaryFunction operation) const  DataArrayView::reductionOp(BinaryFunction operation,
949                               double initial_value) const
950  {  {
951    return reductionOp(m_offset,operation);    return reductionOp(m_offset,operation,initial_value);
952  }  }
953    
954  template <class UnaryFunction>  template <class BinaryFunction>
955  inline  inline
956  double  double
957  DataArrayView::reductionOp(ValueType::size_type offset,  DataArrayView::reductionOp(ValueType::size_type offset,
958                             UnaryFunction operation) const                             BinaryFunction operation,
959                               double initial_value) const
960  {  {
961    EsysAssert((!isEmpty()&&checkOffset(offset)),    EsysAssert((!isEmpty()&&checkOffset(offset)),
962                 "Error - Couldn't perform reductionOp due to insufficient storage.");                 "Error - Couldn't perform reductionOp due to insufficient storage.");
963    operation.resetResult();    double current_value=initial_value;
964    for (ValueType::size_type i=0;i<noValues();i++) {    for (ValueType::size_type i=0;i<noValues();i++) {
965      operation((*m_data)[offset+i]);      current_value=operation(current_value,(*m_data)[offset+i]);
966    }    }
967    return operation.getResult();    return current_value;
968  }  }
969    
970  inline  inline

Legend:
Removed from v.117  
changed lines
  Added in v.155

  ViewVC Help
Powered by ViewVC 1.1.26