From 2d27cd79d3cc8d91c2853f5d92363f117610b9aa Mon Sep 17 00:00:00 2001 From: James Goppert Date: Fri, 26 Feb 2016 05:56:21 -0500 Subject: [PATCH] Added scalar to matrix conversion. --- matrix/Scalar.hpp | 6 ++++++ test/matrixAssignment.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/matrix/Scalar.hpp b/matrix/Scalar.hpp index da91ff68bf..111341d797 100644 --- a/matrix/Scalar.hpp +++ b/matrix/Scalar.hpp @@ -49,6 +49,12 @@ public: return _value; } + operator Matrix() const { + Matrix m; + m(0, 0) = _value; + return m; + } + private: Type _value; diff --git a/test/matrixAssignment.cpp b/test/matrixAssignment.cpp index 21557541af..1484a31189 100644 --- a/test/matrixAssignment.cpp +++ b/test/matrixAssignment.cpp @@ -74,6 +74,9 @@ int main() s = 1; TEST(fabs(s - 1) < 1e-5); + Matrix m5 = s; + TEST(fabs(m5(0,0) - s) < 1e-5); + return 0; }