/[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 580 by gross, Wed Mar 8 05:45:51 2006 UTC revision 1799 by jfenwick, Wed Sep 17 06:33:18 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    /**    /**
110         \brief Return a deep copy of the current object.
111      */
112      ESCRIPT_DLL_API
113      virtual
114      DataAbstract*
115      deepCopy();
116    
117    
118     /**
119         \brief
120         dumps the object into a netCDF file
121      */
122      ESCRIPT_DLL_API
123      virtual
124      void
125      dump(const std::string fileName) const;
126    
127     /**
128         \brief
129        sets all values to zero
130      */
131      ESCRIPT_DLL_API
132      virtual
133      void
134      setToZero();
135    
136      /**
137       \brief       \brief
138       Return the offset for the given sample. This is a somewhat artificial notion       Return the offset for the given sample. This is a somewhat artificial notion
139       but returns the offset in bytes for the given point into the container       but returns the offset in bytes for the given point into the container
# Line 109  class DataConstant : public DataAbstract Line 142  class DataConstant : public DataAbstract
142       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
143       \param dataPointNo - Input - data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
144     */     */
145      ESCRIPT_DLL_API
146    virtual    virtual
147    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
148    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
149                   int dataPointNo) const;                   int dataPointNo) const;
150    
151    /**  //  /**
152       \brief  /*     \brief
153       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
154       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
155       \param dataPointNo - Input - data point number for the sample.       \param dataPointNo - Input - data point number for the sample.*/
156    */  //  */
157    virtual  //   ESCRIPT_DLL_API
158    DataArrayView  //   virtual
159    getDataPoint(int sampleNo,  //   DataArrayView
160                 int dataPointNo);  //   getDataPoint(int sampleNo,
161    //                int dataPointNo);
162    
163    /**    /**
164       \brief       \brief
165       Return the number of doubles stored for the Data object.       Return the number of doubles stored for the Data object.
166    */    */
167      ESCRIPT_DLL_API
168    virtual    virtual
169    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
170    getLength() const;    getLength() const;
171    
172    /**    /**
# Line 140  class DataConstant : public DataAbstract Line 176  class DataConstant : public DataAbstract
176       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
177       \param region - Input - region to slice from this object.       \param region - Input - region to slice from this object.
178    */    */
179      ESCRIPT_DLL_API
180    virtual    virtual
181    DataAbstract*    DataAbstract*
182    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
183    
184    /**    /**
185       \brief       \brief
# Line 150  class DataConstant : public DataAbstract Line 187  class DataConstant : public DataAbstract
187       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
188       \param region - Input - Region to copy.       \param region - Input - Region to copy.
189    */    */
190      ESCRIPT_DLL_API
191    virtual    virtual
192    void    void
193    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
194             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
195    
196    
197      /**
198         \brief
199         Computes a symmetric matrix (A + AT) / 2
200    
201         \param ev - Output - symmetric matrix
202    
203      */
204      ESCRIPT_DLL_API
205      virtual void
206      symmetric(DataAbstract* ev);
207    
208    /**    /**
209       \brief       \brief
210       Reshape the data point if the data point is currently rank 0.       Computes a nonsymmetric matrix (A - AT) / 2
211       The original data point value is used for all values of the new  
212       data point.       \param ev - Output - nonsymmetric matrix
213    
214    */    */
215    void    ESCRIPT_DLL_API
216    reshapeDataPoint(const DataArrayView::ShapeType& shape);    virtual void
217      nonsymmetric(DataAbstract* ev);
218    
219    /**    /**
220      \brief       \brief
221      Archive the underlying data values to the file referenced       Computes the trace of a matrix
222      by ofstream. A count of the number of values expected to be written  
223      is provided as a cross-check.       \param ev - Output - trace of matrix
224    
     The return value indicates success (0) or otherwise (1).  
225    */    */
226    int    ESCRIPT_DLL_API
227    archiveData(std::ofstream& archiveFile,    virtual void
228                const DataArrayView::ValueType::size_type noValues) const;    trace(DataAbstract* ev, int axis_offset);
229    
230    /**    /**
231      \brief       \brief
232      Extract the number of values specified by noValues from the file       Transpose each data point of this Data object around the given axis.
233      referenced by ifstream to the underlying data structure.  
234         \param ev - Output - transpose of matrix
235    
     The return value indicates success (0) or otherwise (1).  
236    */    */
237    int    ESCRIPT_DLL_API
238    extractData(std::ifstream& archiveFile,    virtual void
239                const DataArrayView::ValueType::size_type noValues);    transpose(DataAbstract* ev, int axis_offset);
240    
241      /**
242         \brief
243         swaps components axis0 and axis1
244    
245         \param ev - Output - swapped components
246    
247      */
248      ESCRIPT_DLL_API
249      virtual void
250      swapaxes(DataAbstract* ev, int axis0, int axis1);
251    
252    
253    /**    /**
254       \brief       \brief
# Line 194  class DataConstant : public DataAbstract Line 257  class DataConstant : public DataAbstract
257       \param ev - Output - eigenvalues in increasing order at each data point       \param ev - Output - eigenvalues in increasing order at each data point
258    
259    */    */
260      ESCRIPT_DLL_API
261    virtual void    virtual void
262    eigenvalues(DataAbstract* ev);    eigenvalues(DataAbstract* ev);
263    
# Line 208  class DataConstant : public DataAbstract Line 272  class DataConstant : public DataAbstract
272    
273    */    */
274    
275      ESCRIPT_DLL_API
276    virtual void    virtual void
277    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
278    
279    
280      /**
281         \brief
282         Return a reference to the underlying DataVector.
283      */
284      ESCRIPT_DLL_API
285      DataTypes::ValueType&
286      getVector();
287    
288      ESCRIPT_DLL_API
289      const DataTypes::ValueType&
290      getVector() const;
291    
292    
293   protected:   protected:
294    
295   private:   private:
296    //    //
297    // the actual data    // the actual data
298    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
299    
300  };  };
301    
302    inline
303    DataTypes::ValueType&
304    DataConstant::getVector()
305    {
306      return m_data;
307    }
308    
309    inline
310    const DataTypes::ValueType&
311    DataConstant::getVector() const
312    {
313      return m_data;
314    }
315    
316    
317  } // end of namespace  } // end of namespace
318  #endif  #endif

Legend:
Removed from v.580  
changed lines
  Added in v.1799

  ViewVC Help
Powered by ViewVC 1.1.26