Explorar o código

Moving matrix into submodule

Samuel Jaffe %!s(int64=9) %!d(string=hai) anos
pai
achega
8710739633
Modificáronse 8 ficheiros con 15 adicións e 572 borrados
  1. 3 0
      .gitmodules
  2. 1 1
      include/json
  3. 9 115
      math/math.xcodeproj/project.pbxproj
  4. 1 0
      math/matrix
  5. 0 265
      math/matrix.hpp
  6. 0 107
      math/matrix.t.h
  7. 0 83
      math/matrix_helpers.hpp
  8. 1 1
      math/vector

+ 3 - 0
.gitmodules

@@ -11,3 +11,6 @@
 [submodule "math/vector"]
 	path = math/vector
 	url = freenas:utility/vector
+[submodule "math/matrix"]
+	path = math/matrix
+	url = freenas:utility/matrix

+ 1 - 1
include/json

@@ -1 +1 @@
-Subproject commit 357524597efe513068eec2e31a82dc976c31d085
+Subproject commit cc5508c5d8b1c86ad91ab59362aca900efaebca6

+ 9 - 115
math/math.xcodeproj/project.pbxproj

@@ -8,46 +8,29 @@
 
 /* Begin PBXBuildFile section */
 		CD0E42491D9B3673002FFED1 /* vector.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD0E42481D9B3673002FFED1 /* vector.hpp */; };
-		CD37862D1CFA121C00BE89B2 /* matrix.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD37862C1CFA121C00BE89B2 /* matrix.hpp */; };
 		CD3AC71E1D2C0AF8002B4BB0 /* shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3AC71C1D2C0AF8002B4BB0 /* shape.cpp */; };
 		CD3AC71F1D2C0AF8002B4BB0 /* shape.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3AC71D1D2C0AF8002B4BB0 /* shape.hpp */; };
 		CD3C808A1D66469400ACC795 /* math_fwd.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3AC6FA1D2C0558002B4BB0 /* math_fwd.hpp */; };
-		CD3C809A1D6654C200ACC795 /* matrix_tc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3C80981D6654C200ACC795 /* matrix_tc.cpp */; };
 		CD3C809F1D675AB100ACC795 /* angle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3C809D1D675AB100ACC795 /* angle.cpp */; };
 		CD3C80A01D675AB100ACC795 /* angle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3C809E1D675AB100ACC795 /* angle.hpp */; };
-		CD3C80B11D67B79B00ACC795 /* libmath.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD3786181CF9F61100BE89B2 /* libmath.dylib */; };
-		CD3C80B91D6884D700ACC795 /* matrix_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3C80B81D6884D700ACC795 /* matrix_helpers.hpp */; };
 		CD3C80BC1D68902300ACC795 /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3C80BA1D68902300ACC795 /* common.cpp */; };
 		CD3C80BD1D68902300ACC795 /* common.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3C80BB1D68902300ACC795 /* common.hpp */; };
+		CD3DA3DD1D9B3F85001B53A0 /* matrix_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3DA3DB1D9B3F85001B53A0 /* matrix_helpers.hpp */; };
+		CD3DA3DE1D9B3F85001B53A0 /* matrix.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CD3DA3DC1D9B3F85001B53A0 /* matrix.hpp */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXCopyFilesBuildPhase section */
-		CD3C808F1D6654A400ACC795 /* CopyFiles */ = {
-			isa = PBXCopyFilesBuildPhase;
-			buildActionMask = 2147483647;
-			dstPath = /usr/share/man/man1/;
-			dstSubfolderSpec = 0;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 1;
-		};
-/* End PBXCopyFilesBuildPhase section */
-
 /* Begin PBXFileReference section */
 		CD0E42481D9B3673002FFED1 /* vector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = vector.hpp; path = vector/vector.hpp; sourceTree = "<group>"; };
 		CD3786181CF9F61100BE89B2 /* libmath.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmath.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD37862C1CFA121C00BE89B2 /* matrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = matrix.hpp; sourceTree = "<group>"; };
 		CD3AC6FA1D2C0558002B4BB0 /* math_fwd.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = math_fwd.hpp; sourceTree = "<group>"; };
 		CD3AC71C1D2C0AF8002B4BB0 /* shape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shape.cpp; sourceTree = "<group>"; };
 		CD3AC71D1D2C0AF8002B4BB0 /* shape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = shape.hpp; sourceTree = "<group>"; };
-		CD3C80911D6654A400ACC795 /* matrix_tc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = matrix_tc; sourceTree = BUILT_PRODUCTS_DIR; };
-		CD3C80981D6654C200ACC795 /* matrix_tc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = matrix_tc.cpp; sourceTree = "<group>"; };
-		CD3C80991D6654C200ACC795 /* matrix.t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = matrix.t.h; sourceTree = "<group>"; };
 		CD3C809D1D675AB100ACC795 /* angle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = angle.cpp; sourceTree = "<group>"; };
 		CD3C809E1D675AB100ACC795 /* angle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = angle.hpp; sourceTree = "<group>"; };
-		CD3C80B81D6884D700ACC795 /* matrix_helpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = matrix_helpers.hpp; sourceTree = "<group>"; };
 		CD3C80BA1D68902300ACC795 /* common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common.cpp; sourceTree = "<group>"; };
 		CD3C80BB1D68902300ACC795 /* common.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = common.hpp; sourceTree = "<group>"; };
+		CD3DA3DB1D9B3F85001B53A0 /* matrix_helpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = matrix_helpers.hpp; path = matrix/matrix_helpers.hpp; sourceTree = "<group>"; };
+		CD3DA3DC1D9B3F85001B53A0 /* matrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = matrix.hpp; path = matrix/matrix.hpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -58,14 +41,6 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CD3C808E1D6654A400ACC795 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				CD3C80B11D67B79B00ACC795 /* libmath.dylib in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
@@ -82,7 +57,6 @@
 			isa = PBXGroup;
 			children = (
 				CD3786181CF9F61100BE89B2 /* libmath.dylib */,
-				CD3C80911D6654A400ACC795 /* matrix_tc */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -90,10 +64,10 @@
 		CD3786321CFA304800BE89B2 /* src */ = {
 			isa = PBXGroup;
 			children = (
-				CD0E42481D9B3673002FFED1 /* vector.hpp */,
 				CD3AC6FA1D2C0558002B4BB0 /* math_fwd.hpp */,
-				CD37862C1CFA121C00BE89B2 /* matrix.hpp */,
-				CD3C80B81D6884D700ACC795 /* matrix_helpers.hpp */,
+				CD0E42481D9B3673002FFED1 /* vector.hpp */,
+				CD3DA3DB1D9B3F85001B53A0 /* matrix_helpers.hpp */,
+				CD3DA3DC1D9B3F85001B53A0 /* matrix.hpp */,
 				CD3AC71C1D2C0AF8002B4BB0 /* shape.cpp */,
 				CD3AC71D1D2C0AF8002B4BB0 /* shape.hpp */,
 				CD3C809D1D675AB100ACC795 /* angle.cpp */,
@@ -107,8 +81,6 @@
 		CD3C80791D66440200ACC795 /* test */ = {
 			isa = PBXGroup;
 			children = (
-				CD3C80991D6654C200ACC795 /* matrix.t.h */,
-				CD3C80981D6654C200ACC795 /* matrix_tc.cpp */,
 			);
 			name = test;
 			sourceTree = "<group>";
@@ -120,13 +92,13 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CD3DA3DE1D9B3F85001B53A0 /* matrix.hpp in Headers */,
 				CD3AC71F1D2C0AF8002B4BB0 /* shape.hpp in Headers */,
-				CD37862D1CFA121C00BE89B2 /* matrix.hpp in Headers */,
 				CD3C80A01D675AB100ACC795 /* angle.hpp in Headers */,
 				CD0E42491D9B3673002FFED1 /* vector.hpp in Headers */,
 				CD3C808A1D66469400ACC795 /* math_fwd.hpp in Headers */,
 				CD3C80BD1D68902300ACC795 /* common.hpp in Headers */,
-				CD3C80B91D6884D700ACC795 /* matrix_helpers.hpp in Headers */,
+				CD3DA3DD1D9B3F85001B53A0 /* matrix_helpers.hpp in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -150,24 +122,6 @@
 			productReference = CD3786181CF9F61100BE89B2 /* libmath.dylib */;
 			productType = "com.apple.product-type.library.dynamic";
 		};
-		CD3C80901D6654A400ACC795 /* matrix_tc */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = CD3C80951D6654A400ACC795 /* Build configuration list for PBXNativeTarget "matrix_tc" */;
-			buildPhases = (
-				CD3C809B1D66556900ACC795 /* ShellScript */,
-				CD3C808D1D6654A400ACC795 /* Sources */,
-				CD3C808E1D6654A400ACC795 /* Frameworks */,
-				CD3C808F1D6654A400ACC795 /* CopyFiles */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = matrix_tc;
-			productName = matrix_tc;
-			productReference = CD3C80911D6654A400ACC795 /* matrix_tc */;
-			productType = "com.apple.product-type.tool";
-		};
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
@@ -180,9 +134,6 @@
 					CD3786171CF9F61100BE89B2 = {
 						CreatedOnToolsVersion = 7.2.1;
 					};
-					CD3C80901D6654A400ACC795 = {
-						CreatedOnToolsVersion = 7.2.1;
-					};
 				};
 			};
 			buildConfigurationList = CD3786131CF9F61100BE89B2 /* Build configuration list for PBXProject "math" */;
@@ -198,28 +149,10 @@
 			projectRoot = "";
 			targets = (
 				CD3786171CF9F61100BE89B2 /* math */,
-				CD3C80901D6654A400ACC795 /* matrix_tc */,
 			);
 		};
 /* End PBXProject section */
 
-/* Begin PBXShellScriptBuildPhase section */
-		CD3C809B1D66556900ACC795 /* ShellScript */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputPaths = (
-				"$(SRCROOT)/matrix.t.h",
-			);
-			outputPaths = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "cxxtestgen --error-printer -o matrix_tc.cpp matrix.t.h";
-		};
-/* End PBXShellScriptBuildPhase section */
-
 /* Begin PBXSourcesBuildPhase section */
 		CD3786141CF9F61100BE89B2 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
@@ -231,14 +164,6 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CD3C808D1D6654A400ACC795 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				CD3C809A1D6654C200ACC795 /* matrix_tc.cpp in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXSourcesBuildPhase section */
 
 /* Begin XCBuildConfiguration section */
@@ -349,28 +274,6 @@
 			};
 			name = Release;
 		};
-		CD3C80961D6654A400ACC795 /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_GENERATE_TEST_COVERAGE_FILES = YES;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
-				HEADER_SEARCH_PATHS = /usr/local/include;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				USER_HEADER_SEARCH_PATHS = ..;
-			};
-			name = Debug;
-		};
-		CD3C80971D6654A400ACC795 /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_GENERATE_TEST_COVERAGE_FILES = NO;
-				GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO;
-				HEADER_SEARCH_PATHS = /usr/local/include;
-				PRODUCT_NAME = "$(TARGET_NAME)";
-				USER_HEADER_SEARCH_PATHS = ..;
-			};
-			name = Release;
-		};
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
@@ -392,15 +295,6 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
-		CD3C80951D6654A400ACC795 /* Build configuration list for PBXNativeTarget "matrix_tc" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				CD3C80961D6654A400ACC795 /* Debug */,
-				CD3C80971D6654A400ACC795 /* Release */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
-		};
 /* End XCConfigurationList section */
 	};
 	rootObject = CD3786101CF9F61100BE89B2 /* Project object */;

+ 1 - 0
math/matrix

@@ -0,0 +1 @@
+Subproject commit ac1800bcb7a133b6b513c3efdd7125c0d54d2954

+ 0 - 265
math/matrix.hpp

@@ -1,265 +0,0 @@
-//
-//  matrix.hpp
-//  math
-//
-//  Created by Sam Jaffe on 5/28/16.
-//
-
-#pragma once
-
-#include "vector.hpp"
-
-#include "util/expect.hpp"
-
-namespace math { namespace matrix {
-  
-  template <typename T>
-  struct is_matrix { static const constexpr bool value = false; };
-  
-  template <typename T, std::size_t R, std::size_t C>
-  class matrix;
-  template <typename T, size_t R, size_t C>
-  struct is_matrix<matrix<T, R, C> > { static const constexpr bool value = true; };
-  
-  namespace concat_strategy {
-    struct {} horizonal;
-    using horizontal_concat_t = decltype(horizonal);
-    struct {} vertical;
-    using vertical_concat_t = decltype(vertical);
-    struct {} diagonal;
-    using diagonal_concat_t = decltype(diagonal);
-  };
-  
-#define MATRIX_DISABLE_IF_MATRIX(_type, t, r, c) \
-typename std::enable_if<!is_matrix<_type>::value, matrix<t, r, c> >::type
-  
-#define MATRIX_FOR_EACH_RANGE(i, i_max, j, j_max) for (size_t i = 0; i < i_max; ++i) for (size_t j = 0; j < j_max; ++j)
-#define MATRIX_FOR_EACH(i, j) MATRIX_FOR_EACH_RANGE(i, R, j, C)
-  
-  template <typename T, std::size_t R, std::size_t C>
-  class matrix {
-  public:
-    using value_type = T;
-    
-    template <typename M>
-    using mul_t = decltype(std::declval<T>()*std::declval<M>());
-    template <typename M>
-    using div_t = decltype(std::declval<T>()/std::declval<M>());
-  public:
-    
-    template <typename S>
-    class row_reference {
-    public:
-      row_reference(S ( & h )[C]) : _handle(h) {}
-      row_reference(row_reference const &) = delete;
-
-      row_reference & operator=(row_reference const & other) {
-        return operator=<S>(other);
-      }
-      template <typename S2>
-      row_reference & operator=(row_reference<S2> const & other) {
-        VECTOR_FOR_EACH_RANGE(i, C) { _handle[i] = other[i]; }
-        return *this;
-      }
-
-      S const & operator[](std::size_t col) const { return _handle[col]; }
-      S & operator[](std::size_t col) { return _handle[col]; }
-      S const & at(std::size_t col) const {
-        expects(col < C, std::out_of_range, "column index out of range");
-        return operator[](col);
-      }
-      S & at(std::size_t col) {
-        expects(col < C, std::out_of_range, "column index out of range");
-        return operator[](col);
-      }
-      
-    private:
-      S ( & _handle )[C];
-    };
-    
-    matrix() = default;
-    matrix(std::array<std::array<T, C>, R> const & init) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] = init[i][j];
-      }
-    }
-    matrix(std::initializer_list<std::array<T, C>> const & init) {
-      expects(init.size() == R, "initializer size mismatch");
-      size_t i = 0;
-      for (auto it = init.begin(), end = init.end(); it != end && i < R; ++it, ++i) {
-        for (size_t j = 0; j < C; ++j) {
-          _data[i][j] = (*it)[j];
-        }
-      }
-    }
-    template <size_t N>
-    matrix(vector::vector<typename std::enable_if<C == 1 && N == R, T>::type, N> const & other) {
-      VECTOR_FOR_EACH(i) {
-        _data[i][0] = other[i];
-      }
-    }
-    matrix(matrix const& other) {
-      *this = other;
-    }
-    matrix(matrix && other) {
-      *this = std::move(other);
-    }
-    matrix & operator=(matrix const& other) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] = other._data[i][j];
-      }
-      return *this;
-    }
-    matrix & operator=(matrix && other) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] = std::move(other._data[i][j]);
-      }
-      return *this;
-    }
-    
-    template <size_t R2, size_t C2>
-    matrix(matrix<T, R2, C2> const & other) {
-      MATRIX_FOR_EACH_RANGE(i, std::min(R, R2), j, std::min(C, C2)) {
-        _data[i][j] = other(i, j);
-      }
-    }
-    
-    matrix<T, C, R> transpose() const {
-      matrix<T, C, R> out;
-      MATRIX_FOR_EACH(i, j) { out(j,i) = _data[i][j]; }
-      return out;
-    }
-    
-    template <size_t C2>
-    matrix<T, R, C + C2> concat(matrix<T, R, C2> const & other, concat_strategy::horizontal_concat_t) const {
-      matrix<T, R, C + C2> accum{*this};
-      MATRIX_FOR_EACH_RANGE(i, R, j, C2) { accum(i, j + C) = other(i, j); }
-      return accum;
-    }
-    
-    template <size_t R2>
-    matrix<T, R + R2, C> concat(matrix<T, R2, C> const & other, concat_strategy::vertical_concat_t) const {
-      matrix<T, R + R2, C> accum{*this};
-      MATRIX_FOR_EACH_RANGE(i, R2, j, C) { accum(i + R, j) = other(i, j); }
-      return accum;
-    }
-    
-    template <size_t R2, size_t C2>
-    matrix<T, R + R2, C + C2> concat(matrix<T, R2, C2> const & other, concat_strategy::diagonal_concat_t) const {
-      matrix<T, R + R2, C + C2> accum{*this};
-      MATRIX_FOR_EACH_RANGE(i, R2, j, C2) { accum(i + R, j + C) = other(i, j); }
-      return accum;
-    }
-    
-    T const & operator()(std::size_t row, std::size_t col) const {
-      return _data[row][col];
-    }
-    T & operator()(std::size_t row, std::size_t col) {
-      return _data[row][col];
-    }
-    row_reference<const T> operator[](std::size_t row) const {
-      return { _data[row] };
-    }
-    row_reference<T> operator[](std::size_t row) {
-      return { _data[row] };
-    }
-    row_reference<const T> at(std::size_t row) const {
-      expects(row >= R, std::out_of_range, "row index out of range");
-      return operator[](row);
-    }
-    row_reference<T> at(std::size_t row) {
-      expects(row >= R, std::out_of_range, "row index out of range");
-      return operator[](row);
-    }
-    value_type const & at(std::size_t row, std::size_t col) const {
-      expects(row < R && col < C, std::out_of_range, "coordinates out of range");
-      return _data[row][col];
-    }
-    value_type & at(std::size_t row, std::size_t col) {
-      expects(row < R && col < C, std::out_of_range, "coordinates out of range");
-      return _data[row][col];
-    }
-    
-    matrix& operator+=(matrix const & other) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] += other[i][j];
-      }
-      return *this;
-    }
-    matrix operator+(matrix const & other) const {
-      return matrix{*this} += other;
-    }
-    matrix& operator-=(matrix const & other) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] -= other[i][j];
-      }
-      return *this;
-    }
-    matrix operator-(matrix const & other) const {
-      return matrix{*this} -= other;
-    }
-    
-    vector::vector<T, C> operator*(vector::vector<T, C> const & vec) const {
-      vector::vector<T, C> rval;
-      MATRIX_FOR_EACH(i, j) {
-        rval[i] += _data[i][j] * vec[j];
-      }
-      return rval;
-    }
-    
-    template <std::size_t C2>
-    matrix<T, R, C2> operator*(matrix<T, C, C2> const & other) const {
-      matrix<T, R, C2> rval;
-      MATRIX_FOR_EACH(i, j) {
-        for (size_t k = 0; k < C2; ++k) {
-          rval[i][k] += _data[i][j] * other[j][k];
-        }
-      }
-      return rval;
-    }
-    
-    matrix<T, R, C>& operator*=(T c) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] *= c;
-      }
-      return *this;
-    }
-    
-    template <typename M>
-    MATRIX_DISABLE_IF_MATRIX(M, mul_t<M>, R, C) operator*(M c) const {
-      return matrix<mul_t<M>, R, C>{*this} *= c;
-    }
-    
-    template <typename M>
-    friend MATRIX_DISABLE_IF_MATRIX(M, mul_t<M>, R, C) operator*(M c, matrix const& matr) {
-      return matrix<mul_t<M>, R, C>{matr} *= c;
-    }
-    
-    template <typename M>
-    matrix<div_t<M>, R, C>& operator/=(M c) {
-      MATRIX_FOR_EACH(i, j) {
-        _data[i][j] /= c;
-      }
-      return *this;
-    }
-    template <typename M>
-    matrix<div_t<M>, R, C> operator/(M c) const {
-      return matrix<mul_t<M>, R, C>{*this} /= c;
-    }
-    
-    bool operator==(matrix const & other) const {
-      MATRIX_FOR_EACH(i, j) {
-        if (_data[i][j] != other._data[i][j]) {
-          return false;
-        }
-      }
-      return true;
-    }
-    bool operator!=(matrix const & other) const {
-      return !operator==(other);
-    }
-  private:
-    value_type _data[R][C] = {value_type()};
-  };
-
-} }

+ 0 - 107
math/matrix.t.h

@@ -1,107 +0,0 @@
-//
-//  matrix_tc.h
-//  math
-//
-//  Created by Sam Jaffe on 8/18/16.
-//
-#pragma once
-
-#include <cxxtest/TestSuite.h>
-
-#include "matrix.hpp"
-#include "matrix_helpers.hpp"
-#include "angle.hpp"
-
-class matrix_TestSuite : public CxxTest::TestSuite {
-public:
-  using matr2i = math::matrix::matrix<int, 2, 2>;
-  using matr2 = math::matrix::matrix<double, 2, 2>;
-public:
-  void test_matrix_equals() const {
-    using math::matrix::identity;
-    TS_ASSERT_EQUALS((identity<int, 2>()), (matr2i{{1,0},{0,1}}));
-  }
-  
-  void test_matrix_sum() const {
-    auto iden = math::matrix::identity<int, 2>();
-    auto result = matr2i{{2,0},{0,2}};
-    TS_ASSERT_EQUALS(iden + iden, result);
-  }
-  
-  void test_matrix_default_zero() const {
-    auto zero = matr2i{{0,0},{0,0}};
-    TS_ASSERT_EQUALS(matr2i{}, zero);
-  }
-
-  void test_matrix_subtract() const {
-    auto zero = matr2i{{0,0},{0,0}};
-    auto iden = math::matrix::identity<int, 2>();
-    TS_ASSERT_EQUALS(iden-iden, zero);
-  }
-  
-//  void test_matrix_negate() const {
-//    auto iden = math::matrix::identity<int, 2>();
-//    TS_ASSERT_EQUALS(-iden, (matr2i{{-1,0},{0,-1}}));
-//  }
-  
-  void test_matrix_scaling() const {
-    auto iden = math::matrix::identity<double, 2>();
-    TS_ASSERT_EQUALS(2*iden, (matr2{{2.0,0.0},{0.0,2.0}}));
-    TS_ASSERT_EQUALS(iden*2, (matr2{{2.0,0.0},{0.0,2.0}}));
-    TS_ASSERT_EQUALS(iden/2.0, (matr2{{0.5,0.0},{0.0,0.5}}));
-  }
-  
-  void test_matrix_multiplication_same_dim() const {
-    auto A = matr2i{{1,2},{2,3}};
-    auto B = matr2i{{1,0},{1,1}};
-    TS_ASSERT_EQUALS(A*B, (matr2i{{3,2},{5,3}}));
-    TS_ASSERT_EQUALS(B*A, (matr2i{{1,2},{3,5}}));
-  }
-  
-  void test_matrix_multiplication_diff_dim() const {
-    auto A = math::matrix::matrix<int, 3, 2>{{1,0},{0,1},{1,1}};
-    auto B = math::matrix::matrix<int, 2, 3>{{0,1,0},{1,0,1}};
-    TS_ASSERT_EQUALS(A*B, (math::matrix::matrix<int, 3, 3>{{0,1,0},{1,0,1},{1,1,1}}));
-    TS_ASSERT_EQUALS(B*A, (math::matrix::matrix<int, 2, 2>{{0,1},{2,1}}));
-  }
-  
-  void test_matrix_vector_multiplication() const {
-    auto A = matr2i{{1,0},{1,2}};
-    auto x = math::vector::vector<int, 2>{1,2};
-    TS_ASSERT_EQUALS(A*x, (math::vector::vector<int, 2>{1,5}));
-  }
-  
-  void test_matrix_composition() const {
-    using namespace math::matrix;
-    using vec4 = math::vector::vector<double, 4>;
-    using vec3 = math::vector::vector<double, 3>;
-    auto rot = rotation<4>(math::degree{90}, rotate::X_AXIS);
-    auto mov = translation(vec3{2.0, 2.5, 1.5});
-    auto scl = scalar(vec3{2.0, math::vector::fill});
-    vec4 epsilon{0.00001, math::vector::fill};
-    TS_ASSERT_DELTA((mov * scl * rot * vec4{1,2,3,1}),
-                     (vec4{4.0,-1.5,-4.5,1.0}),
-                    epsilon);
-  }
-  
-  void test_matrix_from_vector() const {
-    using vec3 = math::vector::vector<double, 3>;
-    vec3 v = vec3{1,2,3};
-    math::matrix::matrix<double, 3, 1> m{v};
-    TS_ASSERT_EQUALS(m(0,0), v[0]);
-    TS_ASSERT_EQUALS(m(1,0), v[1]);
-    TS_ASSERT_EQUALS(m(2,0), v[2]);
-  }
-  
-  void test_matrix_init_list_except() const {
-    TS_ASSERT_THROWS((math::matrix::matrix<double, 2, 1>{{1.0}}), std::logic_error);
-  }
-  
-  void test_assign_row() const {
-    matr2i A = math::matrix::identity<int, 2>();
-    matr2i const B = 2 * A;
-    A[0] = B[0];
-    TS_ASSERT_EQUALS(A, (matr2i{{2,0},{0,1}}));
-  }
-private:
-};

+ 0 - 83
math/matrix_helpers.hpp

@@ -1,83 +0,0 @@
-//
-//  matrix_helpers.hpp
-//  math
-//
-//  Created by Sam Jaffe on 8/20/16.
-//
-
-#pragma once
-
-#include "matrix.hpp"
-
-namespace math { namespace matrix {
-  
-  template <typename T, std::size_t N>
-  matrix<T, N, N> identity() {
-    matrix<T, N, N> rval;
-    VECTOR_FOR_EACH(i) { rval.at(i,i) = 1; }
-    return rval;
-  }
-  
-  template <typename T, std::size_t N>
-  matrix<T, N, N> diagonal(vector::vector<T, N> const & vec) {
-    matrix<T, N, N> rval = identity<T, N>();
-    VECTOR_FOR_EACH(i) { rval.at(i,i) = vec[i]; }
-    return rval;
-  }
-  
-  template <typename T, std::size_t N>
-  matrix<T, N+1, N+1> translation(vector::vector<T, N> const & vec) {
-    matrix<T, N+1, N+1> rval = identity<T, N+1>();
-    VECTOR_FOR_EACH(i) { rval.at(i,N) = vec[i]; }
-    return rval;
-  }
-  
-  template <typename T, std::size_t N>
-  matrix<T, N+1, N+1> scalar(vector::vector<T, N> const & vec) {
-    matrix<T, N+1, N+1> rval = identity<T, N+1>();
-    VECTOR_FOR_EACH(i) { rval.at(i,i) = vec[i]; }
-    return rval;
-  }
-  
-  template <size_t N>
-  struct rotation_t {
-    constexpr rotation_t(size_t f, size_t s)
-    : first(f), second(s) {}
-    size_t first, second;
-  };
-  
-  namespace rotate {
-    constexpr rotation_t<3> const X_AXIS{1,2};
-    constexpr rotation_t<3> const Y_AXIS{2,0};
-    constexpr rotation_t<3> const Z_AXIS{0,1};
-    
-    constexpr rotation_t<3> const ROLL{1,2};
-    constexpr rotation_t<3> const PITCH{2,0};
-    constexpr rotation_t<3> const YAW{0,1};
-    
-    constexpr rotation_t<2> const ROT_2D{0,1};
-  }
-  
-  template <typename T, size_t D>
-  auto rotation(T theta, rotation_t<D> r) -> matrix<decltype(sin(theta)), D, D> {
-    static_assert(D >= 2, "cannot rotate with 1D matrix");
-    using G = decltype(sin(theta));
-    using std::sin;
-    using std::cos;
-    matrix<G, D, D> rval = identity<G, D>();
-    G const vsin = sin(theta);
-    G const vcos = cos(theta);
-    rval.at(r.first, r.first) = vcos;
-    rval.at(r.second, r.second) = vcos;
-    rval.at(r.first, r.second) = -vsin;
-    rval.at(r.second, r.first) = vsin;
-    return rval;
-  }
-  
-  template <size_t D, typename T, size_t RD>
-  auto rotation(T theta, rotation_t<RD> r) -> matrix<decltype(sin(theta)), D, D> {
-    using G = decltype(sin(theta));
-    return rotation(theta, r).concat(identity<G, D - RD>(), concat_strategy::diagonal);
-  }
-  
-} }

+ 1 - 1
math/vector

@@ -1 +1 @@
-Subproject commit 2d5980e8d10bcd91f706906d78785ff734f6ac26
+Subproject commit 4ac77cf1691c5f13718b3f55e663426959da9fb4