/[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

trunk/esys2/escript/src/Data/DataTagged.h revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataTagged.h revision 1796 by jfenwick, Wed Sep 17 01:45:46 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_DataTagged_20040615_H  #if !defined escript_DataTagged_20040615_H
17  #define escript_DataTagged_20040615_H  #define escript_DataTagged_20040615_H
18    #include "system_dep.h"
19    
20  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
21  #include "escript/Data/DataArray.h"  #include "DataTypes.h"
 #include "escript/Data/DataArrayView.h"  
22    
23  #include <vector>  #include <vector>
24  #include <map>  #include <map>
# Line 29  class DataConstant; Line 29  class DataConstant;
29    
30  /**  /**
31     \brief     \brief
32     Creates the illusion of a full dataset accessible via sampleNo and dataPointNo.     Simulates a full dataset accessible via sampleNo and dataPointNo.
33    
34     Description:     Description:
35     Creates the illusion of a full dataset accessible via sampleNo and     Each data-point has an associated tag number, and a given tag can represent a
36     dataPointNo. In reality a much smaller number of data-points is stored.     range of dataPointNo and sampleNo. Each tag indexes only a single data-point.
    Each data-point has an associated key, thus a given key represents a specific  
    range of dataPointNo and sampleNo. Each key indexes a single data-point.  
37     Thus only a single data-point needs to be stored for a range of sampleNo and     Thus only a single data-point needs to be stored for a range of sampleNo and
38     dataPointNo values.     dataPointNo values.
39  */  */
# Line 44  class DataTagged : public DataAbstract { Line 42  class DataTagged : public DataAbstract {
42    
43   public:   public:
44    
45    typedef std::vector<int> TagListType;    //
46    typedef std::vector<DataArrayView> ValueListType;    // Types for the lists of tags and values.
47      typedef std::vector<int>           TagListType;
48    //  typedef std::vector<DataArrayView> ValueListType;
49      typedef DataTypes::ValueType   ValueType;
50      typedef std::vector<ValueType::ElementType> ValueBatchType;
51    
52    //    //
53    // Map type, maps the key to an array offset.    // Map from a tag to an offset into the data array.
54    typedef std::map<int, int> DataMapType;    typedef std::map<int, int> DataMapType;
55    
56    /**    /**
# Line 57  class DataTagged : public DataAbstract { Line 59  class DataTagged : public DataAbstract {
59    
60       Description:       Description:
61       Default constructor for DataTagged. Creates a DataTagged object for which       Default constructor for DataTagged. Creates a DataTagged object for which
62       the default data-point is a scalar data-point with value 0.0. Any given tag       the default data-point is a scalar data-point with value 0.0, and no other
63       will map to this data-point.       tag values are stored.
64        T
65    */    */
66      ESCRIPT_DLL_API
67    DataTagged();    DataTagged();
68    
69    //  /**
70    //      \brief
71    //      Constructor for DataTagged.
72    //
73    //      Description:
74    //      Constructor for DataTagged.
75    //      \param tagKeys - Input - A vector of integer tags.
76    //      \param values - Input - A vector of DataArrayViews. If this is empty
77    //                      all tag values will be assigned a scalar data-point of value
78    //                      0. If it contains one value all tag values will be assigned
79    //           this value. Otherwise consecutive tags will be assigned
80    //                      consecutive values.  If there is a mismatch between  the
81    //           number of keys and the number of values an exception
82    //           will be generated.
83    //      \param defaultValue - Input - Value returned if a requested tag doesn't exist.
84    //      \param what - Input - A description of what this data represents.
85    //     T
86    //  */
87    //   ESCRIPT_DLL_API
88    //   DataTagged(const TagListType& tagKeys,
89    //              const ValueListType& values,
90    //       const DataArrayView& defaultValue,
91    //       const FunctionSpace& what);
92    
93    /**    /**
94       \brief       \brief
95       Constructor for DataTagged.       Alternative Constructor for DataTagged.
96    
97         Description:
98         Alternative Constructor for DataTagged.
99         \param what - Input - A description of what this data object represents.
100         \param shape - Input - The shape of each data-point.
101         \param tags - Input - An array of tags, one for each sample number (starts at tag[1]).
102         \param data - The data values for each tag.
103        NB: no unit testing yet
104      */
105      ESCRIPT_DLL_API
106      DataTagged(const FunctionSpace& what,
107                 const DataTypes::ShapeType &shape,
108                 const int tags[],
109                 const ValueType& data);
110    
111     /**
112         \brief
113         Alternative Constructor for DataTagged.
114    
115         Description:
116         Alternative Constructor for DataTagged.
117         \param what - Input - A description of what this data object represents.
118         \param shape - Input - The shape of each data-point.
119         \param tags - Input - An vector of tags, one for each sample number.
120         \param data - The data values for each tag.
121    TODO Make sure to document the relationship between tags and data, ie: data also contains the default value
122     */
123      ESCRIPT_DLL_API
124      DataTagged(const FunctionSpace& what,
125                 const DataTypes::ShapeType &shape,
126                 const TagListType& tags,
127                 const ValueType& data);
128    
129       Description:    /**
130       Constructor for DataTagged.       \brief
131       \param tagKeys - Input - A vector of integer keys.       Copy Constructor for DataTagged.
132       \param values - Input - A vector of DataArrayViews. If this is empty       Performs a deep copy from the given DataTagged object.
133                     all tag values will be assigned a value of zero. If      T
                    it contains one value all tag values will be assigned the  
            same value. Otherwise if there is a mismatch between  
            the number of keys and the number of values an exception  
            will be generated.  
      \param defaultValue - Input - Value returned if a requested tag doesn't exist.  
      \param what - Input - A description of what this data represents.  
134    */    */
135    DataTagged(const TagListType& tagKeys,    ESCRIPT_DLL_API
136               const ValueListType& values,    DataTagged(const DataTagged& other);
          const DataArrayView& defaultValue,  
          const FunctionSpace& what);  
137    
138    /**    /**
139       \brief       \brief
140       Slice constructor for DataTagged.       Copy Constructor for DataTagged.
141         Construct a DataTagged object from a DataConstant object.
142       Description:       The default value will be the value of the DataConstant object.
143       Slice constructor for DataTagged.      T
      Copies a slice from another DataTagged object.  
      \param other - Input - DataTagged object to copy from.  
      \param region - Input - region to copy.  
144    */    */
145    DataTagged(const DataTagged& other,    ESCRIPT_DLL_API
146           const DataArrayView::RegionType& region);    DataTagged(const DataConstant& other);
147    
148    /**    /**
149       \brief       \brief
150       Copy constructorfor DataTagged.       Copies the tags from a DataTagged into a new Data Tagged and assigns them the default value. ** Not unit tested **
151       Performs a deep copy from the given DataTagged object.  
152         This is different from a deep copy because we are not copying shape or other information, just tags.
153         \param what - Input - FunctionSpace for the new DataTagged
154         \param shape - Input - Shape for points in the new DataTagged
155         \param defaultvalue - Input - Default value for new DataTagged
156         \param tagsource - Input - A DataTagged object which supplies the tags.
157    */    */
158    DataTagged(const DataTagged& other);    ESCRIPT_DLL_API
159      DataTagged(const FunctionSpace& what,
160                 const DataTypes::ShapeType& shape,
161             const DataTypes::ValueType& defaultvalue,
162                 const DataTagged* tagsource=0);
163    
164    /**    /**
165       \brief       \brief
166       Construct a tagged data from a DataConstant object.       Destructor
      The default data-point will be that held by the DataConstant object.  
167    */    */
168    DataTagged(const DataConstant& other);    ESCRIPT_DLL_API
169      inline virtual
170      ~DataTagged() {};
171    
172    /**    /**
173       \brief       \brief
174       getSampleDataByTag       getSampleDataByTag
175    
176       Description:       Description:
177       Return the data-point for the given tag. All of the data for the entire       Return the data-point for the given tag. All of the data for the
178       sample should be visable via the returned pointer. This provides an       sample will be visible via the returned pointer.
179       interface into the data suitable for legacy C code.  
180         ** This provides an interface into the data suitable for legacy C code.
181         ** NB: need to do array bounds checking when accessing returned value!
182        T
183    */    */
184      ESCRIPT_DLL_API
185    virtual    virtual
186    double*    double*
187    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
# Line 128  class DataTagged : public DataAbstract { Line 191  class DataTagged : public DataAbstract {
191       Write the data as a string.       Write the data as a string.
192       Writes out each tag, including the default, and the data-point which is       Writes out each tag, including the default, and the data-point which is
193       associated with each tag.       associated with each tag.
194        T
195    */    */
196      ESCRIPT_DLL_API
197    virtual    virtual
198    std::string    std::string
199    toString() const;    toString() const;
200     /**
201         \brief
202         dumps the object into a netCDF file
203      */
204      ESCRIPT_DLL_API
205      virtual
206      void
207      dump(const std::string fileName) const;
208    
209     /**
210         \brief
211        sets all values to zero
212      */
213      ESCRIPT_DLL_API
214      virtual
215      void
216      setToZero();
217    
218      /**
219         \brief
220         Return the tag number associated with the given data-point number
221         according to the associated function space.
222        T
223      */
224      ESCRIPT_DLL_API
225      virtual
226      int
227      getTagNumber(int dpno);
228    
229    /**    /**
230       \brief       \brief
231       getPointOffset       getPointOffset
232    
233       Description:       Description:
234       Return the offset to the given data-point. This is somewhat artificial,       Return the offset to the given data-point value in the underlying
235       but returns the offset for the given point in the DataTagged object.       data vector.
      Only really necessary to avoid many DataArrayView objects.  
236    
237       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
238       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
239     */      T
240      */
241      ESCRIPT_DLL_API
242    virtual    virtual
243    DataArrayView::ValueType::size_type    ValueType::size_type
244    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
245                   int dataPointNo) const;                   int dataPointNo) const;
246    
247    /**  
248    
249    //  /**
250    //      \brief
251    //      addTaggedValues
252    //
253    //      Description:
254    //      Add the given tags and values to this DataTagged object.
255    //      \param tagKeys - Input - A vector of integer tags.
256    //      \param values - Input - A vector of DataArrayViews. If this is empty
257    //                      all tag values will be assigned a scalar data-point of value
258    //                      0. If it contains one value all tag values will be assigned
259    //           this value. Otherwise consecutive tags will be assigned
260    //                      consecutive values.  If there is a mismatch between  the
261    //           number of keys and the number of values an exception
262    //           will be generated.
263    //     T
264    //  */
265    //   ESCRIPT_DLL_API
266    //   void
267    //   addTaggedValues(const TagListType& tagKeys,
268    //                   const ValueListType& values);  
269    
270    //  /**
271    //      \brief
272    //      addTaggedValue
273    //
274    //      Description:
275    //      Add a single tag and value to this DataTagged object. If this tag already has
276    //      a value associated with it, setTaggedValue will be used to update this value.
277    //      \param tagKey - Input - Integer tag.
278    //      \param value - Input - Single DataArrayView value to be assigned to the tag.
279    //     T
280     // */
281    //   ESCRIPT_DLL_API
282    //   void
283    //   addTaggedValue(int tagKey,
284    //                  const DataArrayView& value);
285    
286    
287    
288     /**
289       \brief       \brief
290       addTaggedValues       addTaggedValues
291    
292       Description:       Description:
293       Add the given tags and values to this DataTagged object.       Add the given tags and values to this DataTagged object.
294       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tags.
295       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of doubles. If this is empty, the default value for
296                     then all given tags will be assigned a value of zero. If                       this DataTagged will be used for all tags.
297                     it contains one value all tags will be assigned the same value.                       If it contains one value all tag values will be assigned
298                     Otherwise if there is a mismatch between the number of tags and               this value. Otherwise consecutive tags will be assigned
299                     the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
300       NB: If a tag given here already exists in this object, this attempt to add the given               number of keys and the number of values an exception
301       value will have no effect. setTaggedValues is more versatile and should be               will be generated.
302       used in most cases in preference to addTaggedValues.       \param vShape - shape of the datapoints in "values"
303        T
304     */
305      ESCRIPT_DLL_API
306      void
307      addTaggedValues(const TagListType& tagKeys,
308                                const ValueBatchType& values,
309                                const ShapeType& vShape);
310    
311    
312      /**
313       Description:
314       Add the given tags and values to this DataTagged object.
315       \param tagKeys - Input - A vector of integer tags.
316       \param values - Input - A DataVector containing the datapoints.
317                 If this is empty, the default value for
318                         this DataTagged will be used for all tags.
319                         If it contains one value all tag values will be assigned
320                 this value. Otherwise consecutive tags will be assigned
321                         consecutive values.  If there is a mismatch between  the
322                 number of keys and the number of values an exception
323                 will be generated.
324        \param vShape - shape of the datapoints in "values"
325    
326       TODO Makesure this is properly unit tested
327    */    */
328      ESCRIPT_DLL_API
329    void    void
330    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
331                    const ValueListType& values);                                const ValueType& values,
332                                const ShapeType& vShape);
333    
334    
335    
336    
337    /**    /**
338       \brief       \brief
339       addTaggedValue       addTaggedValue
340    
341       Description:       Description:
342       Add a single tag and value to this DataTagged object.       Add a single tag and value to this DataTagged object. If this tag already has
343       \param tagKey - Input - Integer key.       a value associated with it, setTaggedValue will be used to update this value.
344       \param value - Input - DataArrayView.       \param tagKey - Input - Integer tag.
345       NB: If this tag already exists in this object, this attempt to add the given       \param pointshape - Shape of the value parameter
346       value will have no effect. setTaggedValue is more versatile and should be       \param value - Input - Single DataArrayView value to be assigned to the tag.
347       used in most cases in preference to addTaggedValue.       \param dataOffset - Input - Offset of the beginning of the point in the value parameter
348    */    */
349      ESCRIPT_DLL_API
350    void    void
351    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
352                   const DataArrayView& value);           const DataTypes::ShapeType& pointshape,
353                     const ValueType& value,
354             int dataOffset=0);
355    
356    /**    /**
357       \brief       \brief
358       setTaggedValues       addTag - does not modify the default value for this object. ** Not unit tested **
359    
360       Description:       Description:
361       Assign the given values to the tags listed.       Add a single tag. The default value for this DataTagged will be associated with the tag.
362       \param tagKeys - Input - A vector of integer keys.       If this tag already has a value associated with it, then no change will be made.
363       \param values - Input - A vector of DataArrayViews. If this is empty       \param tagKey - Input - Integer tag.
364                        then all given tags will be assigned a value of zero. If      TODO: Make sure this is unit tested
                       it contains one value all tag values will be assigned the same value.  
                       Otherwise if there is a mismatch between the number of keys and  
                       the number of values an exception will be generated.  
      NB: If a given tag does not yet exist in this DataTagged object, it will be added.  
365    */    */
366      ESCRIPT_DLL_API
367    void    void
368    setTaggedValues(const TagListType& tagKeys,    addTag(int tagKey);
369                    const ValueListType& values);  
370    
371    //  /**
372    //      \brief
373    //      setTaggedValues
374    //
375    //      Description:
376    //      Set the given tags to the given values in this DataTagged object.
377    //      \param tagKeys - Input - A vector of integer tag.
378    //      \param values - Input - A vector of DataArrayViews. If this is empty
379    //                      all tag values will be assigned a scalar data-point of value
380    //                      0. If it contains one value all tag values will be assigned
381    //           this value. Otherwise consecutive tags will be assigned
382    //                      consecutive values.  If there is a mismatch between  the
383    //           number of keys and the number of values an exception
384    //           will be generated.
385    //     T
386    //  */
387    //   ESCRIPT_DLL_API
388    //   void
389    //   setTaggedValues(const TagListType& tagKeys,
390    //                   const ValueListType& values);
391    
392    //  /**
393    //      \brief
394    //      setTaggedValue
395    //
396    //      Description:
397    //      Assign the given value to the given tag.
398    //      \param tagKey - Input - Integer tag.
399    //      \param value - Input - Single DataArrayView value to be assigned to the tag.
400    //     T
401    //  */
402    //   ESCRIPT_DLL_API
403    //   virtual
404    //   void
405    //   setTaggedValue(int tagKey,
406    //                  const DataArrayView& value);
407    
408    /**    /**
409       \brief       \brief
# Line 210  class DataTagged : public DataAbstract { Line 411  class DataTagged : public DataAbstract {
411    
412       Description:       Description:
413       Assign the given value to the given tag.       Assign the given value to the given tag.
414       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer tag.
415       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param pointshape - the shape of the value parameter
416       NB: If the given tag does not yet exist in this DataTagged object, it will be added.       \param value - Input - Vector storing the datapoint to be assigned to the tag.
417         \param dataOffset - beginning of the datapoint within "value".
418        T
419    */    */
420    virtual    ESCRIPT_DLL_API
421    void    void
422    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
423                   const DataArrayView& value);           const DataTypes::ShapeType& pointshape,
424                     const ValueType& value,
425             int dataOffset=0);
426    
427    
428    //  /**
429    //      \brief
430    //      getDataPointByTag
431    //
432    //      Description:
433    //      Return data-point associated with the given tag as a DataArrayView.
434    //      \param tag - Input - Integer key.
435    //     T
436    //  */
437    //   ESCRIPT_DLL_API
438    //   DataArrayView
439    //   getDataPointByTag(int tag) const;
440    
441    /**    /**
442       \brief       \brief
443       getDataPointByTag       getDataByTag
444    
445       Description:       Return a pointer to the beginning of the datapoint with the specified tag.
446       Return a view into the data-point associated with the given tag.       TODO Eventually these should be inlined.
447       \param tag - Input - Integer key.       \param tag - Input - Integer key.
448         \param i - position in the underlying datastructure
449        T
450    */    */
451    DataArrayView    ESCRIPT_DLL_API
452    getDataPointByTag(int tag) const;    DataTypes::ValueType::const_reference
453      getDataByTag(int tag, DataTypes::ValueType::size_type i) const;
454    
455      ESCRIPT_DLL_API
456      DataTypes::ValueType::reference
457      getDataByTag(int tag, DataTypes::ValueType::size_type i);
458    
459    
460      /**
461          \brief
462          getOffsetForTag
463    
464          \param tag
465          \return the offset of the beginning of the datapoint corresponding to tag.
466    
467          Note: If the tag is not valid, the offset of the default value is returned instead.
468      */
469      ESCRIPT_DLL_API
470      DataTypes::ValueType::size_type
471      getOffsetForTag(int tag) const;
472    
473    //  /**
474    //      \brief
475    //      getDataPoint
476    //
477    //      Description:
478    //      Return the data-point specified by the given sample and data-point
479    //      numbers as a DataArrayView.
480    //      \param sampleNo - Input.
481    //      \param dataPointNo - Input.
482    //     T
483    //  */
484    //   ESCRIPT_DLL_API
485    //   virtual
486    //   DataArrayView
487    //   getDataPoint(int sampleNo,
488    //                int dataPointNo);
489    
490    
491    /**    /**
492       \brief       \brief
493       getDataPoint       Return a reference to the underlying DataVector.
494      */
495    
496      ESCRIPT_DLL_API
497      DataTypes::ValueType&
498      getVector();
499    
500      ESCRIPT_DLL_API
501      const DataTypes::ValueType&
502      getVector() const;
503    
504    
505    
506      /**
507         \brief
508         getData
509    
510       Description:       Description:
511       Return a view into the data-point specified by the given sample       Return pointer to the data
512       and data-point numbers.      T
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation.  
      \param sampleNo - Input.  
      \param dataPointNo - Input.  
513    */    */
514    virtual  //   ESCRIPT_DLL_API
515    DataArrayView  //   const DataTypes::ValueType::ElementType*
516    getDataPoint(int sampleNo,  //   getData() const;
                int dataPointNo);  
517    
518    /**    /**
519       \brief       \brief
# Line 253  class DataTagged : public DataAbstract { Line 521  class DataTagged : public DataAbstract {
521    
522       Description:       Description:
523       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
524        T
525    */    */
526      ESCRIPT_DLL_API
527    const DataMapType&    const DataMapType&
528    getTagLookup() const;    getTagLookup() const;
529    
# Line 262  class DataTagged : public DataAbstract { Line 532  class DataTagged : public DataAbstract {
532       isCurrentTag       isCurrentTag
533    
534       Description:       Description:
535       Return true if the given tag exists within the DataTagged tag keys.       Return true if the given tag exists within the DataTagged tag map.
536       NOTE: The DataTagged keys do not necessarily coincide with the tag  
537       keys for the function space.       *** NB: The DataTagged tag map does not necessarily coincide with the tag
538     */       keys in the associated function space.
539        T
540      */
541      ESCRIPT_DLL_API
542    bool    bool
543    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
544    
545    // /**
546    //      \brief
547    //      getDefaultValue
548    //
549    //      Description:
550    //      Return the default value. This value is associated with any tag which
551    //      is not explicitly recorded in this DataTagged object's tag map.
552    //     T
553    //  */
554    //   ESCRIPT_DLL_API
555    //   DataArrayView&
556    //   getDefaultValue();
557    //
558    //   ESCRIPT_DLL_API
559    //   const DataArrayView&
560    //   getDefaultValue() const;
561    
562    /**    /**
563       \brief       \brief
564       getDefaultValue       getDefaultValue
565    
566       Description:       Description:
567       Return the default value. This value is associated with any tag which       Return the default value. This value is associated with any tag which
568       is not explicitly recorded in this DataTagged object.       is not explicitly recorded in this DataTagged object's tag map.
569    */       \param i - position in the underlying datastructure
570    DataArrayView&      T
571    getDefaultValue();    */
572      ESCRIPT_DLL_API
573      DataTypes::ValueType::reference
574      getDefaultValue(DataTypes::ValueType::size_type i);
575    
576      ESCRIPT_DLL_API
577      DataTypes::ValueType::const_reference
578      getDefaultValue(DataTypes::ValueType::size_type i) const;
579    
580    
   /**  
      \brief  
      getDefaultValue  
581    
      Description:  
      Return the default value, const version.  
   */  
   const DataArrayView&  
   getDefaultValue() const;  
582    
583    /**    /**
584       \brief       \brief
585       getLength       getLength
586    
587       Description:       Description:
588       Return the number of doubles stored for the Data.       Return the total number of doubles stored for this DataTagged object.
589        T
590    */    */
591      ESCRIPT_DLL_API
592    virtual    virtual
593    ValueType::size_type    ValueType::size_type
594    getLength() const;    getLength() const;
# Line 306  class DataTagged : public DataAbstract { Line 598  class DataTagged : public DataAbstract {
598       getSlice       getSlice
599    
600       Description:       Description:
601       Factory method that returns a newly created DataTagged.       Factory method that returns a newly created DataTagged object generated
602       The caller is reponsible for managing the object created.       by taking the specified slice from this DataTagged object.
603         The caller is reponsible for managing the returned object.
604        T
605    */    */
606      ESCRIPT_DLL_API
607    virtual    virtual
608    DataAbstract*    DataAbstract*
609    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
610    
611      /**
612         \brief
613         Slice Constructor for DataTagged.
614    
615         Description:
616         Creates a DataTagged object which is the specified slice
617         from the given DataTagged object.
618         \param other - Input - DataTagged object to slice from.
619         \param region - Input - Region to slice.
620        T
621      */
622      ESCRIPT_DLL_API
623      DataTagged(const DataTagged& other,
624             const DataTypes::RegionType& region);
625    
626    /**    /**
627       \brief       \brief
628       setSlice       setSlice
629    
630       Description:       Description:
631       Copy the specified region from the given value.       Copy the given Data object into the specified region in this object.
632       \param value - Input - Data to copy from.       \param other - Input - Data object to copy from.
633       \param region - Input - Region to copy.       \param region - Input - Region to copy into (NB: must have same shape as other!).
634        T
635    */    */
636      ESCRIPT_DLL_API
637    virtual    virtual
638    void    void
639    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* other,
640             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
641    
642    
643    /**    /**
644       \brief       \brief
645       reshapeDataPoint       Computes a symmetric matrix (A + AT) / 2
646    
647         \param ev - Output - symmetric matrix
648    
      Description:  
      Reshape the data point only if the data-point is currently rank 0.  
      An exception is thrown if the data-point has rank other than 0.  
      The original data point value is used for all values of the new  
      data point.  
649    */    */
650    void    ESCRIPT_DLL_API
651    reshapeDataPoint(const DataArrayView::ShapeType& shape);    virtual void
652      symmetric(DataAbstract* ev);
653    
654      /**
655         \brief
656         Computes a nonsymmetric matrix (A - AT) / 2
657    
658         \param ev - Output - nonsymmetric matrix
659    
660      */
661      ESCRIPT_DLL_API
662      virtual void
663      nonsymmetric(DataAbstract* ev);
664    
665      /**
666         \brief
667         Computes the trace of a matrix
668    
669         \param ev - Output - the trace of a matrix
670    
671      */
672      ESCRIPT_DLL_API
673      virtual void
674      trace(DataAbstract* ev, int axis_offset);
675    
676      /**
677         \brief
678         swaps components axis0 and axis1
679    
680         \param ev - Output - swapped components
681    
682      */
683      ESCRIPT_DLL_API
684      virtual void
685      swapaxes(DataAbstract* ev, int axis0, int axis1);
686    
687      /**
688         \brief
689         Transpose each data point of this Data object around the given axis.
690    
691         \param ev - Output - the transpose of a matrix
692    
693      */
694      ESCRIPT_DLL_API
695      virtual void
696      transpose(DataAbstract* ev, int axis_offset);
697    
698      /**
699         \brief
700         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
701    
702         \param ev - Output - eigenvalues in increasing order at each data point
703    
704      */
705      ESCRIPT_DLL_API
706      virtual void
707      eigenvalues(DataAbstract* ev);
708    
709      /**
710         \brief
711         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
712    
713         \param ev - Output - eigenvalues in increasing order at each data point
714         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
715                             and the first nonzero component is positive.
716         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
717    
718      */
719    
720      ESCRIPT_DLL_API
721      virtual void
722      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
723    
724    
725      /**
726         \brief  Returns the offset in the structure which stores the default value
727      */
728      ESCRIPT_DLL_API
729      DataTypes::ValueType::size_type
730      getDefaultOffset() const;
731    
732   protected:   protected:
733    
# Line 349  class DataTagged : public DataAbstract { Line 738  class DataTagged : public DataAbstract {
738    DataMapType m_offsetLookup;    DataMapType m_offsetLookup;
739    
740    //    //
741    // The actual data    // the offset to the default value
742    DataArrayView::ValueType m_data;    static const int m_defaultValueOffset = 0;
743    
744    //    //
745    // the default value offset    // The actual data
746    static const int m_defaultValueOffset = 0;    ValueType m_data;
747    
748  };  };
749    
# Line 366  DataTagged::isCurrentTag(int tag) const Line 755  DataTagged::isCurrentTag(int tag) const
755    return (pos!=m_offsetLookup.end());    return (pos!=m_offsetLookup.end());
756  }  }
757    
758    // inline
759    // DataArrayView&
760    // DataTagged::getDefaultValue()
761    // {
762    //   // The default value is always the first value.
763    //   return getPointDataView();
764    // }
765    
766    // inline
767    // const DataArrayView&
768    // DataTagged::getDefaultValue() const
769    // {
770    //   // The default value is always the first value.
771    //   return getPointDataView();
772    // }
773    
774    
775    inline
776    DataTypes::ValueType::size_type
777    DataTagged::getDefaultOffset() const
778    {
779      return m_defaultValueOffset;  
780    }
781    
782  inline  inline
783  DataArrayView&  DataTypes::ValueType::reference
784  DataTagged::getDefaultValue()  DataTagged::getDefaultValue(DataTypes::ValueType::size_type i)
785  {  {
786    //      return getVector()[i];
   // The default value is always the first value.  
   return getPointDataView();  
787  }  }
788    
789  inline  inline
790  const DataArrayView&  DataTypes::ValueType::const_reference
791  DataTagged::getDefaultValue() const  DataTagged::getDefaultValue(DataTypes::ValueType::size_type i) const
792  {  {
793    //      return getVector()[i];
794    // The default value is always the first value.  }
795    return getPointDataView();  
796    
797    
798    
799    // inline
800    // const DataTypes::ValueType::ElementType*
801    // DataTagged::getData() const
802    // {
803    //    return &(m_data[0]);
804    // }
805    
806    inline
807    const DataTagged::DataMapType&
808    DataTagged::getTagLookup() const
809    {
810      return m_offsetLookup;
811    }
812    
813    inline
814    DataTypes::ValueType::size_type
815    DataTagged::getLength() const
816    {
817      return m_data.size();
818  }  }
819    
820  } // end of namespace  } // end of namespace

Legend:
Removed from v.100  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26