ladc / lgsl

LGSL: A numerical library for Lua based on GSL
GNU General Public License v3.0
24 stars 3 forks source link

Pretty printing of matrices #14

Closed ladc closed 8 years ago

ladc commented 8 years ago

Implement a form (however minimalistic) for pretty printing of matrices, as in GSL Shell.

franko commented 8 years ago

Looking at the file matrix.lua it seems that the code is already there:

> lgsl = require "lgsl"
> m = lgsl.matrix.new(5,5, function(i,j) return 1/(i+j) end)
> =m
cdata<struct 180>: 0x003b69a8
> =m:show()
[        0.5 0.33333333       0.25        0.2 0.16666667 ]
[ 0.33333333       0.25        0.2 0.16666667 0.14285714 ]
[       0.25        0.2 0.16666667 0.14285714      0.125 ]
[        0.2 0.16666667 0.14285714      0.125 0.11111111 ]
[ 0.16666667 0.14285714      0.125 0.11111111        0.1 ]

That could be ok or you would like something else ?

ladc commented 8 years ago

Indeed, you have already implemented this, but I still need to do add a this as the __tostring method, so print(m) would actually print the above.

ladc commented 8 years ago

Fixed in 4f16cfd4