yang.h
Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef _YANG_H_
00006 #define _YANG_H_
00007
00008
00009 #include <iostream>
00010
00011
00012 class Mtx;
00013
00014 class Vtr {
00015 int lenth;
00016 double* ets;
00017 public:
00018 Vtr(int, double*);
00019 Vtr(int, double = 0);
00020 Vtr(const Vtr&);
00021 ~Vtr(){ delete[] ets; }
00022
00023 Vtr& operator=(const Vtr&);
00024 Vtr& operator+=(const Vtr &);
00025 Vtr& operator-=(const Vtr &);
00026 double& operator[](int i) const { return ets[i]; }
00027 double maxnorm() const;
00028 double twonorm() const;
00029 int size() const { return lenth; }
00030
00031 friend Vtr operator+(const Vtr&);
00032 friend Vtr operator-(const Vtr&);
00033 friend Vtr operator+(const Vtr&, const Vtr&);
00034 friend Vtr operator-(const Vtr&, const Vtr&);
00035 friend double dot(const Vtr&, const Vtr&);
00036 friend Vtr operator*(const double, const Vtr&);
00037 friend Vtr operator*(const Vtr&, const double);
00038 friend Vtr operator*(const Vtr&, const Vtr&);
00039 friend Vtr operator*(const Vtr&, const Mtx&);
00040 friend Vtr operator/(const Vtr&, const double);
00041 friend std::ostream& operator<<(std::ostream&, const Vtr&);
00042 };
00043
00044 inline Vtr operator*(const Vtr & v, const double scalar) {
00045 return scalar*v;
00046 }
00047
00048 class Mtx {
00049 private:
00050 int nrows;
00051 int ncols;
00052 double** ets;
00053 public:
00054 Mtx(int n, int m, double**);
00055 Mtx(int n, int m, double d = 0);
00056 Mtx(const Mtx &);
00057 ~Mtx();
00058
00059 Mtx& operator=(const Mtx&);
00060 Mtx& operator+=(const Mtx&);
00061 Mtx& operator-=(const Mtx&);
00062 Vtr operator*(const Vtr&) const;
00063 double* operator[](int i) const { return ets[i]; }
00064
00065
00066
00067 Mtx& operator+();
00068 Mtx operator+(const Mtx&);
00069 friend Mtx operator-(const Mtx&);
00070 friend Mtx operator-(const Mtx&,const Mtx&);
00071
00072
00073 int rows() const {return nrows;}
00074 int cols() const {return ncols;}
00075 void getcol(int i, Vtr& vec) const;
00076 void setcol(int i, const Vtr& vec);
00077 void clear();
00078 int transpose(Mtx& dest) const;
00079 Mtx operator*(const Mtx&) const;
00080 friend Vtr operator*(const Vtr&, const Mtx&);
00081 const double& operator()(int i, int j) const {return ets[i][j];}
00082 double& operator()(int i, int j) {return ets[i][j];}
00083 friend std::ostream& operator<<(std::ostream&, const Mtx&);
00084
00085 int QRdecomp(Mtx& Q, Mtx& R);
00086 int QRdecomp_slow(Mtx& Q, Mtx& R);
00087 };
00088
00089 typedef Vtr Vec_DP;
00090 typedef Mtx Mat_DP;
00091
00092 #endif // _YANG_H_