creating empty matrices makemat(nop, rows, cols)

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

creating empty matrices makemat(nop, rows, cols)

Message par compsystems » jeu. févr. 15, 2018 11:08 pm

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)"]]

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

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

Message par parisse » ven. févr. 16, 2018 9:42 am

I can't see how you would save memory with empty matrices.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

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

Message par compsystems » ven. févr. 16, 2018 11:58 am

hp50
{{},{}}
BYTES
15

{{0},{0}}
BYTES
20

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

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

Message par parisse » ven. févr. 16, 2018 12:11 pm

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.

Répondre