--- trunk/esys2/escript/src/Data/DataConstant.h 2005/04/12 04:45:05 119 +++ trunk/escript/src/DataConstant.h 2006/08/08 11:23:18 800 @@ -1,24 +1,22 @@ //$Id$ /* - ****************************************************************************** - * * - * COPYRIGHT ACcESS 2004 - All Rights Reserved * - * * - * This software is the property of ACcESS. No part of this code * - * may be copied in any form or by any means without the expressed written * - * consent of ACcESS. Copying, use or modification of this software * - * by any unauthorised person is illegal unless that person has a software * - * license agreement with ACcESS. * - * * - ****************************************************************************** + ************************************************************ + * Copyright 2006 by ACcESS MNRF * + * * + * http://www.access.edu.au * + * Primary Business: Queensland, Australia * + * Licensed under the Open Software License version 3.0 * + * http://www.opensource.org/licenses/osl-3.0.php * + * * + ************************************************************ */ - + #if !defined escript_DataConstant_20040323_H #define escript_DataConstant_20040323_H +#include "system_dep.h" -#include "escript/Data/DataAbstract.h" -#include "escript/Data/DataArray.h" -#include "escript/Data/DataArrayView.h" +#include "DataAbstract.h" +#include "DataArrayView.h" #include @@ -47,6 +45,7 @@ \param value - Input - Data value for a single point. \param what - Input - A description of what this data object represents. */ + ESCRIPT_DLL_API DataConstant(const boost::python::numeric::array& value, const FunctionSpace& what); @@ -54,6 +53,7 @@ \brief Copy constructor. Performs a deep copy. */ + ESCRIPT_DLL_API DataConstant(const DataConstant& other); /** @@ -65,6 +65,7 @@ \param value - Input - Data value for a single point. \param what - Input - A description of what this data object represents. */ + ESCRIPT_DLL_API DataConstant(const DataArrayView& value, const FunctionSpace& what); @@ -77,6 +78,7 @@ \param other - Input - Data object to copy from. \param region - Input - region to copy. */ + ESCRIPT_DLL_API DataConstant(const DataConstant& other, const DataArrayView::RegionType& region); @@ -90,6 +92,7 @@ \param shape - Input - the shape of each data-point. \param data - the data values for each data-point. */ + ESCRIPT_DLL_API DataConstant(const FunctionSpace& what, const DataArrayView::ShapeType &shape, const DataArrayView::ValueType &data); @@ -98,6 +101,7 @@ \brief Write the data as a string. */ + ESCRIPT_DLL_API std::string toString() const; @@ -110,6 +114,7 @@ \param sampleNo - Input - sample number. \param dataPointNo - Input - data point number for the sample. */ + ESCRIPT_DLL_API virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, @@ -121,6 +126,7 @@ \param sampleNo - Input - sample number. \param dataPointNo - Input - data point number for the sample. */ + ESCRIPT_DLL_API virtual DataArrayView getDataPoint(int sampleNo, @@ -130,6 +136,7 @@ \brief Return the number of doubles stored for the Data object. */ + ESCRIPT_DLL_API virtual DataArrayView::ValueType::size_type getLength() const; @@ -141,6 +148,7 @@ The caller is reponsible for managing the object created. \param region - Input - region to slice from this object. */ + ESCRIPT_DLL_API virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const; @@ -151,6 +159,7 @@ \param value - Input - Data object to copy from. \param region - Input - Region to copy. */ + ESCRIPT_DLL_API virtual void setSlice(const DataAbstract* value, @@ -162,9 +171,118 @@ The original data point value is used for all values of the new data point. */ + ESCRIPT_DLL_API void reshapeDataPoint(const DataArrayView::ShapeType& shape); + /** + \brief + Archive the underlying data values to the file referenced + by ofstream. A count of the number of values expected to be written + is provided as a cross-check. + + The return value indicates success (0) or otherwise (1). + */ + ESCRIPT_DLL_API + int + archiveData(std::ofstream& archiveFile, + const DataArrayView::ValueType::size_type noValues) const; + + /** + \brief + Extract the number of values specified by noValues from the file + referenced by ifstream to the underlying data structure. + + The return value indicates success (0) or otherwise (1). + */ + ESCRIPT_DLL_API + int + extractData(std::ifstream& archiveFile, + const DataArrayView::ValueType::size_type noValues); + + /** + \brief + Computes a symmetric matrix (A + AT) / 2 + + \param ev - Output - symmetric matrix + + */ + ESCRIPT_DLL_API + virtual void + symmetric(DataAbstract* ev); + + /** + \brief + Computes a nonsymmetric matrix (A - AT) / 2 + + \param ev - Output - nonsymmetric matrix + + */ + ESCRIPT_DLL_API + virtual void + nonsymmetric(DataAbstract* ev); + + /** + \brief + Computes the trace of a matrix + + \param ev - Output - trace of matrix + + */ + ESCRIPT_DLL_API + virtual void + trace(DataAbstract* ev, int axis_offset); + + /** + \brief + Transpose each data point of this Data object around the given axis. + + \param ev - Output - transpose of matrix + + */ + ESCRIPT_DLL_API + virtual void + transpose(DataAbstract* ev, int axis_offset); + + /** + \brief + swaps components axis_offset and axis_offset+1 + + \param ev - Output - swapped components + + */ + ESCRIPT_DLL_API + virtual void + swap(DataAbstract* ev, int axis_offset); + + + /** + \brief + solves the eigenvalue problem this*V=ev*V for the eigenvalues ev + + \param ev - Output - eigenvalues in increasing order at each data point + + */ + ESCRIPT_DLL_API + virtual void + eigenvalues(DataAbstract* ev); + + /** + \brief + solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V + + \param ev - Output - eigenvalues in increasing order at each data point + \param V - Output - corresponding eigenvectors. They are normalized such that their length is one + and the first nonzero component is positive. + \param tol - Input - eigenvalue with relative distance tol are treated as equal. + + */ + + ESCRIPT_DLL_API + virtual void + eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13); + + protected: private: