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

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

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

revision 478 by jgs, Tue Jan 31 02:21:49 2006 UTC revision 922 by gross, Fri Jan 5 04:23:05 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
12   *                                                                            *  
  ******************************************************************************  
13  */  */
14    
15  #if !defined escript_DataAbstract_20040315_H  #if !defined escript_DataAbstract_20040315_H
16  #define escript_DataAbstract_20040315_H  #define escript_DataAbstract_20040315_H
17    #include "system_dep.h"
18    
19  #include "DataArrayView.h"  #include "DataArrayView.h"
20  #include "DataArray.h"  #include "DataArray.h"
21  #include "FunctionSpace.h"  #include "FunctionSpace.h"
22    
 #include <iostream>  
 #include <fstream>  
23  #include <boost/scoped_ptr.hpp>  #include <boost/scoped_ptr.hpp>
24  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
25    
26  #include <string>  #include <string>
27    #include <fstream>
28    
29  namespace escript {  namespace escript {
30    
# Line 58  class DataAbstract { Line 58  class DataAbstract {
58    
59       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
60    */    */
61      ESCRIPT_DLL_API
62    DataAbstract(const FunctionSpace& what);    DataAbstract(const FunctionSpace& what);
63    
64    /**    /**
65      \brief      \brief
66      Destructor for DataAbstract.      Destructor for DataAbstract.
67    */    */
68      ESCRIPT_DLL_API
69    virtual    virtual
70    ~DataAbstract();    ~DataAbstract();
71    
# Line 71  class DataAbstract { Line 73  class DataAbstract {
73       \brief       \brief
74       Write the data as a string.       Write the data as a string.
75    */    */
76      ESCRIPT_DLL_API
77    virtual    virtual
78    std::string    std::string
79    toString() const = 0;    toString() const = 0;
# Line 79  class DataAbstract { Line 82  class DataAbstract {
82       \brief       \brief
83       Return the number of data points per sample.       Return the number of data points per sample.
84    */    */
85      ESCRIPT_DLL_API
86    int    int
87    getNumDPPSample() const;    getNumDPPSample() const;
88    
# Line 86  class DataAbstract { Line 90  class DataAbstract {
90       \brief       \brief
91       Return the number of samples.       Return the number of samples.
92    */    */
93      ESCRIPT_DLL_API
94    int    int
95    getNumSamples() const;    getNumSamples() const;
96    
# Line 95  class DataAbstract { Line 100  class DataAbstract {
100       the shape information for each data point although it also may be used       the shape information for each data point although it also may be used
101       to manipulate the point data.       to manipulate the point data.
102    */    */
103      ESCRIPT_DLL_API
104    DataArrayView&    DataArrayView&
105    getPointDataView();    getPointDataView();
106    
107      ESCRIPT_DLL_API
108    const DataArrayView&    const DataArrayView&
109    getPointDataView() const;    getPointDataView() const;
110    
# Line 110  class DataAbstract { Line 117  class DataAbstract {
117       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
118       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
119     */     */
120      ESCRIPT_DLL_API
121    virtual    virtual
122    ValueType::size_type    ValueType::size_type
123    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 119  class DataAbstract { Line 127  class DataAbstract {
127       \brief       \brief
128       Return the sample data for the given sample number.       Return the sample data for the given sample number.
129    */    */
130      ESCRIPT_DLL_API
131    double*    double*
132    getSampleData(ValueType::size_type sampleNo);    getSampleData(ValueType::size_type sampleNo);
133    
# Line 126  class DataAbstract { Line 135  class DataAbstract {
135       \brief       \brief
136       Return the number of doubles stored for this Data object.       Return the number of doubles stored for this Data object.
137    */    */
138      ESCRIPT_DLL_API
139    virtual    virtual
140    ValueType::size_type    ValueType::size_type
141    getLength() const = 0;    getLength() const = 0;
# Line 135  class DataAbstract { Line 145  class DataAbstract {
145       Return the sample data for the given tag key.       Return the sample data for the given tag key.
146       NB: If the data isn't tagged an exception will be thrown.       NB: If the data isn't tagged an exception will be thrown.
147    */    */
148      ESCRIPT_DLL_API
149    virtual    virtual
150    double*    double*
151    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
# Line 151  class DataAbstract { Line 162  class DataAbstract {
162       \param value - Input - value to assign to data-points associated with       \param value - Input - value to assign to data-points associated with
163                              the given reference number.                              the given reference number.
164    */    */
165      ESCRIPT_DLL_API
166    virtual    virtual
167    void    void
168    setRefValue(int ref,    setRefValue(int ref,
# Line 168  class DataAbstract { Line 180  class DataAbstract {
180       \param value - Output - object to receive data-points associated with       \param value - Output - object to receive data-points associated with
181                               the given reference number.                               the given reference number.
182    */    */
183      ESCRIPT_DLL_API
184    virtual    virtual
185    void    void
186    getRefValue(int ref,    getRefValue(int ref,
# Line 180  class DataAbstract { Line 193  class DataAbstract {
193    
194       \param right - Input - The right hand side.       \param right - Input - The right hand side.
195    */    */
196      ESCRIPT_DLL_API
197    void    void
198    operandCheck(const DataAbstract& right) const;    operandCheck(const DataAbstract& right) const;
199    
# Line 187  class DataAbstract { Line 201  class DataAbstract {
201       \brief       \brief
202       Return true if a valid sample point number.       Return true if a valid sample point number.
203    */    */
204      ESCRIPT_DLL_API
205    bool    bool
206    validSamplePointNo(int samplePointNo) const;    validSamplePointNo(int samplePointNo) const;
207    
# Line 194  class DataAbstract { Line 209  class DataAbstract {
209       \brief       \brief
210       Return true if a valid sample number.       Return true if a valid sample number.
211    */    */
212      ESCRIPT_DLL_API
213    bool    bool
214    validSampleNo(int sampleNo) const;    validSampleNo(int sampleNo) const;
215    
# Line 206  class DataAbstract { Line 222  class DataAbstract {
222       \param sampleNo - Input - the sample number.       \param sampleNo - Input - the sample number.
223       \param dataPointNo - Input - the data point number.       \param dataPointNo - Input - the data point number.
224    */    */
225      ESCRIPT_DLL_API
226    virtual    virtual
227    DataArrayView    DataArrayView
228    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
# Line 215  class DataAbstract { Line 232  class DataAbstract {
232       \brief       \brief
233       Return the function space associated with this Data object.       Return the function space associated with this Data object.
234    */    */
235      ESCRIPT_DLL_API
236    const    const
237    FunctionSpace&    FunctionSpace&
238    getFunctionSpace() const;    getFunctionSpace() const;
# Line 225  class DataAbstract { Line 243  class DataAbstract {
243    
244       NB: The caller is responsible for managing the object created.       NB: The caller is responsible for managing the object created.
245    */    */
246      ESCRIPT_DLL_API
247    virtual    virtual
248    DataAbstract*    DataAbstract*
249    getSlice(const DataArrayView::RegionType& region) const = 0;    getSlice(const DataArrayView::RegionType& region) const = 0;
# Line 236  class DataAbstract { Line 255  class DataAbstract {
255       \param value - Input - Data to copy from       \param value - Input - Data to copy from
256       \param region - Input - Region to copy.       \param region - Input - Region to copy.
257    */    */
258      ESCRIPT_DLL_API
259    virtual    virtual
260    void    void
261    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
262             const DataArrayView::RegionType& region) = 0;             const DataArrayView::RegionType& region) = 0;
263    
   /**  
      \brief  
      Reshape the data points if they are currently rank 0.  
      Will throw an exception if the data points are not rank 0.  
      The original data point value is used for all values of the new  
      data point.  
   */  
   virtual  
   void  
   reshapeDataPoint(const ShapeType& shape) = 0;  
264    
265    /**    /**
266       \brief       \brief
# Line 264  class DataAbstract { Line 274  class DataAbstract {
274       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
275       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
276    */    */
277      ESCRIPT_DLL_API
278    virtual    virtual
279    void    void
280    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 277  class DataAbstract { Line 288  class DataAbstract {
288    
289      The return value indicates success (0) or otherwise (1).      The return value indicates success (0) or otherwise (1).
290    */    */
291      ESCRIPT_DLL_API
292    virtual    virtual
293    int    int
294    archiveData(std::ofstream& archiveFile,    archiveData(std::ofstream& archiveFile,
# Line 289  class DataAbstract { Line 301  class DataAbstract {
301    
302      The return value indicates success (0) or otherwise (1).      The return value indicates success (0) or otherwise (1).
303    */    */
304      ESCRIPT_DLL_API
305    virtual    virtual
306    int    int
307    extractData(std::ifstream& archiveFile,    extractData(std::ifstream& archiveFile,
# Line 303  class DataAbstract { Line 316  class DataAbstract {
316    
317       \param value Input - new values for the data points       \param value Input - new values for the data points
318    */    */
319      ESCRIPT_DLL_API
320    virtual void    virtual void
321    copyAll(const boost::python::numeric::array& value);    copyAll(const boost::python::numeric::array& value);
322    
323    /**    /**
324       \brief       \brief
325         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
326    
327         Description:
328         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
329    
330         \param sampleNo Input - sample number
331         \param dataPointNo Input - data point of the sample
332         \param value Input - new values for the data point
333      */
334      ESCRIPT_DLL_API
335      virtual void
336      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
337    
338      /**
339         \brief
340         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
341    
342         Description:
343         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
344    
345         \param sampleNo Input - sample number
346         \param dataPointNo Input - data point of the sample
347         \param value Input - new values for the data point
348      */
349      ESCRIPT_DLL_API
350      virtual void
351      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
352    
353    
354      /**
355         \brief
356       Return the tag number associated with the given data-point number.       Return the tag number associated with the given data-point number.
357    
358       If the object cannot be referenced by tag numbers, an exception       If the object cannot be referenced by tag numbers, an exception
359       will be thrown.       will be thrown.
360    */    */
361      ESCRIPT_DLL_API
362    virtual    virtual
363    int    int
364    getTagNumber(int dpno);    getTagNumber(int dpno);
365    
366      /**
367         \brief
368         Computes a symmetric matrix (A + AT) / 2
369    
370         \param ev - Output - a symmetric matrix
371    
372      */
373      ESCRIPT_DLL_API
374      virtual void
375      symmetric(DataAbstract* ev);
376    
377      /**
378         \brief
379         Computes a nonsymmetric matrix (A - AT) / 2
380    
381         \param ev - Output - a nonsymmetric matrix
382    
383      */
384      ESCRIPT_DLL_API
385      virtual void
386      nonsymmetric(DataAbstract* ev);
387    
388      /**
389         \brief
390         Computes the trace of a matrix
391    
392         \param ev - Output - the trace of a matrix
393    
394      */
395      ESCRIPT_DLL_API
396      virtual void
397      trace(DataAbstract* ev, int axis_offset);
398    
399      /**
400         \brief
401         Transpose each data point of this Data object around the given axis.
402    
403         \param ev - Output - the transpose of a matrix
404    
405      */
406      ESCRIPT_DLL_API
407      virtual void
408      transpose(DataAbstract* ev, int axis_offset);
409    
410      /**
411         \brief
412         swaps components axis0 and axis1
413    
414         \param ev - Output - swapped components
415    
416      */
417      ESCRIPT_DLL_API
418      virtual void
419      swapaxes(DataAbstract* ev, int axis0, int axis1);
420      /**
421         \brief
422         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
423    
424         \param ev - Output - eigenvalues in increasing order at each data point
425    
426      */
427      ESCRIPT_DLL_API
428      virtual void
429      eigenvalues(DataAbstract* ev);
430    
431      /**
432         \brief
433         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
434    
435         \param ev - Output - eigenvalues in increasing order at each data point
436         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
437                             and the first nonzero component is positive.
438         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
439    
440      */
441    
442      ESCRIPT_DLL_API
443      virtual void
444      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
445    
446   protected:   protected:
447    
448    /**    /**
# Line 326  class DataAbstract { Line 452  class DataAbstract {
452       \param input - Input - The point data view. DataAbstract takes ownership       \param input - Input - The point data view. DataAbstract takes ownership
453       of the DataArrayView provided. It will delete it when it is destructed.       of the DataArrayView provided. It will delete it when it is destructed.
454    */    */
455      ESCRIPT_DLL_API
456    void    void
457    setPointDataView(const DataArrayView& input);    setPointDataView(const DataArrayView& input);
458    
459      ESCRIPT_DLL_API
460    void    void
461    resetPointDataView();    resetPointDataView();
462    
# Line 414  DataAbstract::getPointDataView() Line 542  DataAbstract::getPointDataView()
542  {  {
543    return *(m_pointDataView.get());    return *(m_pointDataView.get());
544  }  }
   
545  } // end of namespace  } // end of namespace
546    
547  #endif  #endif

Legend:
Removed from v.478  
changed lines
  Added in v.922

  ViewVC Help
Powered by ViewVC 1.1.26