00001 #ifndef IOTRVECTOR 00002 #define IOTRVECTOR 00003 00009 #include "IotrRefCount.hh" 00010 #include "IotrHandle.hh" 00011 #include <iostream> 00012 #include "IotrHandle.hh" 00013 00020 class ElementGather; 00021 class SimpleVector; 00022 00023 00047 class IotrVectorCategorize : public IotrRefCount { 00048 public: 00049 enum { category1 = 0x1, category2 = 0x2, category3 = 0x4, 00050 category4 = 0x8, category5 = 0x10, category6 = 0x20, 00051 category7 = 0x40, category8 = 0x80 } ; 00052 virtual void operator()( unsigned char cat[], int len, int ncat, 00053 const double self[], 00054 const double *rhs[], int nrhs ) const = 0; 00055 }; 00056 typedef Handle<IotrVectorCategorize> IotrVectorCategorizeHandle; 00057 00064 template<typename T> 00065 class IotrVectorReduce : public IotrRefCount { 00066 public: 00067 virtual T operator()( const double self[], int len, 00068 const double *v[], int nv ) const = 0; 00069 }; 00070 00071 00074 class IotrVector : public IotrRefCount { 00075 protected: 00076 int mLength; 00079 IotrVector( int length ) : mLength(length) {} 00080 public: 00082 00083 virtual void copyFrom( const SimpleVector& v ) = 0; 00084 virtual void copyFrom( const IotrVector& v ) = 0; 00086 00088 virtual void copyInto( SimpleVector& v ) const = 0; 00089 00091 virtual IotrVector * copy() const = 0; 00093 virtual IotrVector * newSibling() const = 0; 00094 00096 int length() const { return mLength; }; 00105 virtual void writefToStream( std::ostream& out, 00106 const char format[] ) const = 0; 00108 virtual void setToConstant( double c ) = 0; 00110 virtual void setToZero() = 0; 00112 virtual void addConstant( double c ) = 0; 00114 virtual void scale ( double alpha ) = 0; 00116 virtual void axpy ( double alpha, const IotrVector & x ) = 0; 00119 virtual void diagonalMult( double alpha, const IotrVector & x, 00120 double beta, IotrVector & y ) const = 0; 00123 virtual void diagonalDiv( double alpha, const IotrVector & x, 00124 double beta, IotrVector & y ) const = 0; 00127 virtual void 00128 diagonalDiv( double alpha, double beta, IotrVector & y ) const = 0; 00129 00132 virtual double twonorm() const = 0; 00137 virtual double infnorm( double addnlElt = 0.0 ) const = 0; 00143 virtual double stepbound( const IotrVector& s, double bound ) const = 0; 00151 virtual double stepbound( const IotrVector& s, 00152 const IotrVector& xlow, ElementGather& ixlow, 00153 const IotrVector& xupp, ElementGather& ixupp, 00154 double bound ) const = 0; 00172 virtual void makeInterior( const IotrVector &xlow, ElementGather & ixlow, 00173 const IotrVector &xupp, ElementGather & ixupp, 00174 double rtol, double atol ) = 0; 00175 00177 virtual void negate() = 0; 00178 00180 virtual IotrVector& operator*=( const IotrVector& v ) = 0; 00181 virtual IotrVector& operator/=( const IotrVector& v ) = 0; 00182 IotrVector& operator-=( const IotrVector& v ) 00183 { 00184 this->axpy( -1.0, v ); 00185 return *this; 00186 } 00187 IotrVector& operator+=( const IotrVector& v ) 00188 { 00189 this->axpy( 1.0, v ); 00190 return *this; 00191 } 00193 virtual double dot( const IotrVector &x ) const = 0; 00195 virtual double scaledDot( const IotrVector & D, 00196 const IotrVector & x ) const = 0; 00198 virtual void invertNonzero() = 0; 00205 virtual void inspect( const char * name = 0, 00206 const char * filename = 0 ) const = 0; 00214 virtual void inspectAsMatlab( const char * name = 0, 00215 const char * filename = 0) const = 0; 00216 00219 virtual double min() const = 0; 00222 virtual double min(const double addnElt ) const = 0; 00224 virtual int allPositive() const = 0; 00226 virtual void squareRoot() = 0; 00238 virtual void 00239 categorize( ElementGather * cat[], int ncat, IotrVector * rhs[], int nrhs, 00240 const IotrVectorCategorize & func ) const = 0; 00241 virtual double sumReduce( const IotrVector * v[], int nv, 00242 const IotrVectorReduce<double> & func ) const = 0; 00243 }; 00244 00245 typedef Handle<IotrVector> IotrVectorHandle; 00246 00251 #endif 00252