/[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 1118 by gross, Tue Apr 24 08:55:04 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
185        sets all values to zero
186      */
187      ESCRIPT_DLL_API
188      virtual
189      void
190      setToZero();
191    
192    /**    /**
193       \brief       \brief
# Line 153  class DataTagged : public DataAbstract { Line 195  class DataTagged : public DataAbstract {
195       according to the associated function space.       according to the associated function space.
196      T      T
197    */    */
198      ESCRIPT_DLL_API
199    virtual    virtual
200    int    int
201    getTagNumber(int dpno);    getTagNumber(int dpno);
# Line 169  class DataTagged : public DataAbstract { Line 212  class DataTagged : public DataAbstract {
212       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
213      T      T
214    */    */
215      ESCRIPT_DLL_API
216    virtual    virtual
217    ValueType::size_type    ValueType::size_type
218    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 190  class DataTagged : public DataAbstract { Line 234  class DataTagged : public DataAbstract {
234               will be generated.               will be generated.
235      T      T
236    */    */
237      ESCRIPT_DLL_API
238    void    void
239    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
240                    const ValueListType& values);                      const ValueListType& values);  
# Line 205  class DataTagged : public DataAbstract { Line 250  class DataTagged : public DataAbstract {
250       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
251      T      T
252    */    */
253      ESCRIPT_DLL_API
254    void    void
255    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
256                   const DataArrayView& value);                   const DataArrayView& value);
# Line 225  class DataTagged : public DataAbstract { Line 271  class DataTagged : public DataAbstract {
271               will be generated.               will be generated.
272      T      T
273    */    */
274      ESCRIPT_DLL_API
275    void    void
276    setTaggedValues(const TagListType& tagKeys,    setTaggedValues(const TagListType& tagKeys,
277                    const ValueListType& values);                    const ValueListType& values);
# Line 239  class DataTagged : public DataAbstract { Line 286  class DataTagged : public DataAbstract {
286       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
287      T      T
288    */    */
289      ESCRIPT_DLL_API
290    virtual    virtual
291    void    void
292    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 253  class DataTagged : public DataAbstract { Line 301  class DataTagged : public DataAbstract {
301       \param tag - Input - Integer key.       \param tag - Input - Integer key.
302      T      T
303    */    */
304      ESCRIPT_DLL_API
305    DataArrayView    DataArrayView
306    getDataPointByTag(int tag) const;    getDataPointByTag(int tag) const;
307    
# Line 267  class DataTagged : public DataAbstract { Line 316  class DataTagged : public DataAbstract {
316       \param dataPointNo - Input.       \param dataPointNo - Input.
317      T      T
318    */    */
319      ESCRIPT_DLL_API
320    virtual    virtual
321    DataArrayView    DataArrayView
322    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
323                 int dataPointNo);                 int dataPointNo);
324    
325    /**    /**
326         \brief
327         getData
328    
329         Description:
330         Return pointer to the data
331        T
332      */
333      ESCRIPT_DLL_API
334      const DataArrayView::ValueType::ElementType*
335      getData() const;
336    
337      /**
338       \brief       \brief
339       getTagLookup       getTagLookup
340    
# Line 280  class DataTagged : public DataAbstract { Line 342  class DataTagged : public DataAbstract {
342       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
343      T      T
344    */    */
345      ESCRIPT_DLL_API
346    const DataMapType&    const DataMapType&
347    getTagLookup() const;    getTagLookup() const;
348    
# Line 294  class DataTagged : public DataAbstract { Line 357  class DataTagged : public DataAbstract {
357       keys in the associated function space.       keys in the associated function space.
358      T      T
359    */    */
360      ESCRIPT_DLL_API
361    bool    bool
362    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
363    
# Line 306  class DataTagged : public DataAbstract { Line 370  class DataTagged : public DataAbstract {
370       is not explicitly recorded in this DataTagged object's tag map.       is not explicitly recorded in this DataTagged object's tag map.
371      T      T
372    */    */
373      ESCRIPT_DLL_API
374    DataArrayView&    DataArrayView&
375    getDefaultValue();    getDefaultValue();
376    
377      ESCRIPT_DLL_API
378    const DataArrayView&    const DataArrayView&
379    getDefaultValue() const;    getDefaultValue() const;
380    
# Line 320  class DataTagged : public DataAbstract { Line 386  class DataTagged : public DataAbstract {
386       Return the total number of doubles stored for this DataTagged object.       Return the total number of doubles stored for this DataTagged object.
387      T      T
388    */    */
389      ESCRIPT_DLL_API
390    virtual    virtual
391    ValueType::size_type    ValueType::size_type
392    getLength() const;    getLength() const;
# Line 332  class DataTagged : public DataAbstract { Line 399  class DataTagged : public DataAbstract {
399       Factory method that returns a newly created DataTagged object generated       Factory method that returns a newly created DataTagged object generated
400       by taking the specified slice from this DataTagged object.       by taking the specified slice from this DataTagged object.
401       The caller is reponsible for managing the returned object.       The caller is reponsible for managing the returned object.
402        T
403    */    */
404      ESCRIPT_DLL_API
405    virtual    virtual
406    DataAbstract*    DataAbstract*
407    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 342  class DataTagged : public DataAbstract { Line 411  class DataTagged : public DataAbstract {
411       Slice Constructor for DataTagged.       Slice Constructor for DataTagged.
412    
413       Description:       Description:
      Slice Constructor for DataTagged.  
414       Creates a DataTagged object which is the specified slice       Creates a DataTagged object which is the specified slice
415       from another DataTagged object.       from the given DataTagged object.
416       \param other - Input - DataTagged object to copy from.       \param other - Input - DataTagged object to slice from.
417       \param region - Input - Region to copy.       \param region - Input - Region to slice.
418        T
419    */    */
420      ESCRIPT_DLL_API
421    DataTagged(const DataTagged& other,    DataTagged(const DataTagged& other,
422           const DataArrayView::RegionType& region);           const DataArrayView::RegionType& region);
423    
# Line 356  class DataTagged : public DataAbstract { Line 426  class DataTagged : public DataAbstract {
426       setSlice       setSlice
427    
428       Description:       Description:
429       Copy the specified region from the given Data object into this object.       Copy the given Data object into the specified region in this object.
430       \param other - Input - Data object to copy from.       \param other - Input - Data object to copy from.
431       \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!).
432        T
433    */    */
434      ESCRIPT_DLL_API
435    virtual    virtual
436    void    void
437    setSlice(const DataAbstract* other,    setSlice(const DataAbstract* other,
# Line 367  class DataTagged : public DataAbstract { Line 439  class DataTagged : public DataAbstract {
439    
440    /**    /**
441       \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  
442       Archive the underlying data values to the file referenced       Archive the underlying data values to the file referenced
443       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
444       is provided as a cross-check.       is provided as a cross-check.
445    
446       The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
447    */    */
448      ESCRIPT_DLL_API
449    int    int
450    archiveData(std::ofstream& archiveFile,    archiveData(std::ofstream& archiveFile,
451                const DataArrayView::ValueType::size_type noValues) const;                const DataArrayView::ValueType::size_type noValues) const;
# Line 399  class DataTagged : public DataAbstract { Line 457  class DataTagged : public DataAbstract {
457    
458       The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
459    */    */
460      ESCRIPT_DLL_API
461    int    int
462    extractData(std::ifstream& archiveFile,    extractData(std::ifstream& archiveFile,
463                const DataArrayView::ValueType::size_type noValues);                const DataArrayView::ValueType::size_type noValues);
464    
465      /**
466         \brief
467         Computes a symmetric matrix (A + AT) / 2
468    
469         \param ev - Output - symmetric matrix
470    
471      */
472      ESCRIPT_DLL_API
473      virtual void
474      symmetric(DataAbstract* ev);
475    
476      /**
477         \brief
478         Computes a nonsymmetric matrix (A - AT) / 2
479    
480         \param ev - Output - nonsymmetric matrix
481    
482      */
483      ESCRIPT_DLL_API
484      virtual void
485      nonsymmetric(DataAbstract* ev);
486    
487      /**
488         \brief
489         Computes the trace of a matrix
490    
491         \param ev - Output - the trace of a matrix
492    
493      */
494      ESCRIPT_DLL_API
495      virtual void
496      trace(DataAbstract* ev, int axis_offset);
497    
498      /**
499         \brief
500         swaps components axis0 and axis1
501    
502         \param ev - Output - swapped components
503    
504      */
505      ESCRIPT_DLL_API
506      virtual void
507      swapaxes(DataAbstract* ev, int axis0, int axis1);
508    
509      /**
510         \brief
511         Transpose each data point of this Data object around the given axis.
512    
513         \param ev - Output - the transpose of a matrix
514    
515      */
516      ESCRIPT_DLL_API
517      virtual void
518      transpose(DataAbstract* ev, int axis_offset);
519    
520      /**
521         \brief
522         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
523    
524         \param ev - Output - eigenvalues in increasing order at each data point
525    
526      */
527      ESCRIPT_DLL_API
528      virtual void
529      eigenvalues(DataAbstract* ev);
530    
531      /**
532         \brief
533         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
534    
535         \param ev - Output - eigenvalues in increasing order at each data point
536         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
537                             and the first nonzero component is positive.
538         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
539    
540      */
541    
542      ESCRIPT_DLL_API
543      virtual void
544      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
545    
546    
547   protected:   protected:
548    
549   private:   private:
# Line 446  DataTagged::getDefaultValue() const Line 587  DataTagged::getDefaultValue() const
587  }  }
588    
589  inline  inline
590    const DataArrayView::ValueType::ElementType*
591    DataTagged::getData() const
592    {
593       return &(m_data[0]);
594    }
595    
596    inline
597  const DataTagged::DataMapType&  const DataTagged::DataMapType&
598  DataTagged::getTagLookup() const  DataTagged::getTagLookup() const
599  {  {

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

  ViewVC Help
Powered by ViewVC 1.1.26