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 2.0KB

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