aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/YAGE/Math/matrix.hpp11
-rw-r--r--test/matrix_test.cpp14
-rw-r--r--test/rigid_body_test.cpp2
3 files changed, 18 insertions, 9 deletions
diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp
index 76c90c16..2ada55eb 100644
--- a/include/YAGE/Math/matrix.hpp
+++ b/include/YAGE/Math/matrix.hpp
@@ -9,9 +9,11 @@ namespace yage
template<int Rows, int Cols, class Type> class Matrix;
+namespace detail
+{
+
template<int Rows, int Cols, class Type> class Row
{
- friend class Matrix<Rows, Cols, Type>;
private:
std::shared_ptr<Matrix<Rows, Cols, Type>> parent_;
int index_;
@@ -27,8 +29,11 @@ public:
}
};
+} // detail
+
template<int Rows=4, int Cols=4, class Type=double> class Matrix
{
+ friend class detail::Row<Rows, Cols, Type>;
private:
std::vector<Type> data_;
@@ -36,9 +41,9 @@ public:
Matrix<Rows, Cols, Type>() : data_(Rows*Cols) {}
Matrix<Rows, Cols, Type>(int rows, int cols) : data_(rows*cols) {}
- Row<Rows, Cols, Type> operator[](int row)
+ detail::Row<Rows, Cols, Type> operator[](int row)
{
- return Row<Rows, Cols, Type>(std::make_shared<Matrix<Rows, Cols, Type>>(*this), row);
+ return detail::Row<Rows, Cols, Type>(std::make_shared<Matrix<Rows, Cols, Type>>(*this), row);
}
};
diff --git a/test/matrix_test.cpp b/test/matrix_test.cpp
index ba1f0d4a..e975794f 100644
--- a/test/matrix_test.cpp
+++ b/test/matrix_test.cpp
@@ -4,10 +4,14 @@
int main()
{
- yage::Matrix<4, 4, int> matrix;
+ yage::Matrix<4, 4> matrix;
- int x=matrix[2][2];
-
- std::cout<<"at: "<<x<<'\n';
- return 0;
+ double x=matrix[2][2];
+ matrix[2][2]=4;
+
+ std::cout<<"at: "<<x<<", "<<matrix[2][2]<<'\n';
+
+ if(matrix[2][2]==4 && x==0)
+ return 0;
+ return 1;
}
diff --git a/test/rigid_body_test.cpp b/test/rigid_body_test.cpp
index 57ba1162..c5683697 100644
--- a/test/rigid_body_test.cpp
+++ b/test/rigid_body_test.cpp
@@ -1,4 +1,4 @@
-#include "particlebody.hpp"
+#include "Physics/particlebody.hpp"
#include <iostream>