aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-05-26 23:43:10 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-05-26 23:43:10 +0100
commit4c16cca26bdae09525c04665b536da98beb4c76f (patch)
tree0a3ba29199ed13aaf34b8e624da08719793d1df4 /include
parent89c11e6679346e77ee32eb1343d3cf4e7d429a46 (diff)
downloadYAGE-4c16cca26bdae09525c04665b536da98beb4c76f.tar.gz
YAGE-4c16cca26bdae09525c04665b536da98beb4c76f.zip
Creating matrix
Diffstat (limited to 'include')
-rw-r--r--include/YAGE/Math/matrix.hpp32
-rw-r--r--include/YAGE/Math/vector.hpp151
-rw-r--r--include/YAGE/Math/vector2d.hpp20
3 files changed, 32 insertions, 171 deletions
diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp
new file mode 100644
index 00000000..b6807c09
--- /dev/null
+++ b/include/YAGE/Math/matrix.hpp
@@ -0,0 +1,32 @@
+#ifndef YAGE_MATH_MATRIX_HPP
+#define YAGE_MATH_MATRIX_HPP
+
+namespace yage
+{
+
+template<typename Type, int Cols, int Rows> class Matrix
+{
+private:
+ Type x[Cols][Rows];
+
+public:
+ Matrix()
+ {
+ for(int i=0; i<Cols; ++i)
+ {
+ for(int j=0; j<Rows; ++j)
+ {
+ x[i][j]=5;
+ }
+ }
+ }
+
+ Type get(int i, int j) const
+ {
+ return x[i][j];
+ }
+};
+
+} // yage
+
+#endif
diff --git a/include/YAGE/Math/vector.hpp b/include/YAGE/Math/vector.hpp
deleted file mode 100644
index 5f3161df..00000000
--- a/include/YAGE/Math/vector.hpp
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef YAGE_MATH_VECTOR_HPP
-#define YAGE_MATH_VECTOR_HPP
-
-#include <ostream>
-#include <vector>
-
-namespace yage
-{
-
-class Vector
-{
-protected:
- std::vector<long double> members_;
-
-public:
- Vector()=delete;
- virtual ~Vector() {}
-
- inline long double &operator[](std::size_t index)
- {
- return members_[index];
- }
-
- inline const long double &operator[](std::size_t index) const
- {
- return members_[index];
- }
-
- inline Vector operator=(Vector other)
- {
- this->members_=other.members_;
- return *this;
- }
-
- inline Vector &operator+()
- {
- return *this;
- }
-
- inline Vector &operator-()
- {
- for(auto &i : members_)
- {
- i=-i;
- }
- return *this;
- }
-
- inline Vector &operator+=(const Vector &other)
- {
- for(std::size_t i=0; i<members_.size(); ++i)
- {
- members_[i]+=other[i];
- }
- return *this;
- }
-
- inline Vector &operator-=(const Vector &other)
- {
- for(std::size_t i=0; i<members_.size(); ++i)
- {
- members_[i]-=other[i];
- }
- return *this;
- }
-
- inline Vector &operator*=(const Vector &other)
- {
- for(std::size_t i=0; i<members_.size(); ++i)
- {
- members_[i]*=other[i];
- }
- return *this;
- }
-
- inline Vector operator+(Vector other) const
- {
- Vector v(members_);
- return v+=other;
- }
-
- inline Vector operator-(const Vector &other) const
- {
- Vector v(members_);
- return v-=other;
- }
-
- inline Vector operator*(const Vector &other) const
- {
- Vector v(members_);
- return v*=other;
- }
-
- inline Vector operator+(long double other) const
- {
- std::vector<long double> mem;
- for(auto i : members_)
- {
- mem.emplace_back(i+other);
- }
- return Vector(mem);
- }
-
- inline Vector operator-(long double other) const
- {
- std::vector<long double> mem;
- for(auto i : members_)
- {
- mem.emplace_back(i-other);
- }
- return Vector(mem);
- }
-
- inline Vector operator*(long double other) const
- {
- std::vector<long double> mem;
- for(auto i : members_)
- {
- mem.emplace_back(i*other);
- }
- return Vector(mem);
- }
-
- inline Vector operator/(long double other) const
- {
- std::vector<long double> mem;
- for(auto i : members_)
- {
- mem.emplace_back(i/other);
- }
- return Vector(mem);
- }
-
- friend inline std::ostream &operator<<(std::ostream &os, const Vector &object)
- {
- os<<"(";
- for(std::size_t i=0; i<object.members_.size()-1; ++i)
- {
- os<<object.members_[i]<<", ";
- }
- os<<object.members_[object.members_.size()-1]<<")";
- return os;
- }
-
-protected:
- Vector(const std::vector<long double> &members) : members_(members) {}
-};
-
-} // yage
-
-#endif
diff --git a/include/YAGE/Math/vector2d.hpp b/include/YAGE/Math/vector2d.hpp
deleted file mode 100644
index 1a6d2856..00000000
--- a/include/YAGE/Math/vector2d.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef YAGE_MATH_VECTOR2D_HPP
-#define YAGE_MATH_VECTOR2D_HPP
-
-#include "vector.hpp"
-
-namespace yage
-{
-
-class Vector2D : public Vector
-{
-public:
- Vector2D(long double x=0.L, long double y=0.L);
-
- long double getX() const;
- long double getY() const;
-};
-
-} // yage
-
-#endif