00001 #ifndef LINEARTRANSFORM 00002 #define LINEARTRANSFORM 00003 00004 #include "IotrRefCount.hh" 00005 #include "IotrHandle.hh" 00006 00007 class IotrVector; 00008 class ElementGatherSeq; 00009 class ElementTransfer; 00010 class IotrMask; 00011 00016 class ElementGather : public IotrRefCount { 00017 public: 00018 ElementGather( int nx, int my ) : mNx(nx), mMy(my) {} 00019 virtual IotrMask * asMask() = 0; 00020 virtual void copyFrom( const ElementGatherSeq& elt ) = 0; 00021 virtual void copyInto( ElementGatherSeq& elt ) const = 0; 00022 00023 virtual ElementGather * copy() const = 0; 00024 00026 virtual void gather( double alpha, const IotrVector & x, 00027 double beta, IotrVector & y ) const = 0; 00028 00029 virtual void gatherScaled( double alpha, 00030 const IotrVector & diag, 00031 const IotrVector & x, 00032 double beta, IotrVector & y ) const = 0; 00034 virtual void gatherThenScale( double alpha, const IotrVector & x, 00035 double beta, IotrVector & y, 00036 const IotrVector & d ) const = 0; 00037 00038 virtual IotrVector * rangeVector() const = 0; 00039 virtual IotrVector * rangeVector( const IotrVector & v ) const = 0; 00040 virtual IotrVector * domainVector() const = 0; 00041 00042 virtual ElementGather * composeWith( const ElementGather & b ) const = 0; 00043 00044 virtual void unionWith2( const ElementGather & b, const ElementGather & c, 00045 ElementGather *& u, 00046 ElementGather *& AinU, ElementGather *&BinU, 00047 ElementGather *& CinU ) const = 0; 00048 virtual ElementTransfer * transferTo( ElementGather * e ) = 0; 00051 virtual void scatter( double alpha, const IotrVector & x, 00052 double beta, IotrVector & y ) const = 0; 00053 virtual void scatterInverse( double alpha, const IotrVector & x, 00054 double beta, IotrVector & y ) const = 0; 00055 virtual void scatterScaled( double alpha, const IotrVector & diag, 00056 const IotrVector & x, 00057 double beta, IotrVector & y ) const = 0; 00058 virtual void scatterScaledInverse( double alpha, const IotrVector & diag, 00059 const IotrVector & x, double beta, 00060 IotrVector & y ) const = 0; 00062 virtual void unionWith( const ElementGather &b, 00063 ElementGather *& abunion, 00064 ElementGather *& union2a, 00065 ElementGather *& union2b ) const = 0; 00066 00067 bool isEmpty() const { return mMy == 0; } 00068 virtual bool isIdentity() const = 0; 00069 virtual int isValid() const = 0; 00070 virtual void inspect( const char * name = 0, 00071 const char * filename = 0 ) const = 0; 00072 virtual void inspectAsMatlab( const char * name = 0, 00073 const char * filename = 0) const = 0; 00074 00075 00076 int nx() const { return mNx; } 00077 int my() const { return mMy; } 00078 public: 00079 int mNx, mMy; 00080 }; 00081 00086 class ElementTransfer : public IotrRefCount { 00087 public: 00088 virtual void transferForward( double alpha, IotrVector & x, 00089 double beta, IotrVector & y ) = 0; 00090 virtual void transferBackward( double alpha, IotrVector & x, 00091 double beta, IotrVector & y ) = 0; 00092 virtual void inspect( const char * name = 0, 00093 const char * filename = 0 ) = 0; 00094 00095 virtual void inspectAsMatlab( const char * name = 0, 00096 const char * filename = 0 ) = 0; 00097 }; 00098 00099 typedef Handle<ElementGather> ElementGatherHandle; 00100 typedef Handle< ElementTransfer> ElementTransferHandle; 00101 00102 #endif