aboutsummaryrefslogtreecommitdiff
path: root/matrix/init.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-31 11:18:16 +0800
committerDeterminant <[email protected]>2015-05-31 11:18:16 +0800
commitab12a9583bdd39884fde9bc2444e6fd1bc5f518e (patch)
tree11d6bf3b4aafd4a07cf78fe8dc921fa5280d8a3e /matrix/init.lua
parentc6f6ac13a1cf00e440e998422f89b42c69b073a6 (diff)
add async copy by index; add MMatrixInt
Diffstat (limited to 'matrix/init.lua')
-rw-r--r--matrix/init.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/matrix/init.lua b/matrix/init.lua
index 0075668..057b085 100644
--- a/matrix/init.lua
+++ b/matrix/init.lua
@@ -2,17 +2,22 @@ function nerv.Matrix:__tostring__()
local ncol = self:ncol()
local nrow = self:nrow()
local strt = {}
-
+ local fmt
+ if self.fmt then
+ fmt = self.fmt
+ else
+ fmt = "%.10f "
+ end
if nrow == 1 then
for col = 0, ncol - 1 do
- table.insert(strt, string.format("%f ", self[col]))
+ table.insert(strt, string.format(fmt, self[col]))
end
table.insert(strt, "\n")
else
for row = 0, nrow - 1 do
local rp = self[row]
for col = 0, ncol - 1 do
- table.insert(strt, string.format("%.10f ", rp[col]))
+ table.insert(strt, string.format(fmt, rp[col]))
end
table.insert(strt, "\n")
end
@@ -21,6 +26,8 @@ function nerv.Matrix:__tostring__()
return table.concat(strt)
end
+nerv.MMatrixInt.fmt = "%d "
+
function nerv.CuMatrix:__add__(b)
c = self:create()
c:add(self, b, 1.0, 1.0)