aboutsummaryrefslogtreecommitdiff
path: root/matrix/matrix.lua
blob: 7aa1f122e4ba5f2e18b22827bf6be8201535d835 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))
    return table.concat(strt)
end