00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSL_VECTOR_H
00020 #define MSL_VECTOR_H
00021
00022 #include <stream.h>
00023 #include <list.h>
00024 #include <vector.h>
00025
00026 void error_handler(int i, const char* s);
00027
00028 class MSLVector
00029 {
00030 friend class MSLMatrix;
00031
00032 double* v;
00033 int d;
00034
00035 void check_dimensions(const MSLVector&) const;
00036
00037 public:
00038
00039 MSLVector();
00040 MSLVector(int d);
00041 MSLVector(double a, double b);
00042 MSLVector(double a, double b, double c);
00043 MSLVector(const MSLVector& w, int prec);
00044 MSLVector(const MSLVector&);
00045 ~MSLVector();
00046 MSLVector& operator=(const MSLVector&);
00047
00048 int dim() const { return d; }
00049 double& operator[](int i);
00050 double operator[](int) const;
00051 double hcoord(int i) const { return (i<d) ? (*this)[i] : 1; }
00052 double coord(int i) const { return (*this)[i]; }
00053 double sqr_length() const;
00054 double length() const;
00055 MSLVector norm() const { return *this/length(); }
00056 double angle(const MSLVector& w) const;
00057 MSLVector rotate90() const;
00058 MSLVector rotate(double a) const;
00059 MSLVector& operator+=(const MSLVector&);
00060 MSLVector& operator-=(const MSLVector&);
00061 MSLVector operator+(const MSLVector& v1) const;
00062 MSLVector operator-(const MSLVector& v1) const;
00063 double operator*(const MSLVector& v1) const;
00064 MSLVector operator*(double r) const;
00065 MSLVector operator-() const;
00066 MSLVector operator/(double) const;
00067 bool operator==(const MSLVector& w) const;
00068 bool operator!=(const MSLVector& w) const { return !(*this == w); }
00069 friend MSLVector operator*(double f, const MSLVector& v) { return v *f; }
00070 void print(ostream& O);
00071 void print() { print(cout); }
00072 void read(istream& I);
00073 void read() { read(cin); }
00074 friend ostream& operator<<(ostream& O, const MSLVector& v);
00075 friend istream& operator>>(istream& I, MSLVector& v);
00076 friend istream& operator>>(istream& is, list<MSLVector> & vl);
00077 friend ostream& operator<<(ostream& os, const list<MSLVector> & vl);
00078 friend istream& operator>>(istream& is, vector<MSLVector> & vl);
00079 friend ostream& operator<<(ostream& os, const vector<MSLVector> & vl);
00080 };
00081
00082
00083 #endif