/[escript]/branches/arrayview_from_1695_trunk/escript/src/DataTagged.h
ViewVC logotype

Diff of /branches/arrayview_from_1695_trunk/escript/src/DataTagged.h

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

trunk/esys2/escript/src/Data/DataTagged.h revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC branches/arrayview_from_1695_trunk/escript/src/DataTagged.h revision 1712 by jfenwick, Wed Aug 20 05:04:28 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 "DataArrayView.h"
22  #include "escript/Data/DataArrayView.h"  #include "DataTypes.h"
23    
24  #include <vector>  #include <vector>
25  #include <map>  #include <map>
# Line 29  class DataConstant; Line 30  class DataConstant;
30    
31  /**  /**
32     \brief     \brief
33     Creates the illusion of a full dataset accessible via sampleNo and dataPointNo.     Simulates a full dataset accessible via sampleNo and dataPointNo.
34    
35     Description:     Description:
36     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
37     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.  
38     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
39     dataPointNo values.     dataPointNo values.
40  */  */
# Line 44  class DataTagged : public DataAbstract { Line 43  class DataTagged : public DataAbstract {
43    
44   public:   public:
45    
46    typedef std::vector<int> TagListType;    //
47      // Types for the lists of tags and values.
48      typedef std::vector<int>           TagListType;
49    typedef std::vector<DataArrayView> ValueListType;    typedef std::vector<DataArrayView> ValueListType;
50      typedef DataTypes::ValueType   ValueType;
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    /**    /**
# Line 68  class DataTagged : public DataAbstract { Line 72  class DataTagged : public DataAbstract {
72    
73       Description:       Description:
74       Constructor for DataTagged.       Constructor for DataTagged.
75       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tags.
76       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
77                     all tag values will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
78                     it contains one value all tag values will be assigned the                       0. If it contains one value all tag values will be assigned
79             same value. Otherwise if there is a mismatch between               this value. Otherwise consecutive tags will be assigned
80             the number of keys and the number of values an exception                       consecutive values.  If there is a mismatch between  the
81             will be generated.               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.       \param defaultValue - Input - Value returned if a requested tag doesn't exist.
84       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
85        T
86    */    */
87      ESCRIPT_DLL_API
88    DataTagged(const TagListType& tagKeys,    DataTagged(const TagListType& tagKeys,
89               const ValueListType& values,               const ValueListType& values,
90           const DataArrayView& defaultValue,           const DataArrayView& defaultValue,
# Line 85  class DataTagged : public DataAbstract { Line 92  class DataTagged : public DataAbstract {
92    
93    /**    /**
94       \brief       \brief
95       Slice constructor for DataTagged.       Alternative Constructor for DataTagged.
96    
97       Description:       Description:
98       Slice constructor for DataTagged.       Alternative Constructor for DataTagged.
99       Copies a slice from another DataTagged object.       \param what - Input - A description of what this data object represents.
100       \param other - Input - DataTagged object to copy from.       \param shape - Input - The shape of each data-point.
101       \param region - Input - region to copy.       \param tags - Input - An array of tags, one for each sample number.
102         \param data - The data values for each tag.
103        NB: no unit testing yet
104    */    */
105    DataTagged(const DataTagged& other,    ESCRIPT_DLL_API
106           const DataArrayView::RegionType& region);    DataTagged(const FunctionSpace& what,
107                 const DataTypes::ShapeType &shape,
108                 const int tags[],
109                 const ValueType& data);
110    
111    /**    /**
112       \brief       \brief
113       Copy constructorfor DataTagged.       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        NB: no unit testing yet
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      /**
130         \brief
131         Copy Constructor for DataTagged.
132       Performs a deep copy from the given DataTagged object.       Performs a deep copy from the given DataTagged object.
133        T
134    */    */
135      ESCRIPT_DLL_API
136    DataTagged(const DataTagged& other);    DataTagged(const DataTagged& other);
137    
138    /**    /**
139       \brief       \brief
140       Construct a tagged data from a DataConstant object.       Copy Constructor for DataTagged.
141       The default data-point will be that held by the DataConstant object.       Construct a DataTagged object from a DataConstant object.
142         The default value will be the value of the DataConstant object.
143        T
144    */    */
145      ESCRIPT_DLL_API
146    DataTagged(const DataConstant& other);    DataTagged(const DataConstant& other);
147    
148    /**    /**
149       \brief       \brief
150         Copies the tags from a DataTagged into a new Data Tagged and assigns them the default value. ** Not unit tested **
151    
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      ESCRIPT_DLL_API
159      DataTagged(const FunctionSpace& what,
160                 const DataTypes::ShapeType& shape,
161             const DataTypes::ValueType& defaultvalue,
162                 const DataTagged& tagsource);
163    
164    
165    
166      /**
167         \brief
168         Destructor
169      */
170      ESCRIPT_DLL_API
171      inline virtual
172      ~DataTagged() {};
173    
174      /**
175         \brief
176       getSampleDataByTag       getSampleDataByTag
177    
178       Description:       Description:
179       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
180       sample should be visable via the returned pointer. This provides an       sample will be visible via the returned pointer.
181       interface into the data suitable for legacy C code.  
182         ** This provides an interface into the data suitable for legacy C code.
183         ** NB: need to do array bounds checking when accessing returned value!
184        T
185    */    */
186      ESCRIPT_DLL_API
187    virtual    virtual
188    double*    double*
189    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
# Line 128  class DataTagged : public DataAbstract { Line 193  class DataTagged : public DataAbstract {
193       Write the data as a string.       Write the data as a string.
194       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
195       associated with each tag.       associated with each tag.
196        T
197    */    */
198      ESCRIPT_DLL_API
199    virtual    virtual
200    std::string    std::string
201    toString() const;    toString() const;
202     /**
203         \brief
204         dumps the object into a netCDF file
205      */
206      ESCRIPT_DLL_API
207      virtual
208      void
209      dump(const std::string fileName) const;
210    
211     /**
212         \brief
213        sets all values to zero
214      */
215      ESCRIPT_DLL_API
216      virtual
217      void
218      setToZero();
219    
220      /**
221         \brief
222         Return the tag number associated with the given data-point number
223         according to the associated function space.
224        T
225      */
226      ESCRIPT_DLL_API
227      virtual
228      int
229      getTagNumber(int dpno);
230    
231    /**    /**
232       \brief       \brief
233       getPointOffset       getPointOffset
234    
235       Description:       Description:
236       Return the offset to the given data-point. This is somewhat artificial,       Return the offset to the given data-point value in the underlying
237       but returns the offset for the given point in the DataTagged object.       data vector.
      Only really necessary to avoid many DataArrayView objects.  
238    
239       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
240       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
241     */      T
242      */
243      ESCRIPT_DLL_API
244    virtual    virtual
245    DataArrayView::ValueType::size_type    ValueType::size_type
246    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
247                   int dataPointNo) const;                   int dataPointNo) const;
248    
249    
250    
251    /**    /**
252       \brief       \brief
253       addTaggedValues       addTaggedValues
254    
255       Description:       Description:
256       Add the given tags and values to this DataTagged object.       Add the given tags and values to this DataTagged object.
257       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tags.
258       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
259                     then all given tags will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
260                     it contains one value all tags will be assigned the same value.                       0. If it contains one value all tag values will be assigned
261                     Otherwise if there is a mismatch between the number of tags and               this value. Otherwise consecutive tags will be assigned
262                     the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
263       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
264       value will have no effect. setTaggedValues is more versatile and should be               will be generated.
265       used in most cases in preference to addTaggedValues.      T
266    */    */
267      ESCRIPT_DLL_API
268    void    void
269    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
270                    const ValueListType& values);                      const ValueListType& values);  
# Line 175  class DataTagged : public DataAbstract { Line 274  class DataTagged : public DataAbstract {
274       addTaggedValue       addTaggedValue
275    
276       Description:       Description:
277       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
278       \param tagKey - Input - Integer key.       a value associated with it, setTaggedValue will be used to update this value.
279       \param value - Input - DataArrayView.       \param tagKey - Input - Integer tag.
280       NB: If this tag already exists in this object, this attempt to add the given       \param value - Input - Single DataArrayView value to be assigned to the tag.
281       value will have no effect. setTaggedValue is more versatile and should be      T
      used in most cases in preference to addTaggedValue.  
282    */    */
283      ESCRIPT_DLL_API
284    void    void
285    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
286                   const DataArrayView& value);                   const DataArrayView& value);
287    
288    /**    /**
289       \brief       \brief
290         addTag - does not modify the default value for this object. ** Not unit tested **
291    
292         Description:
293         Add a single tag. The default value for this DataTagged will be associated with the tag.
294         If this tag already has a value associated with it, then no change will be made.
295         \param tagKey - Input - Integer tag.
296        T
297      */
298      ESCRIPT_DLL_API
299      void
300      addTag(int tagKey);
301    
302    
303      /**
304         \brief
305       setTaggedValues       setTaggedValues
306    
307       Description:       Description:
308       Assign the given values to the tags listed.       Set the given tags to the given values in this DataTagged object.
309       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tag.
310       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
311                        then all given tags will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
312                        it contains one value all tag values will be assigned the same value.                       0. If it contains one value all tag values will be assigned
313                        Otherwise if there is a mismatch between the number of keys and               this value. Otherwise consecutive tags will be assigned
314                        the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
315       NB: If a given tag does not yet exist in this DataTagged object, it will be added.               number of keys and the number of values an exception
316                 will be generated.
317        T
318    */    */
319      ESCRIPT_DLL_API
320    void    void
321    setTaggedValues(const TagListType& tagKeys,    setTaggedValues(const TagListType& tagKeys,
322                    const ValueListType& values);                    const ValueListType& values);
# Line 210  class DataTagged : public DataAbstract { Line 327  class DataTagged : public DataAbstract {
327    
328       Description:       Description:
329       Assign the given value to the given tag.       Assign the given value to the given tag.
330       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer tag.
331       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
332       NB: If the given tag does not yet exist in this DataTagged object, it will be added.      T
333    */    */
334      ESCRIPT_DLL_API
335    virtual    virtual
336    void    void
337    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 224  class DataTagged : public DataAbstract { Line 342  class DataTagged : public DataAbstract {
342       getDataPointByTag       getDataPointByTag
343    
344       Description:       Description:
345       Return a view into the data-point associated with the given tag.       Return data-point associated with the given tag as a DataArrayView.
346       \param tag - Input - Integer key.       \param tag - Input - Integer key.
347        T
348    */    */
349      ESCRIPT_DLL_API
350    DataArrayView    DataArrayView
351    getDataPointByTag(int tag) const;    getDataPointByTag(int tag) const;
352    
353    /**    /**
354       \brief       \brief
355         getDataByTag
356    
357         Return a pointer to the beginning of the datapoint with the specified tag.
358         TODO Eventually these should be inlined.
359         \param tag - Input - Integer key.
360         \param i - position in the underlying datastructure
361        T
362      */
363      ESCRIPT_DLL_API
364      DataTypes::ValueType::const_reference
365      getDataByTag(int tag, DataTypes::ValueType::size_type i) const;
366    
367      ESCRIPT_DLL_API
368      DataTypes::ValueType::reference
369      getDataByTag(int tag, DataTypes::ValueType::size_type i);
370    
371    
372      /**
373         \brief
374       getDataPoint       getDataPoint
375    
376       Description:       Description:
377       Return a view into the data-point specified by the given sample       Return the data-point specified by the given sample and data-point
378       and data-point numbers.       numbers as a DataArrayView.
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation.  
379       \param sampleNo - Input.       \param sampleNo - Input.
380       \param dataPointNo - Input.       \param dataPointNo - Input.
381        T
382    */    */
383      ESCRIPT_DLL_API
384    virtual    virtual
385    DataArrayView    DataArrayView
386    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
387                 int dataPointNo);                 int dataPointNo);
388    
389    /**    /**
390         \brief
391         getData
392    
393         Description:
394         Return pointer to the data
395        T
396      */
397      ESCRIPT_DLL_API
398      const DataTypes::ValueType::ElementType*
399      getData() const;
400    
401      /**
402       \brief       \brief
403       getTagLookup       getTagLookup
404    
405       Description:       Description:
406       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
407        T
408    */    */
409      ESCRIPT_DLL_API
410    const DataMapType&    const DataMapType&
411    getTagLookup() const;    getTagLookup() const;
412    
# Line 262  class DataTagged : public DataAbstract { Line 415  class DataTagged : public DataAbstract {
415       isCurrentTag       isCurrentTag
416    
417       Description:       Description:
418       Return true if the given tag exists within the DataTagged tag keys.       Return true if the given tag exists within the DataTagged tag map.
419       NOTE: The DataTagged keys do not necessarily coincide with the tag  
420       keys for the function space.       *** NB: The DataTagged tag map does not necessarily coincide with the tag
421     */       keys in the associated function space.
422        T
423      */
424      ESCRIPT_DLL_API
425    bool    bool
426    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
427    
# Line 275  class DataTagged : public DataAbstract { Line 431  class DataTagged : public DataAbstract {
431    
432       Description:       Description:
433       Return the default value. This value is associated with any tag which       Return the default value. This value is associated with any tag which
434       is not explicitly recorded in this DataTagged object.       is not explicitly recorded in this DataTagged object's tag map.
435        T
436    */    */
437      ESCRIPT_DLL_API
438    DataArrayView&    DataArrayView&
439    getDefaultValue();    getDefaultValue();
440    
441      ESCRIPT_DLL_API
442      const DataArrayView&
443      getDefaultValue() const;
444    
445    /**    /**
446       \brief       \brief
447       getDefaultValue       getDefaultValue
448    
449       Description:       Description:
450       Return the default value, const version.       Return the default value. This value is associated with any tag which
451    */       is not explicitly recorded in this DataTagged object's tag map.
452    const DataArrayView&       \param i - position in the underlying datastructure
453    getDefaultValue() const;      T
454      */
455      ESCRIPT_DLL_API
456      DataTypes::ValueType::reference
457      getDefaultValue(DataTypes::ValueType::size_type i);
458    
459      ESCRIPT_DLL_API
460      DataTypes::ValueType::const_reference
461      getDefaultValue(DataTypes::ValueType::size_type i) const;
462    
463    
464    
465    
466    /**    /**
467       \brief       \brief
468       getLength       getLength
469    
470       Description:       Description:
471       Return the number of doubles stored for the Data.       Return the total number of doubles stored for this DataTagged object.
472        T
473    */    */
474      ESCRIPT_DLL_API
475    virtual    virtual
476    ValueType::size_type    ValueType::size_type
477    getLength() const;    getLength() const;
# Line 306  class DataTagged : public DataAbstract { Line 481  class DataTagged : public DataAbstract {
481       getSlice       getSlice
482    
483       Description:       Description:
484       Factory method that returns a newly created DataTagged object.       Factory method that returns a newly created DataTagged object generated
485       The caller is reponsible for managing the object created.       by taking the specified slice from this DataTagged object.
486         The caller is reponsible for managing the returned object.
487        T
488    */    */
489      ESCRIPT_DLL_API
490    virtual    virtual
491    DataAbstract*    DataAbstract*
492    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
493    
494      /**
495         \brief
496         Slice Constructor for DataTagged.
497    
498         Description:
499         Creates a DataTagged object which is the specified slice
500         from the given DataTagged object.
501         \param other - Input - DataTagged object to slice from.
502         \param region - Input - Region to slice.
503        T
504      */
505      ESCRIPT_DLL_API
506      DataTagged(const DataTagged& other,
507             const DataTypes::RegionType& region);
508    
509    /**    /**
510       \brief       \brief
511       setSlice       setSlice
512    
513       Description:       Description:
514       Copy the specified region from the given value into this object.       Copy the given Data object into the specified region in this object.
515       \param value - Input - Data to copy from.       \param other - Input - Data object to copy from.
516       \param region - Input - Region to copy.       \param region - Input - Region to copy into (NB: must have same shape as other!).
517        T
518    */    */
519      ESCRIPT_DLL_API
520    virtual    virtual
521    void    void
522    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* other,
523             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
524    
525    /**    /**
526       \brief       \brief
527       reshapeDataPoint       Archive the underlying data values to the file referenced
528         by ofstream. A count of the number of values expected to be written
529         is provided as a cross-check.
530    
531       Description:       The return value indicates success (0) or otherwise (1).
      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.  
532    */    */
533    void    ESCRIPT_DLL_API
534    reshapeDataPoint(const DataArrayView::ShapeType& shape);    int
535      archiveData(std::ofstream& archiveFile,
536                  const DataTypes::ValueType::size_type noValues) const;
537    
538      /**
539         \brief
540         Extract the number of values specified by noValues from the file
541         referenced by ifstream to the underlying data structure.
542    
543         The return value indicates success (0) or otherwise (1).
544      */
545      ESCRIPT_DLL_API
546      int
547      extractData(std::ifstream& archiveFile,
548                  const DataTypes::ValueType::size_type noValues);
549    
550      /**
551         \brief
552         Computes a symmetric matrix (A + AT) / 2
553    
554         \param ev - Output - symmetric matrix
555    
556      */
557      ESCRIPT_DLL_API
558      virtual void
559      symmetric(DataAbstract* ev);
560    
561      /**
562         \brief
563         Computes a nonsymmetric matrix (A - AT) / 2
564    
565         \param ev - Output - nonsymmetric matrix
566    
567      */
568      ESCRIPT_DLL_API
569      virtual void
570      nonsymmetric(DataAbstract* ev);
571    
572      /**
573         \brief
574         Computes the trace of a matrix
575    
576         \param ev - Output - the trace of a matrix
577    
578      */
579      ESCRIPT_DLL_API
580      virtual void
581      trace(DataAbstract* ev, int axis_offset);
582    
583      /**
584         \brief
585         swaps components axis0 and axis1
586    
587         \param ev - Output - swapped components
588    
589      */
590      ESCRIPT_DLL_API
591      virtual void
592      swapaxes(DataAbstract* ev, int axis0, int axis1);
593    
594      /**
595         \brief
596         Transpose each data point of this Data object around the given axis.
597    
598         \param ev - Output - the transpose of a matrix
599    
600      */
601      ESCRIPT_DLL_API
602      virtual void
603      transpose(DataAbstract* ev, int axis_offset);
604    
605      /**
606         \brief
607         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
608    
609         \param ev - Output - eigenvalues in increasing order at each data point
610    
611      */
612      ESCRIPT_DLL_API
613      virtual void
614      eigenvalues(DataAbstract* ev);
615    
616      /**
617         \brief
618         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
619    
620         \param ev - Output - eigenvalues in increasing order at each data point
621         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
622                             and the first nonzero component is positive.
623         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
624    
625      */
626    
627      ESCRIPT_DLL_API
628      virtual void
629      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
630    
631    
632   protected:   protected:
633    
# Line 349  class DataTagged : public DataAbstract { Line 638  class DataTagged : public DataAbstract {
638    DataMapType m_offsetLookup;    DataMapType m_offsetLookup;
639    
640    //    //
641    // The actual data    // the offset to the default value
642    DataArrayView::ValueType m_data;    static const int m_defaultValueOffset = 0;
643    
644    //    //
645    // the default value offset    // The actual data
646    static const int m_defaultValueOffset = 0;    ValueType m_data;
647    
648  };  };
649    
# Line 370  inline Line 659  inline
659  DataArrayView&  DataArrayView&
660  DataTagged::getDefaultValue()  DataTagged::getDefaultValue()
661  {  {
   //  
662    // The default value is always the first value.    // The default value is always the first value.
663    return getPointDataView();    return getPointDataView();
664  }  }
# Line 379  inline Line 667  inline
667  const DataArrayView&  const DataArrayView&
668  DataTagged::getDefaultValue() const  DataTagged::getDefaultValue() const
669  {  {
   //  
670    // The default value is always the first value.    // The default value is always the first value.
671    return getPointDataView();    return getPointDataView();
672  }  }
673    
674    inline
675    DataTypes::ValueType::reference
676    DataTagged::getDefaultValue(DataTypes::ValueType::size_type i)
677    {
678        return getPointDataView().getData()[i];
679    }
680    
681    inline
682    DataTypes::ValueType::const_reference
683    DataTagged::getDefaultValue(DataTypes::ValueType::size_type i) const
684    {
685        return getPointDataView().getData()[i];
686    }
687    
688    
689    
690    
691    inline
692    const DataTypes::ValueType::ElementType*
693    DataTagged::getData() const
694    {
695       return &(m_data[0]);
696    }
697    
698    inline
699    const DataTagged::DataMapType&
700    DataTagged::getTagLookup() const
701    {
702      return m_offsetLookup;
703    }
704    
705    inline
706    DataTypes::ValueType::size_type
707    DataTagged::getLength() const
708    {
709      return m_data.size();
710    }
711    
712  } // end of namespace  } // end of namespace
713    
714  #endif  #endif

Legend:
Removed from v.102  
changed lines
  Added in v.1712

  ViewVC Help
Powered by ViewVC 1.1.26