summaryrefslogtreecommitdiff
path: root/matrix/init.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-19 15:01:38 +0800
committerDeterminant <[email protected]>2015-05-19 15:01:38 +0800
commite9b8855c894daa4e6749acfe891f68b3ed8ed481 (patch)
tree5a3ea5e89bd475dc4312d379ffc7bf9121862dbb /matrix/init.lua
parent9b6606504241f27a9d42b96f535bf5f2c2918161 (diff)
add double precision matrix implementation
Diffstat (limited to 'matrix/init.lua')
-rw-r--r--matrix/init.lua22
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