/[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 535 by jgs, Fri Feb 17 02:27:06 2006 UTC revision 984 by gross, Tue Feb 20 03:33:45 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 99  class DataTagged : public DataAbstract { Line 100  class DataTagged : public DataAbstract {
100       \param data - The data values for each tag.       \param data - The data values for each tag.
101      NB: no unit testing yet      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 106  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 119  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 133  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 144  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 154  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 170  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 191  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 206  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 226  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 240  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 254  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 268  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,
314                 int dataPointNo);                 int dataPointNo);
315    
316    /**    /**
317         \brief
318         getData
319    
320         Description:
321         Return pointer to the data
322        T
323      */
324      ESCRIPT_DLL_API
325      const DataArrayView::ValueType::ElementType*
326      getData() const;
327    
328      /**
329       \brief       \brief
330       getTagLookup       getTagLookup
331    
# Line 281  class DataTagged : public DataAbstract { Line 333  class DataTagged : public DataAbstract {
333       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
334      T      T
335    */    */
336      ESCRIPT_DLL_API
337    const DataMapType&    const DataMapType&
338    getTagLookup() const;    getTagLookup() const;
339    
# Line 295  class DataTagged : public DataAbstract { Line 348  class DataTagged : public DataAbstract {
348       keys in the associated function space.       keys in the associated function space.
349      T      T
350    */    */
351      ESCRIPT_DLL_API
352    bool    bool
353    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
354    
# Line 307  class DataTagged : public DataAbstract { Line 361  class DataTagged : public DataAbstract {
361       is not explicitly recorded in this DataTagged object's tag map.       is not explicitly recorded in this DataTagged object's tag map.
362      T      T
363    */    */
364      ESCRIPT_DLL_API
365    DataArrayView&    DataArrayView&
366    getDefaultValue();    getDefaultValue();
367    
368      ESCRIPT_DLL_API
369    const DataArrayView&    const DataArrayView&
370    getDefaultValue() const;    getDefaultValue() const;
371    
# Line 321  class DataTagged : public DataAbstract { Line 377  class DataTagged : public DataAbstract {
377       Return the total number of doubles stored for this DataTagged object.       Return the total number of doubles stored for this DataTagged object.
378      T      T
379    */    */
380      ESCRIPT_DLL_API
381    virtual    virtual
382    ValueType::size_type    ValueType::size_type
383    getLength() const;    getLength() const;
# Line 335  class DataTagged : public DataAbstract { Line 392  class DataTagged : public DataAbstract {
392       The caller is reponsible for managing the returned object.       The caller is reponsible for managing the returned object.
393      T      T
394    */    */
395      ESCRIPT_DLL_API
396    virtual    virtual
397    DataAbstract*    DataAbstract*
398    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 350  class DataTagged : public DataAbstract { Line 408  class DataTagged : public DataAbstract {
408       \param region - Input - Region to slice.       \param region - Input - Region to slice.
409      T      T
410    */    */
411      ESCRIPT_DLL_API
412    DataTagged(const DataTagged& other,    DataTagged(const DataTagged& other,
413           const DataArrayView::RegionType& region);           const DataArrayView::RegionType& region);
414    
# Line 363  class DataTagged : public DataAbstract { Line 422  class DataTagged : public DataAbstract {
422       \param region - Input - Region to copy into (NB: must have same shape as other!).       \param region - Input - Region to copy into (NB: must have same shape as other!).
423      T      T
424    */    */
425      ESCRIPT_DLL_API
426    virtual    virtual
427    void    void
428    setSlice(const DataAbstract* other,    setSlice(const DataAbstract* other,
# Line 370  class DataTagged : public DataAbstract { Line 430  class DataTagged : public DataAbstract {
430    
431    /**    /**
432       \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  
433       Archive the underlying data values to the file referenced       Archive the underlying data values to the file referenced
434       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
435       is provided as a cross-check.       is provided as a cross-check.
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    archiveData(std::ofstream& archiveFile,    archiveData(std::ofstream& archiveFile,
442                const DataArrayView::ValueType::size_type noValues) const;                const DataArrayView::ValueType::size_type noValues) const;
# Line 402  class DataTagged : public DataAbstract { Line 448  class DataTagged : public DataAbstract {
448    
449       The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
450    */    */
451      ESCRIPT_DLL_API
452    int    int
453    extractData(std::ifstream& archiveFile,    extractData(std::ifstream& archiveFile,
454                const DataArrayView::ValueType::size_type noValues);                const DataArrayView::ValueType::size_type noValues);
455    
456      /**
457         \brief
458         Computes a symmetric matrix (A + AT) / 2
459    
460         \param ev - Output - symmetric matrix
461    
462      */
463      ESCRIPT_DLL_API
464      virtual void
465      symmetric(DataAbstract* ev);
466    
467      /**
468         \brief
469         Computes a nonsymmetric matrix (A - AT) / 2
470    
471         \param ev - Output - nonsymmetric matrix
472    
473      */
474      ESCRIPT_DLL_API
475      virtual void
476      nonsymmetric(DataAbstract* ev);
477    
478      /**
479         \brief
480         Computes the trace of a matrix
481    
482         \param ev - Output - the trace of a matrix
483    
484      */
485      ESCRIPT_DLL_API
486      virtual void
487      trace(DataAbstract* ev, int axis_offset);
488    
489      /**
490         \brief
491         swaps components axis0 and axis1
492    
493         \param ev - Output - swapped components
494    
495      */
496      ESCRIPT_DLL_API
497      virtual void
498      swapaxes(DataAbstract* ev, int axis0, int axis1);
499    
500      /**
501         \brief
502         Transpose each data point of this Data object around the given axis.
503    
504         \param ev - Output - the transpose of a matrix
505    
506      */
507      ESCRIPT_DLL_API
508      virtual void
509      transpose(DataAbstract* ev, int axis_offset);
510    
511      /**
512         \brief
513         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
514    
515         \param ev - Output - eigenvalues in increasing order at each data point
516    
517      */
518      ESCRIPT_DLL_API
519      virtual void
520      eigenvalues(DataAbstract* ev);
521    
522      /**
523         \brief
524         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
525    
526         \param ev - Output - eigenvalues in increasing order at each data point
527         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
528                             and the first nonzero component is positive.
529         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
530    
531      */
532    
533      ESCRIPT_DLL_API
534      virtual void
535      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
536    
537    
538   protected:   protected:
539    
540   private:   private:
# Line 449  DataTagged::getDefaultValue() const Line 578  DataTagged::getDefaultValue() const
578  }  }
579    
580  inline  inline
581    const DataArrayView::ValueType::ElementType*
582    DataTagged::getData() const
583    {
584       return &(m_data[0]);
585    }
586    
587    inline
588  const DataTagged::DataMapType&  const DataTagged::DataMapType&
589  DataTagged::getTagLookup() const  DataTagged::getTagLookup() const
590  {  {

Legend:
Removed from v.535  
changed lines
  Added in v.984

  ViewVC Help
Powered by ViewVC 1.1.26