aboutsummaryrefslogtreecommitdiff
path: root/matrix/init.lua
diff options
context:
space:
mode:
authorcloudygoose <[email protected]>2015-05-31 11:32:45 +0800
committercloudygoose <[email protected]>2015-05-31 11:32:45 +0800
commit36162328956177d554891f937a13616b5476b231 (patch)
treea28c7a6f29b37ce091b03534e85d5cb28b2e0f81 /matrix/init.lua
parentcfd06bb974c7088837a107d721b1311a4f160572 (diff)
parentab12a9583bdd39884fde9bc2444e6fd1bc5f518e (diff)
...
Merge remote-tracking branch 'upstream/master'
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)