aboutsummaryrefslogtreecommitdiff
path: root/matrix.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-14 15:01:55 +0800
committerDeterminant <[email protected]>2015-05-14 15:01:55 +0800
commitf48dc493b5b77fd4e4472dd6c78b7542a4884129 (patch)
tree0b7a0f95df28fc100fc1fd252ce1d0215d19150d /matrix.lua
parent46ccec6d5ad057476e945afa34981f7e8d732547 (diff)
add basic matrix implementation
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/matrix.lua b/matrix.lua
new file mode 100644
index 0000000..2a70590
--- /dev/null
+++ b/matrix.lua
@@ -0,0 +1,15 @@
+function nerv.FloatMatrix:__tostring__()
+ local ncol = self:ncol()
+ local nrow = self:nrow()
+ local i = 0
+ local res = ""
+ for row = 0, nrow - 1 do
+ for col = 0, ncol - 1 do
+ res = res .. string.format("%f ", self:get_elem(i))
+ i = i + 1
+ end
+ res = res .. "\n"
+ end
+ res = res .. string.format("[Float Matrix %d x %d]", nrow, ncol)
+ return res
+end