aboutsummaryrefslogtreecommitdiff
path: root/cumatrix_example.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-17 23:40:25 +0800
committerDeterminant <[email protected]>2015-05-17 23:40:25 +0800
commit83006367aeec856bf8e59231c78df5b1802e3138 (patch)
treed617de84bcc11067840582ebe276d29e3851e548 /cumatrix_example.lua
parent902faa66e3da52a1a4cf7b1dc7da6e6bf0d47d34 (diff)
add addition and multiplication for cumatrix
Diffstat (limited to 'cumatrix_example.lua')
-rw-r--r--cumatrix_example.lua25
1 files changed, 21 insertions, 4 deletions
diff --git a/cumatrix_example.lua b/cumatrix_example.lua
index 4b6fb4a..ccd88b8 100644
--- a/cumatrix_example.lua
+++ b/cumatrix_example.lua
@@ -1,10 +1,27 @@
-t = nerv.FloatCuMatrix(10, 20)
+m = 2
+n = 3
+t = nerv.FloatCuMatrix(m, n)
+t2 = nerv.FloatCuMatrix(m, n)
print(t)
a = t[1]
-for i = 0, 9 do
- for j = 0, 19 do
+for i = 0, m - 1 do
+ for j = 0, n - 1 do
t[i][j] = i + j
+ t2[i][j] = t[i][j]
end
end
-print(t)
print(a)
+print(t)
+print(t2)
+print(t + t2)
+d = nerv.FloatCuMatrix(3, 3)
+for i = 0, 2 do
+ for j = 0, 2 do
+ d[i][j] = 0
+ end
+end
+d[0][0] = 1
+d[1][1] = 2
+d[2][2] = 3
+print(d)
+print(t * d)