Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Copy vectors

Hello everyone,

I have the following problem: I have two vectors v = vector(QQ, [1,1]), w = vector(QQ, [3,3]). I want to copy the coefficients of w into v. I can't set v = w directly, beacuse v is used as a value in some dictionaries. I could loop over the list() of the vectors, but I was wondering if there is some better way to copy all of the entries.

click to hide/show revision 2
No.2 Revision

updated 2012-10-19 04:42:56 -0600

kcrisman gravatar image

Copy vectors

Hello everyone,

I have the following problem: I have two vectors v = vector(QQ, [1,1]), w = vector(QQ, [3,3]). I want to copy the coefficients of w into v. I can't set v = w directly, beacuse v is used as a value in some dictionaries. I could loop over the list() of the vectors, but I was wondering if there is some better way to copy all of the entries.

Example from comment:

l = {1: v}; v.set(1,2) Now l == {1: (1, 2)}, but v = copy(w) does not change l