aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorcloudygoose <[email protected]>2015-06-12 13:06:27 +0800
committercloudygoose <[email protected]>2015-06-21 10:25:03 +0800
commit839d938df0d83ec311c5d1299923c667adff6a87 (patch)
tree5e774230b9a9fd1c99a3f0a0dff0a776ec628d2f /matrix
parenta55769787d1b3ec2d1db519cd5efb3b5b2e75404 (diff)
git rebase
... ... ... ... .. .. ... .... ... ... .. ... ... ... ... ... ... ... ... ... ... ... ... ... ... git rebase ... ... ... doc change doc change ... added nerv.Matrix:randomize() ... doc change for DAGLayer bug fix in nerv.Matrix:random() doc change
Diffstat (limited to 'matrix')
-rw-r--r--matrix/init.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/matrix/init.lua b/matrix/init.lua
index 7bbc6a4..769ef2d 100644
--- a/matrix/init.lua
+++ b/matrix/init.lua
@@ -27,6 +27,22 @@ function nerv.Matrix:__tostring__()
return table.concat(strt)
end
+--func: function
+--All entrys in the matrix will be assigned by calling func()
+function nerv.Matrix:randomize(func)
+ if (self:nrow() == 1) then
+ for j = 0, self:ncol() - 1, 1 do
+ self[j] = func()
+ end
+ else
+ for i = 0, self:nrow() - 1, 1 do
+ for j = 0, self:ncol() - 1, 1 do
+ self[i][j] = func()
+ end
+ end
+ end
+end
+
nerv.MMatrixInt.fmt = "%d "
function nerv.CuMatrix:__add__(b)