On 4 March 2015 at 08:55, Jeroen Demeyer <[email protected]> wrote:
> On 2015-03-04 09:48, John Cremona wrote:
>>
>> What is the simplest way to do this.  I have a matrix M (square and
>> over ZZ, but that is not so important).  I want to make another matric
>> of the same size & base.  I have not explicitly constructed the
>> associated matrix space, but I know that I can get it wth M.parent(),
>> so doing   newM = M.parent()(0) would work, but is there something
>> more natural?
>
>
> Do you want to *copy* a matrix or construct a new matrix with the same
> parent? In the former case, just use copy(). In the latter case, what you

It was the latter.  I first tried copy() as a way to get a new matrix
with the same parent whose entries were then changed;  but in the
contex I was working in , copy() was not imported, so I switched to
the other way anyway.

In fact the new matrix in this case is just obtained from the old one
by permuting rows and columns, and I just discovered the method
M.permute_rows_and_column(), so I should really use that anyway.  the
trouble is that that function requires proper permutation objects,
when what I have is a permutation of range(n) as a list.  It seems to
me to be too much trouble to construct the associated permutations,
remember that permutations act on [1..n] and not [0..(n-1)], and also
that these functions act on a matrix in place so require me to make a
copy first anyway!  I just need to be able to write newM=permut(M,L)
where L is something like [1,2,0] and a new matrix is created and
returned.  (And of course I am capable of writeing such a function!
but surely others need the same?)

John

> did seems right. The fact that you have not *explicitly* constructed the
> matrix space doesn't matter, it exists anyway.
>
> Of course, in Cython, there are much more efficient ways.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to