You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vectorxd.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef VECTORXD_H
  2. #define VECTORXD_H
  3. #include <QDebug>
  4. #define tmplx template<unsigned X>
  5. #define tmpl template<unsigned X, class T>
  6. tmpl class GenericVector
  7. {
  8. public:
  9. T& setScalar(unsigned i, double value);
  10. double getScalar(unsigned i) const;
  11. bool isNull() const;
  12. bool equal(const T& other) const;
  13. T& add(double k);
  14. T& add(double scalars[X]);
  15. T& add(const T& other);
  16. T& sub(double k);
  17. T& sub(double scalars[X]);
  18. T& sub(const T& other);
  19. T& mult(double k);
  20. T& mult(double scalars[X]);
  21. T& mult(const T& other);
  22. T& div(double k);
  23. T& div(double scalars[X]);
  24. T& div(const T& other);
  25. double dotProduct(const T& other) const;
  26. T& crossProduct(const T& other);
  27. static T crossProduct(const T &v1, const T &v2);
  28. double norm() const;
  29. T operator+() const;
  30. T operator+(const double& k) const;
  31. T& operator+=(const double& k);
  32. T operator+(const T& other) const;
  33. T& operator+=(const T& other);
  34. T operator-() const;
  35. T operator-(const double& k) const;
  36. T& operator-=(const double& k);
  37. T operator-(const T& other) const;
  38. T& operator-=(const T& other);
  39. T operator*(const double& k) const;
  40. T& operator*=(const double& k);
  41. T operator*(const T& other) const;
  42. T& operator*=(const T& other);
  43. T operator/(const double& k) const;
  44. T& operator/=(const double& k);
  45. bool operator==(const T& other) const;
  46. bool operator!=(const T& other) const;
  47. double operator[](unsigned i) const;
  48. bool operator!() const;
  49. operator bool() const;
  50. protected:
  51. double _scalars[X];
  52. private:
  53. T* getThis() const;
  54. };
  55. tmplx class VectorXD: public GenericVector<X, VectorXD<X> >
  56. {
  57. public:
  58. VectorXD();
  59. VectorXD(const double scalars[X]);
  60. VectorXD(const VectorXD<X>& other);
  61. protected:
  62. using GenericVector<X, VectorXD<X> >::_scalars;
  63. };
  64. tmplx QDebug operator<<(QDebug dbg, const VectorXD<X>& v);
  65. #include "vectorxd.hxx"
  66. #endif // VECTORXD_H