diff options
Diffstat (limited to 'matrix/init.lua')
-rw-r--r-- | matrix/init.lua | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/matrix/init.lua b/matrix/init.lua index 59b8384..d6aab73 100644 --- a/matrix/init.lua +++ b/matrix/init.lua @@ -1,4 +1,4 @@ -function nerv.FloatCuMatrix:__tostring__() +function nerv.Matrix:__tostring__() local ncol = self:ncol() local nrow = self:nrow() local strt = {} @@ -12,27 +12,11 @@ function nerv.FloatCuMatrix:__tostring__() for row = 0, nrow - 1 do local rp = self[row] for col = 0, ncol - 1 do - table.insert(strt, string.format("%f ", rp[col])) + table.insert(strt, string.format("%.10f ", rp[col])) end table.insert(strt, "\n") end end - table.insert(strt, string.format("[Float Matrix %d x %d]", nrow, ncol)) - return table.concat(strt) -end - -function nerv.FloatMatrix:__tostring__() - local ncol = self:ncol() - local nrow = self:nrow() - local i = 0 - local strt = {} - for row = 0, nrow - 1 do - for col = 0, ncol - 1 do - table.insert(strt, string.format("%f ", self:get_elem(i))) - i = i + 1 - end - table.insert(strt, "\n") - end - table.insert(strt, string.format("[Float Matrix %d x %d]", nrow, ncol)) + table.insert(strt, string.format("[Matrix %d x %d]", nrow, ncol)) return table.concat(strt) end |