> 
# First, let's see what went on with the original approach. restart;

> 
M:=Matrix([[a,2*a],[3*a,a^2]]);

> 
# There is no instance of `a` within M, which is why unassignment to `a` does not affect M. lprint(M);

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
> 
# Now let's see what happens with the reverse approach. restart;

> 
M:=Matrix([[a,2*a],[3*a,a^2]]);

> 
# You see the 5, not 'a', but this is just an artefact of evaluation during printing. M;

> 
# Entries are evaluated upon access. Together with the printing, as above, this is often adequate. M[2,2];

> 
lprint(M); # Indeed the 'a' is still there.

Matrix(2, 2, {(1, 1) = a, (1, 2) = 2*a, (2, 1) = 3*a, (2, 2) = a^2}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
> 
# This copy of M contains the 5, not the 'a', as entries were evaluated upon access during copying. lprint(C);

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
> 
# This new version of M also contains 5, not 'a'. K:=rtable_eval(M);

> 
# And here is proof of that. lprint(K);

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
> 
# M still contains 'a', though elementwise access will get the 5. lprint(M);

Matrix(2, 2, {(1, 1) = a, (1, 2) = 2*a, (2, 1) = 3*a, (2, 2) = a^2}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
> 
# This causes the entries of M to be evaluated insitu, without copying the whole structure. rtable_eval(M, inplace);

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 10, (2, 1) = 15, (2, 2) = 25}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])
