DenseVector.h
Go to the documentation of this file.
00001 #ifndef DenseVector_H
00002 #define DenseVector_H
00003 
00004 #include <vector>
00005 #include <string>
00006 using namespace std;
00007 
00008 #include "MObject.h"
00009 #include "Const.h"
00010 #include "SparseVector.h"
00011 #include "SparseMatrix.h"
00012 
00013 
00014 using namespace momdp;
00015 namespace momdp 
00016 {
00017 class SparseVector;
00018 
00019 class DenseVector :     public MObject
00020 {
00021         friend class SparseMatrix;
00022         friend class SparseVector;
00023 public:
00024         vector<REAL_VALUE> data;
00025 
00026 protected:
00027         
00028 
00029 public:
00030         DenseVector(void);
00031         DenseVector(int _size);
00032 
00033         void copyFrom(const DenseVector& x)
00034         {
00035                 this->data = x.data;
00036         }
00037         virtual ~DenseVector(void);
00038 
00039         // Accessor
00040         REAL_VALUE& operator()(unsigned int i) 
00041         { 
00042                 return data[i]; 
00043         }
00044 
00045         REAL_VALUE operator()(unsigned int i) const 
00046         { 
00047                 return data[i]; 
00048         }
00049 
00050         // Arithmetic functions 
00051         void operator*=(REAL_VALUE s);
00052         void operator+=(const DenseVector& x);
00053         void operator-=(const DenseVector& x);
00054         
00055         void operator+=(const SparseVector& x);
00056         void operator-=(const SparseVector& x);
00057         
00058         int argSampleDist();
00059         double norm_inf()
00060         {
00061                 double val, max = 0.0;
00062                 FOREACH(double, xi,  data) 
00063                 {
00064                         val = fabs(*xi);
00065                         if (val > max) max = val;
00066                 }
00067                 return max;
00068         }
00069 
00070         double norm_2()
00071         {
00072                 double sum = 0.0;
00073                 FOR(i, data.size())
00074                 {
00075                         sum += data[i]*data[i];
00076                 }
00077                 return sum;
00078         }
00079 
00080 
00081 
00082         DenseVector* mult( SparseMatrix& A);
00083 
00084         // Capacity
00085         int size(void) const 
00086         { 
00087                 return data.size(); 
00088         }
00089 
00090         void resize(int _size, REAL_VALUE value);
00091         void resize(int _size);
00092 
00093 
00094 
00095         // Input Output Functions:
00096         void read(std::istream& in);
00097         std::ostream& write(std::ostream& out) const;
00098 
00099         string ToString() const;
00100 };
00101 
00102 }
00103 
00104 
00105 #endif


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29