aboutsummaryrefslogtreecommitdiff
path: root/matrix/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'matrix/init.lua')
-rw-r--r--matrix/init.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/matrix/init.lua b/matrix/init.lua
index d6aab73..c33cf7e 100644
--- a/matrix/init.lua
+++ b/matrix/init.lua
@@ -20,3 +20,15 @@ function nerv.Matrix:__tostring__()
table.insert(strt, string.format("[Matrix %d x %d]", nrow, ncol))
return table.concat(strt)
end
+
+function nerv.CuMatrix:__add__(b)
+ c = self:create()
+ c:add(self, b, 1.0, 1.0)
+ return c
+end
+
+function nerv.CuMatrix:__sub__(b)
+ c = self:create()
+ c:add(self, b, 1.0, -1.0)
+ return c
+end