Code

Partial 2geom update (anticipating changes that will be part of the next major update...
authorcilix42 <cilix42@users.sourceforge.net>
Thu, 3 Jul 2008 09:39:33 +0000 (09:39 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Thu, 3 Jul 2008 09:39:33 +0000 (09:39 +0000)
src/2geom/numeric/linear_system.h
src/2geom/piecewise.h

index 9cb521eb2a2f919a8d7982d46117109362c5643f..7699c5224ead519e34c4bbe9ea7b7fb0b8a864ec 100644 (file)
@@ -6,8 +6,8 @@
 
 #include <gsl/gsl_linalg.h>
 
-#include "numeric/matrix.h"
-#include "numeric/vector.h"
+#include "2geom/numeric/matrix.h"
+#include "2geom/numeric/vector.h"
 
 
 namespace Geom { namespace NL {
index 8992c0097d3987f6d740fc8568c770506a9dc107..96e64bcf9e40ba3ab53e9dedbf7e2d32c6ce85d4 100644 (file)
@@ -704,7 +704,23 @@ Piecewise<T> derivative(Piecewise<T> const &a) {
 }
 
 std::vector<double> roots(Piecewise<SBasis> const &f);
-Piecewise<SBasis> reverse(Piecewise<SBasis> const &f);
+
+template<typename T>
+Piecewise<T> reverse(Piecewise<T> const &f) {
+    Piecewise<T> ret = Piecewise<T>();
+    ret.cuts.resize(f.cuts.size());
+    ret.segs.resize(f.segs.size());
+    double start = f.cuts[0];
+    double end = f.cuts.back();
+    for (unsigned i = 0; i < f.cuts.size(); i++) {
+        double x = f.cuts[f.cuts.size() - 1 - i];
+        ret.cuts[i] = end - (x - start);
+    }
+    for (unsigned i = 0; i < f.segs.size(); i++)
+        ret.segs[i] = reverse(f[f.segs.size() - i - 1]);
+    return ret;
+}
+
 
 }