Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I form a new matrix from a given one by picking out some of its columns, using MAGMA?

share|cite|improve this question
up vote 3 down vote accepted

Suppose you have an $m\times n$ matrix $A=[A_{i,j}]$ defined in MAGMA. Am I correct in thinking that you want to define an $m\times l$ matrix $B=[B_{r,s}]$ in MAGMA such that the columns of $B$ are all copies of columns of $A$. This is easily done using loops. First define $B$ to be the zero matrix over your chosen ring $R$:


Then suppose you want the 1st column of $B$ to be equal to the $a$-th column of $A$? Then use the following loop:

for i in {1..m} do
end for;

Repeating this for all the columns of $B$ will give you your result.

share|cite|improve this answer

You can actually do this really easily in Magma using the ColumnSubmatrix command, no looping necessary. You can use this in a few ways.

For example if you have a matrix $A$ and you want $B$ to be made up a selection of columns:

1st, 2nd, $\ldots$, 5th columns:

B := ColumnSubmatrix(A, 5);

3rd, 4th, $\ldots$, 7th columns:

B := ColumnSubmatrix(A, 3, 4);

(since 7=3+4) OR

ColumnSubmatrixRange(A, 3, 7);

2nd, 5th, 8th columns: This is trickier. Magma doesn't let you do this cleanly. But you can select rows 2, 5, and 8 of a matrix individually. You can obviously replace [2,5,8] with any arbitrary sequence.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.