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

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

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

revision 480 by jgs, Wed Feb 1 05:15:12 2006 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*  /* $Id$ */
3   ******************************************************************************  
4   *                                                                            *  /*******************************************************
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *
6   *                                                                            *   *           Copyright 2003-2007 by ACceSS MNRF
7   * This software is the property of ACcESS. No part of this code              *   *       Copyright 2007 by University of Queensland
8   * may be copied in any form or by any means without the expressed written    *   *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *                http://esscc.uq.edu.au
10   * by any unauthorised person is illegal unless that person has a software    *   *        Primary Business: Queensland, Australia
11   * license agreement with ACcESS.                                             *   *  Licensed under the Open Software License version 3.0
12   *                                                                            *   *     http://www.opensource.org/licenses/osl-3.0.php
13   ******************************************************************************   *
14  */   *******************************************************/
15    
16  #if !defined escript_DataConstant_20040323_H  #if !defined escript_DataConstant_20040323_H
17  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
18    #include "system_dep.h"
19    
20  #include "DataAbstract.h"  #include "DataAbstract.h"
 #include "DataArrayView.h"  
21    
22  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
23    
# Line 46  class DataConstant : public DataAbstract Line 46  class DataConstant : public DataAbstract
46       \param value - Input - Data value for a single point.       \param value - Input - Data value for a single point.
47       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.
48    */    */
49      ESCRIPT_DLL_API
50    DataConstant(const boost::python::numeric::array& value,    DataConstant(const boost::python::numeric::array& value,
51                 const FunctionSpace& what);                 const FunctionSpace& what);
52    
# Line 53  class DataConstant : public DataAbstract Line 54  class DataConstant : public DataAbstract
54       \brief       \brief
55       Copy constructor. Performs a deep copy.       Copy constructor. Performs a deep copy.
56    */    */
57      ESCRIPT_DLL_API
58    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
59    
60    /**  //  /**
61       \brief  /*     \brief
62       Alternative constructor for DataConstant objects.       Alternative constructor for DataConstant objects.
63    
64       Description:       Description:
65       Alternative Constructor for DataConstant objects.       Alternative Constructor for DataConstant objects.
66       \param value - Input - Data value for a single point.       \param value - Input - Data value for a single point.
67       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.*/
68    */  //  */
69    DataConstant(const DataArrayView& value,  //   ESCRIPT_DLL_API
70                 const FunctionSpace& what);  //   DataConstant(const DataArrayView& value,
71    //                const FunctionSpace& what);
72    
73    /**    /**
74       \brief       \brief
# Line 76  class DataConstant : public DataAbstract Line 79  class DataConstant : public DataAbstract
79       \param other - Input - Data object to copy from.       \param other - Input - Data object to copy from.
80       \param region - Input - region to copy.       \param region - Input - region to copy.
81    */    */
82      ESCRIPT_DLL_API
83    DataConstant(const DataConstant& other,    DataConstant(const DataConstant& other,
84                 const DataArrayView::RegionType& region);                 const DataTypes::RegionType& region);
85    
86    /**    /**
87       \brief       \brief
# Line 89  class DataConstant : public DataAbstract Line 93  class DataConstant : public DataAbstract
93       \param shape - Input - the shape of each data-point.       \param shape - Input - the shape of each data-point.
94       \param data - the data values for each data-point.       \param data - the data values for each data-point.
95    */    */
96      ESCRIPT_DLL_API
97    DataConstant(const FunctionSpace& what,    DataConstant(const FunctionSpace& what,
98                 const DataArrayView::ShapeType &shape,                 const DataTypes::ShapeType &shape,
99                 const DataArrayView::ValueType &data);                 const DataTypes::ValueType &data);
100    
101    /**    /**
102       \brief       \brief
103       Write the data as a string.       Write the data as a string.
104    */    */
105      ESCRIPT_DLL_API
106    std::string    std::string
107    toString() const;    toString() const;
108     /**
109         \brief
110         dumps the object into a netCDF file
111      */
112      ESCRIPT_DLL_API
113      virtual
114      void
115      dump(const std::string fileName) const;
116    
117     /**
118         \brief
119        sets all values to zero
120      */
121      ESCRIPT_DLL_API
122      virtual
123      void
124      setToZero();
125    
126    /**    /**
127       \brief       \brief
# Line 109  class DataConstant : public DataAbstract Line 132  class DataConstant : public DataAbstract
132       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
133       \param dataPointNo - Input - data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
134     */     */
135      ESCRIPT_DLL_API
136    virtual    virtual
137    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
138    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
139                   int dataPointNo) const;                   int dataPointNo) const;
140    
141    /**  //  /**
142       \brief  /*     \brief
143       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
144       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
145       \param dataPointNo - Input - data point number for the sample.       \param dataPointNo - Input - data point number for the sample.*/
146    */  //  */
147    virtual  //   ESCRIPT_DLL_API
148    DataArrayView  //   virtual
149    getDataPoint(int sampleNo,  //   DataArrayView
150                 int dataPointNo);  //   getDataPoint(int sampleNo,
151    //                int dataPointNo);
152    
153    /**    /**
154       \brief       \brief
155       Return the number of doubles stored for the Data object.       Return the number of doubles stored for the Data object.
156    */    */
157      ESCRIPT_DLL_API
158    virtual    virtual
159    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
160    getLength() const;    getLength() const;
161    
162    /**    /**
# Line 140  class DataConstant : public DataAbstract Line 166  class DataConstant : public DataAbstract
166       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
167       \param region - Input - region to slice from this object.       \param region - Input - region to slice from this object.
168    */    */
169      ESCRIPT_DLL_API
170    virtual    virtual
171    DataAbstract*    DataAbstract*
172    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
173    
174    /**    /**
175       \brief       \brief
# Line 150  class DataConstant : public DataAbstract Line 177  class DataConstant : public DataAbstract
177       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
178       \param region - Input - Region to copy.       \param region - Input - Region to copy.
179    */    */
180      ESCRIPT_DLL_API
181    virtual    virtual
182    void    void
183    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
184             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
185    
186    
187    /**    /**
188       \brief       \brief
189       Reshape the data point if the data point is currently rank 0.       Computes a symmetric matrix (A + AT) / 2
190       The original data point value is used for all values of the new  
191       data point.       \param ev - Output - symmetric matrix
192    
193    */    */
194    void    ESCRIPT_DLL_API
195    reshapeDataPoint(const DataArrayView::ShapeType& shape);    virtual void
196      symmetric(DataAbstract* ev);
197    
198    /**    /**
199      \brief       \brief
200      Archive the underlying data values to the file referenced       Computes a nonsymmetric matrix (A - AT) / 2
201      by ofstream. A count of the number of values expected to be written  
202      is provided as a cross-check.       \param ev - Output - nonsymmetric matrix
203    
     The return value indicates success (0) or otherwise (1).  
204    */    */
205    int    ESCRIPT_DLL_API
206    archiveData(std::ofstream& archiveFile,    virtual void
207                const DataArrayView::ValueType::size_type noValues) const;    nonsymmetric(DataAbstract* ev);
208    
209    /**    /**
210      \brief       \brief
211      Extract the number of values specified by noValues from the file       Computes the trace of a matrix
212      referenced by ifstream to the underlying data structure.  
213         \param ev - Output - trace of matrix
214    
     The return value indicates success (0) or otherwise (1).  
215    */    */
216    int    ESCRIPT_DLL_API
217    extractData(std::ifstream& archiveFile,    virtual void
218                const DataArrayView::ValueType::size_type noValues);    trace(DataAbstract* ev, int axis_offset);
219    
220      /**
221         \brief
222         Transpose each data point of this Data object around the given axis.
223    
224         \param ev - Output - transpose of matrix
225    
226      */
227      ESCRIPT_DLL_API
228      virtual void
229      transpose(DataAbstract* ev, int axis_offset);
230    
231      /**
232         \brief
233         swaps components axis0 and axis1
234    
235         \param ev - Output - swapped components
236    
237      */
238      ESCRIPT_DLL_API
239      virtual void
240      swapaxes(DataAbstract* ev, int axis0, int axis1);
241    
242    
243      /**
244         \brief
245         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
246    
247         \param ev - Output - eigenvalues in increasing order at each data point
248    
249      */
250      ESCRIPT_DLL_API
251      virtual void
252      eigenvalues(DataAbstract* ev);
253    
254      /**
255         \brief
256         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
257    
258         \param ev - Output - eigenvalues in increasing order at each data point
259         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
260                             and the first nonzero component is positive.
261         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
262    
263      */
264    
265      ESCRIPT_DLL_API
266      virtual void
267      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
268    
269    
270      /**
271         \brief
272         Return a reference to the underlying DataVector.
273      */
274      ESCRIPT_DLL_API
275      DataTypes::ValueType&
276      getVector();
277    
278      ESCRIPT_DLL_API
279      const DataTypes::ValueType&
280      getVector() const;
281    
282    
283   protected:   protected:
284    
285   private:   private:
286    //    //
287    // the actual data    // the actual data
288    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
289    
290  };  };
291    
292    inline
293    DataTypes::ValueType&
294    DataConstant::getVector()
295    {
296      return m_data;
297    }
298    
299    inline
300    const DataTypes::ValueType&
301    DataConstant::getVector() const
302    {
303      return m_data;
304    }
305    
306    
307  } // end of namespace  } // end of namespace
308  #endif  #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26