00001 #ifndef VECTORD_H
00002 #define VECTORD_H
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
00035
00036 #include "matrix.h"
00043 #define REF_CV(A,I) (((A).D)->m[(I)])
00044 #define THIS_CV(I) (((*this).D)->m[(I)])
00045
00046
00047 #ifdef USE_NAMESPACE_LINAL
00048 namespace LinAl {
00049 #endif
00050
00056 class VectorD:public MatrixC<double>
00057 {
00058 public:
00060 explicit VectorD() : MatrixC<double>() {}
00062 explicit VectorD(const int nr, const double value=0.0) : MatrixC<double>(nr,1,value) {}
00064 explicit VectorD(const double* A, const int nr) : MatrixC<double>(A,nr,1) {}
00066 VectorD(const VectorD& B) : MatrixC<double>(B) {} ;
00068 ~VectorD() {} ;
00070 VectorD& operator= (const double value)
00071 {this->MatrixC<double>::operator=(value); return *this;}
00073 void resize(const int nr, const double value=0.0);
00075 virtual Ref<double> operator() (const int i, const int=0) {return MatrixC<double>::operator()(i);}
00077 virtual double operator() (const int i, const int=0) const {return THIS_CV(i);}
00078 protected:
00080 double* ref(const int i) const {return &THIS_CV(i);}
00082 double read(const int i) const {return THIS_CV(i);}
00084 void write(const int i, const double v) {D=D->get_own_copy();THIS_CV(i)=v;}
00086 void add(const int i, const double v) {D=D->get_own_copy();THIS_CV(i)+=v;}
00088 void sub(const int i, const double v) {D=D->get_own_copy();THIS_CV(i)-=v;}
00090 void mul(const int i, const double v) {D=D->get_own_copy();THIS_CV(i)*=v;}
00092 void div(const int i, const double v) {D=D->get_own_copy();THIS_CV(i)/=v;}
00093 public:
00095 virtual void stream(ostream& s);
00099
00100 VectorD transpose() const ;
00102 void multiply(const MatrixFD& A, const VectorD& x, const char TRANS='N',
00103 const double ALPHA=1.0, const double BETA=0.0) ;
00105 void multiply(const MatrixSD& A, const VectorD& x,
00106 const double ALPHA=1.0, const double BETA=0.0) ;
00108 void multiply(const MatrixBD& A, const VectorD& x, const char TRANS='N',
00109 const double ALPHA=1.0, const double BETA=0.0) ;
00111 double multiply(const VectorD& B) const;
00113 void multiply(const double value);
00115 double norm2() const ;
00116 };
00117 #ifdef USE_NAMESPACE_LINAL
00118 }
00119 #endif
00120 #endif // #ifndef VECTORD_H