If you want to store all the matrices, then I think you will have to stack them together inside one large matrix. This complicates things as you need to keep track of where in the larger matrix, the individual matrices are stored. Here is an example:
n = 3;
maxp = 60;
ap = j(maxp#n, n); /* large matrix in which to keep all the powers of a */
ri = shape(1:(maxp#n), maxp); /* row index matrix for sub-matrices in ap */
a = 1.01 # i(n); /* define the matrix a */
ap[ ri[ 1, ], ] = a; /* write matrix a to ap */
do i = 2 to maxp; /* write powers to ap */
ap[ ri[ i, ], ] = ap [ ri[ i-1, ], ] * a;
end;
c = ap[ ri[ 3, ], ]; /* set c to to a**3 */
Hope that helps.
... View more