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

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

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

revision 513 by jgs, Mon Feb 13 04:46:51 2006 UTC revision 950 by gross, Tue Feb 6 07:01:11 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2    
3  /*  /*
4   ******************************************************************************   ************************************************************
5   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
6   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
7   *                                                                            *   *              http://www.access.edu.au                    *
8   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
9   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
10   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
11   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
12   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
13  */  */
14    
15  #if !defined escript_DataTagged_20040615_H  #if !defined escript_DataTagged_20040615_H
16  #define escript_DataTagged_20040615_H  #define escript_DataTagged_20040615_H
17    #include "system_dep.h"
18    
19  #include "DataAbstract.h"  #include "DataAbstract.h"
20  #include "DataArrayView.h"  #include "DataArrayView.h"
# Line 62  class DataTagged : public DataAbstract { Line 61  class DataTagged : public DataAbstract {
61       tag values are stored.       tag values are stored.
62      T      T
63    */    */
64      ESCRIPT_DLL_API
65    DataTagged();    DataTagged();
66    
67    /**    /**
# Line 82  class DataTagged : public DataAbstract { Line 82  class DataTagged : public DataAbstract {
82       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
83      T      T
84    */    */
85      ESCRIPT_DLL_API
86    DataTagged(const TagListType& tagKeys,    DataTagged(const TagListType& tagKeys,
87               const ValueListType& values,               const ValueListType& values,
88           const DataArrayView& defaultValue,           const DataArrayView& defaultValue,
# Line 97  class DataTagged : public DataAbstract { Line 98  class DataTagged : public DataAbstract {
98       \param shape - Input - The shape of each data-point.       \param shape - Input - The shape of each data-point.
99       \param tags - Input - An array of tags, one for each sample number.       \param tags - Input - An array of tags, one for each sample number.
100       \param data - The data values for each tag.       \param data - The data values for each tag.
101        NB: no unit testing yet
102    */    */
103      ESCRIPT_DLL_API
104    DataTagged(const FunctionSpace& what,    DataTagged(const FunctionSpace& what,
105               const DataArrayView::ShapeType &shape,               const DataArrayView::ShapeType &shape,
106               const int tags[],               const int tags[],
# Line 105  class DataTagged : public DataAbstract { Line 108  class DataTagged : public DataAbstract {
108    
109    /**    /**
110       \brief       \brief
111         Alternative Constructor for DataTagged.
112    
113         Description:
114         Alternative Constructor for DataTagged.
115         \param what - Input - A description of what this data object represents.
116         \param shape - Input - The shape of each data-point.
117         \param tags - Input - An vector of tags, one for each sample number.
118         \param data - The data values for each tag.
119        NB: no unit testing yet
120      */
121      ESCRIPT_DLL_API
122      DataTagged(const FunctionSpace& what,
123                 const DataArrayView::ShapeType &shape,
124                 const TagListType& tags,
125                 const ValueType& data);
126    
127      /**
128         \brief
129       Copy Constructor for DataTagged.       Copy Constructor for DataTagged.
130       Performs a deep copy from the given DataTagged object.       Performs a deep copy from the given DataTagged object.
131      T      T
132    */    */
133      ESCRIPT_DLL_API
134    DataTagged(const DataTagged& other);    DataTagged(const DataTagged& other);
135    
136    /**    /**
# Line 118  class DataTagged : public DataAbstract { Line 140  class DataTagged : public DataAbstract {
140       The default value will be the value of the DataConstant object.       The default value will be the value of the DataConstant object.
141      T      T
142    */    */
143      ESCRIPT_DLL_API
144    DataTagged(const DataConstant& other);    DataTagged(const DataConstant& other);
145    
146    /**    /**
# Line 132  class DataTagged : public DataAbstract { Line 155  class DataTagged : public DataAbstract {
155       ** NB: need to do array bounds checking when accessing returned value!       ** NB: need to do array bounds checking when accessing returned value!
156      T      T
157    */    */
158      ESCRIPT_DLL_API
159    virtual    virtual
160    double*    double*
161    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
# Line 143  class DataTagged : public DataAbstract { Line 167  class DataTagged : public DataAbstract {
167       associated with each tag.       associated with each tag.
168      T      T
169    */    */
170      ESCRIPT_DLL_API
171    virtual    virtual
172    std::string    std::string
173    toString() const;    toString() const;
174     /**
175         \brief
176         dumps the object into a netCDF file
177      */
178      ESCRIPT_DLL_API
179      virtual
180      void
181      dump(const std::string fileName) const;
182    
183    /**    /**
184       \brief       \brief
# Line 153  class DataTagged : public DataAbstract { Line 186  class DataTagged : public DataAbstract {
186       according to the associated function space.       according to the associated function space.
187      T      T
188    */    */
189      ESCRIPT_DLL_API
190    virtual    virtual
191    int    int
192    getTagNumber(int dpno);    getTagNumber(int dpno);
# Line 169  class DataTagged : public DataAbstract { Line 203  class DataTagged : public DataAbstract {
203       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
204      T      T
205    */    */
206      ESCRIPT_DLL_API
207    virtual    virtual
208    ValueType::size_type    ValueType::size_type
209    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 190  class DataTagged : public DataAbstract { Line 225  class DataTagged : public DataAbstract {
225               will be generated.               will be generated.
226      T      T
227    */    */
228      ESCRIPT_DLL_API
229    void    void
230    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
231                    const ValueListType& values);                      const ValueListType& values);  
# Line 205  class DataTagged : public DataAbstract { Line 241  class DataTagged : public DataAbstract {
241       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
242      T      T
243    */    */
244      ESCRIPT_DLL_API
245    void    void
246    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
247                   const DataArrayView& value);                   const DataArrayView& value);
# Line 225  class DataTagged : public DataAbstract { Line 262  class DataTagged : public DataAbstract {
262               will be generated.               will be generated.
263      T      T
264    */    */
265      ESCRIPT_DLL_API
266    void    void
267    setTaggedValues(const TagListType& tagKeys,    setTaggedValues(const TagListType& tagKeys,
268                    const ValueListType& values);                    const ValueListType& values);
# Line 239  class DataTagged : public DataAbstract { Line 277  class DataTagged : public DataAbstract {
277       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
278      T      T
279    */    */
280      ESCRIPT_DLL_API
281    virtual    virtual
282    void    void
283    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 253  class DataTagged : public DataAbstract { Line 292  class DataTagged : public DataAbstract {
292       \param tag - Input - Integer key.       \param tag - Input - Integer key.
293      T      T
294    */    */
295      ESCRIPT_DLL_API
296    DataArrayView    DataArrayView
297    getDataPointByTag(int tag) const;    getDataPointByTag(int tag) const;
298    
# Line 267  class DataTagged : public DataAbstract { Line 307  class DataTagged : public DataAbstract {
307       \param dataPointNo - Input.       \param dataPointNo - Input.
308      T      T
309    */    */
310      ESCRIPT_DLL_API
311    virtual    virtual
312    DataArrayView    DataArrayView
313    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
# Line 280  class DataTagged : public DataAbstract { Line 321  class DataTagged : public DataAbstract {
321       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
322      T      T
323    */    */
324      ESCRIPT_DLL_API
325    const DataMapType&    const DataMapType&
326    getTagLookup() const;    getTagLookup() const;
327    
# Line 294  class DataTagged : public DataAbstract { Line 336  class DataTagged : public DataAbstract {
336       keys in the associated function space.       keys in the associated function space.
337      T      T
338    */    */
339      ESCRIPT_DLL_API
340    bool    bool
341    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
342    
# Line 306  class DataTagged : public DataAbstract { Line 349  class DataTagged : public DataAbstract {
349       is not explicitly recorded in this DataTagged object's tag map.       is not explicitly recorded in this DataTagged object's tag map.
350      T      T
351    */    */
352      ESCRIPT_DLL_API
353    DataArrayView&    DataArrayView&
354    getDefaultValue();    getDefaultValue();
355    
356      ESCRIPT_DLL_API
357    const DataArrayView&    const DataArrayView&
358    getDefaultValue() const;    getDefaultValue() const;
359    
# Line 320  class DataTagged : public DataAbstract { Line 365  class DataTagged : public DataAbstract {
365       Return the total number of doubles stored for this DataTagged object.       Return the total number of doubles stored for this DataTagged object.
366      T      T
367    */    */
368      ESCRIPT_DLL_API
369    virtual    virtual
370    ValueType::size_type    ValueType::size_type
371    getLength() const;    getLength() const;
# Line 332  class DataTagged : public DataAbstract { Line 378  class DataTagged : public DataAbstract {
378       Factory method that returns a newly created DataTagged object generated       Factory method that returns a newly created DataTagged object generated
379       by taking the specified slice from this DataTagged object.       by taking the specified slice from this DataTagged object.
380       The caller is reponsible for managing the returned object.       The caller is reponsible for managing the returned object.
381        T
382    */    */
383      ESCRIPT_DLL_API
384    virtual    virtual
385    DataAbstract*    DataAbstract*
386    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 342  class DataTagged : public DataAbstract { Line 390  class DataTagged : public DataAbstract {
390       Slice Constructor for DataTagged.       Slice Constructor for DataTagged.
391    
392       Description:       Description:
      Slice Constructor for DataTagged.  
393       Creates a DataTagged object which is the specified slice       Creates a DataTagged object which is the specified slice
394       from another DataTagged object.       from the given DataTagged object.
395       \param other - Input - DataTagged object to copy from.       \param other - Input - DataTagged object to slice from.
396       \param region - Input - Region to copy.       \param region - Input - Region to slice.
397        T
398    */    */
399      ESCRIPT_DLL_API
400    DataTagged(const DataTagged& other,    DataTagged(const DataTagged& other,
401           const DataArrayView::RegionType& region);           const DataArrayView::RegionType& region);
402    
# Line 356  class DataTagged : public DataAbstract { Line 405  class DataTagged : public DataAbstract {
405       setSlice       setSlice
406    
407       Description:       Description:
408       Copy the specified region from the given Data object into this object.       Copy the given Data object into the specified region in this object.
409       \param other - Input - Data object to copy from.       \param other - Input - Data object to copy from.
410       \param region - Input - Region to copy (NB: must have same shape as this!).       \param region - Input - Region to copy into (NB: must have same shape as other!).
411        T
412    */    */
413      ESCRIPT_DLL_API
414    virtual    virtual
415    void    void
416    setSlice(const DataAbstract* other,    setSlice(const DataAbstract* other,
# Line 367  class DataTagged : public DataAbstract { Line 418  class DataTagged : public DataAbstract {
418    
419    /**    /**
420       \brief       \brief
      reshapeDataPoint  
   
      Description:  
      Reshape each data-point in this object to the given shape, only  
      if current data-points are scalars. An exception is thrown if  
      the current data-points have rank other than 0.  
      The original values of the data-points are used for all values  
      of the new data-points.  
     T  
   */  
   void  
   reshapeDataPoint(const DataArrayView::ShapeType& shape);  
   
   /**  
      \brief  
421       Archive the underlying data values to the file referenced       Archive the underlying data values to the file referenced
422       by ofstream. A count of the number of values expected to be written       by ofstream. A count of the number of values expected to be written
423       is provided as a cross-check.       is provided as a cross-check.
424    
425       The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
426    */    */
427      ESCRIPT_DLL_API
428    int    int
429    archiveData(std::ofstream& archiveFile,    archiveData(std::ofstream& archiveFile,
430                const DataArrayView::ValueType::size_type noValues) const;                const DataArrayView::ValueType::size_type noValues) const;
# Line 399  class DataTagged : public DataAbstract { Line 436  class DataTagged : public DataAbstract {
436    
437       The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
438    */    */
439      ESCRIPT_DLL_API
440    int    int
441    extractData(std::ifstream& archiveFile,    extractData(std::ifstream& archiveFile,
442                const DataArrayView::ValueType::size_type noValues);                const DataArrayView::ValueType::size_type noValues);
443    
444      /**
445         \brief
446         Computes a symmetric matrix (A + AT) / 2
447    
448         \param ev - Output - symmetric matrix
449    
450      */
451      ESCRIPT_DLL_API
452      virtual void
453      symmetric(DataAbstract* ev);
454    
455      /**
456         \brief
457         Computes a nonsymmetric matrix (A - AT) / 2
458    
459         \param ev - Output - nonsymmetric matrix
460    
461      */
462      ESCRIPT_DLL_API
463      virtual void
464      nonsymmetric(DataAbstract* ev);
465    
466      /**
467         \brief
468         Computes the trace of a matrix
469    
470         \param ev - Output - the trace of a matrix
471    
472      */
473      ESCRIPT_DLL_API
474      virtual void
475      trace(DataAbstract* ev, int axis_offset);
476    
477      /**
478         \brief
479         swaps components axis0 and axis1
480    
481         \param ev - Output - swapped components
482    
483      */
484      ESCRIPT_DLL_API
485      virtual void
486      swapaxes(DataAbstract* ev, int axis0, int axis1);
487    
488      /**
489         \brief
490         Transpose each data point of this Data object around the given axis.
491    
492         \param ev - Output - the transpose of a matrix
493    
494      */
495      ESCRIPT_DLL_API
496      virtual void
497      transpose(DataAbstract* ev, int axis_offset);
498    
499      /**
500         \brief
501         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
502    
503         \param ev - Output - eigenvalues in increasing order at each data point
504    
505      */
506      ESCRIPT_DLL_API
507      virtual void
508      eigenvalues(DataAbstract* ev);
509    
510      /**
511         \brief
512         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
513    
514         \param ev - Output - eigenvalues in increasing order at each data point
515         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
516                             and the first nonzero component is positive.
517         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
518    
519      */
520    
521      ESCRIPT_DLL_API
522      virtual void
523      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
524    
525    
526   protected:   protected:
527    
528   private:   private:

Legend:
Removed from v.513  
changed lines
  Added in v.950

  ViewVC Help
Powered by ViewVC 1.1.26