How to create a matrix in pari/gp

1.8k Views Asked by At

How does one create a matrix in $\texttt{pari}$?

I currently understand how to create a vector:

? vector(6,n,n^2)

%1 = [1, 4, 9, 16, 25, 36]

I also know how to write down a matrix with specific entries:

? [1,4,9;1,8,27]

%2 = 

[1 4 9]

[1 8 27]

However, I am at a loss how to create a matrix with (say) the first row given by $n^2$ and the second by $n^3$ without typing it all in.

In practice, I have a script which generates a bunch of vectors of the same length (say 100 vectors of length 10), and I want to create the matrix formed by these rows. I have tried to use concat, but so far without success.

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the "matrix" command:

? matrix(2,6,n,m,m^(n+1))
%1 = 
[1 4 9 16 25 36]

[1 8 27 64 125 216]