29d28 < #include 195,305d193 < < /** --------------------------------------------------------- **/ < < /** < @short complex vector base class < @header Goptical/MathVector < @module {Core} < < This class is the base class for N dimensional complex vector. < */ < template struct CVectorBase < { < inline CVectorBase() {}; < /** Set the whole vector to the specified value */ < inline CVectorBase(std::complex value); < /** Set the whole vector to the specified value */ < inline void set(std::complex value); < /** Get value at specified index */ < inline std::complex operator[](int n) const; < /** Get reference to value at specified index */ < inline std::complex & operator[](int n); < /** Add two vectors */ < inline CVectorBase operator+(const CVectorBase &v) const; < /** Subtract two vectors */ < inline CVectorBase operator-(const CVectorBase &v) const; < /** Get negated vector */ < inline CVectorBase operator-() const; < /** Negate vector */ < inline CVectorBase & neg(); < /** Add a vector */ < inline const CVectorBase & operator+=(const CVectorBase &v); < /** Sutract a vector */ < inline const CVectorBase & operator-=(const CVectorBase &v); < /** CVector scalar multiply */ < inline std::complex operator*(const CVectorBase &v) const; < /** CVector values multiply */ < inline CVectorBase mul(const CVectorBase &v) const; < /** Scale vector */ < inline CVectorBase operator*(std::complex scale) const; < /** Scale vector */ < inline CVectorBase operator/(std::complex scale) const; < /** CVector division */ < inline CVectorBase operator/(const CVectorBase &v) const; < /** Multiply by a vector */ < inline const CVectorBase & operator*=(std::complex scale); < /** Divide by a vector */ < inline const CVectorBase & operator/=(std::complex scale); < /** Compute vector length */ < inline std::complex len() const; < /** Normalize vector length */ < inline const CVectorBase & normalize(); < /** Get normalize vector */ < inline CVectorBase normalized() const; < /** Adjust vector length */ < inline CVectorBase magnitude(std::complex newlen) const; < /** Extract value at index and get other values from v vector */ < inline CVectorBase select(unsigned int index, const CVectorBase v) const; < /** Multiply vector with matrix. See CVector class for < matrix/vector multiplication. */ < inline CVectorBase operator*(const Matrix &m); < /** compare two vectors for equality */ < inline bool operator==(const CVectorBase &m) const; < < protected: < std::complex _val[N]; < }; < < /** < @short N dimensional complex vector class < @header Goptical/MathVector < @module {Core} < < This class is the general purpose N dimensional complex vector class. < */ < template struct CVector : public CVectorBase < { < inline CVector(); < inline CVector(const CVectorBase &v); < }; < < /** < @short 2d complex vector class < @header Goptical/MathCVector < @module {Core} < < This class is the 2d complex vector class. < */ < template <> struct CVector<2> : public CVectorBase<2> < { < inline CVector(); < < /** Copy constructor */ < inline CVector(const CVectorBase<2> &v); < /** Create a 2d vector from x and y z values */ < inline CVector(std::complex x, std::complex y); < < inline std::complex perp_product(const CVector<2> &v) const; < < /** Get reference to vector x value */ < inline std::complex & x(); < /** Get reference to vector y value */ < inline std::complex & y(); < /** Get vector x value */ < inline std::complex x() const; < /** Get vector y value */ < inline std::complex y() const; < }; < < template < std::ostream & operator<<(std::ostream &o, const CVectorBase &v); <