Page 1 sur 1

creating empty matrices makemat(nop, rows, cols)

Publié : jeu. févr. 15, 2018 11:08 pm
par compsystems
Hello BP
I think that to save memory, it is necessary to create empty matrices, do you think it is necessary?
if so, the function field could be nop to create an empty matrix
makemat(nop,3,2)
RETURNS
[[ , ],
[ , ],
[ , ]]

with a no empty function
makemat((a,b)-> "("+string(a)+","+string(b)+")",3,2)
RETURNS
[["(0,0)","(0,1)"],
["(1,0)","(1,1)"],
["(2,0)","(2,1)"]]

Re: creating empty matrices makemat(nop, rows, cols)

Publié : ven. févr. 16, 2018 9:42 am
par parisse
I can't see how you would save memory with empty matrices.

Re: creating empty matrices makemat(nop, rows, cols)

Publié : ven. févr. 16, 2018 11:58 am
par compsystems
hp50
{{},{}}
BYTES
15

{{0},{0}}
BYTES
20

Re: creating empty matrices makemat(nop, rows, cols)

Publié : ven. févr. 16, 2018 12:11 pm
par parisse
On modern hardware, you will never need to optimize for a few bits. Memory becomes a problem if you have large matrices (nxn with n=a few thousands). And inside giac vectors with size from 0 to 3 do not allocate memory, they take the same space.