diff --git a/Makefile.am b/Makefile.am
index 9a28af1f..b6a93ea6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -101,6 +101,7 @@ UTIL_FILES = \
platform.hpp \
point.cpp \
point.hpp \
+ point.ipp \
pool.cpp \
pool.hpp \
pool.ipp \
diff --git a/point.hpp b/point.hpp
index e16399f6..e3e4d5e0 100644
--- a/point.hpp
+++ b/point.hpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
- * Copyright 2011 Danny Robson
+ * Copyright 2011-14 Danny Robson
*/
#ifndef __UTIL_POINT_HPP
@@ -53,7 +53,7 @@ namespace util {
util::vector to (const point&) const;
- template point redim (void);
+ template point redim (void) const;
void sanity (void) const;
};
@@ -68,6 +68,6 @@ namespace util {
std::ostream& operator<< (std::ostream&, const util::point&);
}
-
+#include "point.ipp"
#endif // __UTIL_POINT_HPP
diff --git a/point.ipp b/point.ipp
new file mode 100644
index 00000000..9ff1a486
--- /dev/null
+++ b/point.ipp
@@ -0,0 +1,30 @@
+/*
+ * This file is part of libgim.
+ *
+ * libgim is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * libgim is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libgim. If not, see .
+ *
+ * Copyright 2014 Danny Robson
+ */
+
+#include
+
+namespace util {
+ template
+ template
+ point point::redim (void) const {
+ point out;
+ std::copy (std::begin (this->data), std::begin (this->data) + D, std::begin (out.data));
+ return out;
+ }
+}
diff --git a/test/Makefile.am b/test/Makefile.am
index 3ef75622..fc8a6937 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -15,6 +15,7 @@ TEST_BIN = \
md4 \
md5 \
options \
+ point \
pool \
rand \
range \
diff --git a/test/point.cpp b/test/point.cpp
new file mode 100644
index 00000000..e995d8cf
--- /dev/null
+++ b/test/point.cpp
@@ -0,0 +1,16 @@
+
+#include "point.hpp"
+
+#include "debug.hpp"
+#include "types.hpp"
+
+using namespace util;
+
+int
+main (int, char**) {
+ const point<3> p(0.0, 1.0, 2.0);
+ const point<2> q = p.redim<2> ();
+
+ CHECK_EQ (q.data[0], p.data[0]);
+ CHECK_EQ (q.data[1], p.data[1]);
+}