JasonWang 7 år sedan
förälder
incheckning
445594ae31
2 ändrade filer med 14 tillägg och 7 borttagningar
  1. 0 7
      .gitmodules
  2. 14 0
      traph/include/traph/core/tensor.h

+ 0 - 7
.gitmodules

@@ -1,7 +0,0 @@
-
-[submodule "traph/contrib/xtensor"]
-	path = traph/contrib/xtensor
-	url = https://github.com/QuantStack/xtensor.git
-[submodule "traph/contrib/xtl"]
-	path = traph/contrib/xtl
-	url = https://github.com/QuantStack/xtl.git

+ 14 - 0
traph/include/traph/core/tensor.h

@@ -1,3 +1,5 @@
+#include <cmath>
+
 
 #include<traph/core/type.h>
 #include<traph/core/index.h>
@@ -242,6 +244,18 @@ namespace traph
             return result;
         }
         // op
+        void abs_()
+        {
+            idx_type i = offset;
+            for(idx_type dim = 0;dim < dimensions.size();++dim)
+            {
+                for(idx_type step = 0; step < dimension[dim];++step)
+                {
+                    rep->data[i] = std::abs(rep->data[i]);
+                    i += strides[dim];
+                }
+            }
+        }
         // index
         T& item()
         {