00001 #ifndef GVECTOR_H
00002 #define GVECTOR_H
00003
00004 #include "GObject.h"
00005 #include "GMatrix.h"
00006 #include "io/GError_Output.h"
00007
00008 #include <string>
00009
00010 namespace GMathLib{
00011
00016 class GVector : public GMatrix
00017 {
00018 public:
00024 GVector();
00025
00032 virtual ~GVector();
00033
00052 GVector(int size, int vec_type=GVector::COLUMN_VECTOR, double *p_data=0);
00053
00067 virtual int Copy(const GVector& obj, int begin_id, int end_id, int pos);
00068
00075 virtual int Copy(const GVector& obj){
00076 return GMatrix::Copy(obj);
00077 }
00078
00085 inline void Set(int no, double value){
00086 if( Row() == 1){
00087 SetElement(0, no, value);
00088 }else if( Column() == 1){
00089 SetElement(no, 0, value);
00090 }
00091 }
00092
00099 inline double Get(int no) const{
00100 if( Row() == 1){
00101 return GetElement(0, no);
00102 }else{
00103 return GetElement(no, 0);
00104 }
00105
00106 return -1;
00107 }
00108
00109
00118 static double Dot_Product(GVector& vec1, GVector& vec2);
00119
00127 void Cross_Product(GVector& vec1, GVector& vec2);
00128
00129
00134 double Norm();
00135
00140 inline int Size() const{
00141 if( Row() == 1){
00142 return Column();
00143 }else{
00144 return Row();
00145 }
00146 }
00147
00152 inline int Shape(){
00153 if( Row() == 1){
00154 return GVector::ROW_VECTOR;
00155 }else{
00156 return GVector::COLUMN_VECTOR;
00157 }
00158 }
00159
00165 inline double& operator()(int i){
00166 return p_data[i];
00167 }
00168
00169 const static int COLUMN_VECTOR = 0;
00170 const static int ROW_VECTOR = 1;
00172 };
00173
00174 }
00175
00176 #endif