00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef Vector_h
00035 #define Vector_h
00036
00037 #include <OPS_Globals.h>
00038
00039 class ID;
00040
00041 #define VECTOR_VERY_LARGE_VALUE 1.0e200
00042
00043 class Matrix;
00044 class Message;
00045 class SystemOfEqn;
00046
00047 #include <Tensor.h>
00048
00049 class Vector
00050 {
00051 public:
00052
00053 Vector();
00054 Vector(int);
00055 Vector(const Vector &);
00056 Vector(double *data, int size);
00057 ~Vector();
00058
00059
00060 int setData(double *newData, int size);
00061 int Assemble(const Vector &V, const ID &l, double fact = 1.0);
00062 double Norm(void) const;
00063 double pNorm(int p) const;
00064 inline int Size(void) const;
00065 int resize(int newSize);
00066 inline void Zero(void);
00067 int Normalize(void);
00068
00069 int addVector(double factThis, const Vector &other, double factOther);
00070 int addMatrixVector(double factThis, const Matrix &m, const Vector &v, double factOther);
00071 int addMatrixTransposeVector(double factThis, const Matrix &m, const Vector &v, double factOther);
00072
00073
00074
00075 inline double operator()(int x) const;
00076 inline double &operator()(int x);
00077 double operator[](int x) const;
00078 double &operator[](int x);
00079 Vector operator()(const ID &rows) const;
00080 Vector &operator=(const Vector &V);
00081 Vector &operator=(const Tensor &T);
00082
00083 Vector &operator+=(double fact);
00084 Vector &operator-=(double fact);
00085 Vector &operator*=(double fact);
00086 Vector &operator/=(double fact);
00087
00088 Vector operator+(double fact) const;
00089 Vector operator-(double fact) const;
00090 Vector operator*(double fact) const;
00091 Vector operator/(double fact) const;
00092
00093 Vector &operator+=(const Vector &V);
00094 Vector &operator-=(const Vector &V);
00095
00096 Vector operator+(const Vector &V) const;
00097 Vector operator-(const Vector &V) const;
00098 double operator^(const Vector &V) const;
00099 Vector operator/(const Matrix &M) const;
00100
00101 int operator==(const Vector &V) const;
00102 int operator!=(const Vector &V) const;
00103
00104
00105 int Assemble(const Vector &V, int init_row, double fact = 1.0);
00106 int Extract (const Vector &V, int init_row, double fact = 1.0);
00107
00108 friend OPS_Stream &operator<<(OPS_Stream &s, const Vector &V);
00109
00110 friend Vector operator*(double a, const Vector &V);
00111
00112 friend class Message;
00113 friend class SystemOfEqn;
00114 friend class Matrix;
00115 friend class TCP_SocketNoDelay;
00116 friend class TCP_Socket;
00117 friend class UDP_Socket;
00118 friend class MPI_Channel;
00119 friend class MySqlDatastore;
00120 friend class BerkeleyDbDatastore;
00121
00122 private:
00123 static double VECTOR_NOT_VALID_ENTRY;
00124 int sz;
00125 double *theData;
00126 int fromFree;
00127 };
00128
00129
00130
00131 inline int
00132 Vector::Size(void) const
00133 {
00134 return sz;
00135 }
00136
00137
00138 inline void
00139 Vector::Zero(void){
00140 for (int i=0; i<sz; i++) theData[i] = 0.0;
00141 }
00142
00143
00144 inline double
00145 Vector::operator()(int x) const
00146 {
00147 #ifdef _G3DEBUG
00148
00149 if (x < 0 || x >= sz) {
00150 opserr << "Vector::(loc) - loc " << x << " outside range [0, " << sz-1 << endln;
00151 return VECTOR_NOT_VALID_ENTRY;
00152 }
00153 #endif
00154
00155 return theData[x];
00156 }
00157
00158
00159 inline double &
00160 Vector::operator()(int x)
00161 {
00162 #ifdef _G3DEBUG
00163
00164 if (x < 0 || x >= sz) {
00165 opserr << "Vector::(loc) - loc " << x << " outside range [0, " << sz-1 << endln;
00166 return VECTOR_NOT_VALID_ENTRY;
00167 }
00168 #endif
00169
00170 return theData[x];
00171 }
00172
00173
00174 #endif
00175