Re: [sage-support] What is wrong with this SAGE function?

2015-06-10 Thread Lee Worden
On Tuesday, June 9, 2015 at 11:44:46 AM UTC-7, Nils Bruin wrote: On Tuesday, June 9, 2015 at 10:05:26 AM UTC-7, Phoenix wrote: @Lee Worden Your code is deciding the linear independence of the set {v,v*A,v*A^2,...,v*A^{dim(A)}} That would always be linear dependent and not what the

Re: [sage-support] What is wrong with this SAGE function?

2015-06-09 Thread Anirbit
@Lee Worden Your code is deciding the linear independence of the set {v,v*A,v*A^2,...,v*A^{dim(A)}} But I want to decide the linear independence of the set {v, A*v,..,,A^{dim(A)-1}*v} On Fri, Jun 5, 2015 at 1:20 PM, Lee Worden worden@gmail.com wrote: On Thursday, June 4, 2015 at

Re: [sage-support] What is wrong with this SAGE function?

2015-06-09 Thread Nils Bruin
On Tuesday, June 9, 2015 at 10:05:26 AM UTC-7, Phoenix wrote: @Lee Worden Your code is deciding the linear independence of the set {v,v*A,v*A^2,...,v*A^{dim(A)}} That would always be linear dependent and not what the proposed code does But I want to decide the linear independence of

Re: [sage-support] What is wrong with this SAGE function?

2015-06-05 Thread Vincent Delecroix
[0] * i + [1] + [0] * (n-i-1) On 05/06/15 00:11, Michael Orlitzky wrote: On 06/04/2015 05:53 PM, Phoenix wrote: Thanks! Is there otherwise any standard operation in SAGE to create such vectors? If the construction isn't too complicated, a list comprehension usually suffices. This will do

Re: [sage-support] What is wrong with this SAGE function?

2015-06-05 Thread Lee Worden
On Thursday, June 4, 2015 at 2:53:50 PM UTC-7, Phoenix wrote: Thanks! Is there otherwise any standard operation in SAGE to create such vectors? sage: def elem(i,n): : return VectorSpace( QQ, n ).basis()[i] : sage: elem( 1, 5 ) (0, 1, 0, 0, 0) or if you need it to return a

Re: [sage-support] What is wrong with this SAGE function?

2015-06-05 Thread Lee Worden
On Thursday, June 4, 2015 at 3:11:59 PM UTC-7, Michael Orlitzky wrote: Given a vector $v$ and a matrix $A$ of dimension $n$, one would say that $v$ is a cyclic vector of $A$ if the following set is linearly independent $\{ v,Av,A^2v,..,A^{n-1}v \}$. Is there a way to test this

Re: [sage-support] What is wrong with this SAGE function?

2015-06-04 Thread Christophe Bal
Use range(n-1) instead of range [n-1]. *Christophe BAL* *Enseignant de mathématiques en Lycée **et développeur Python amateur* *---* *French math teacher in a Lycée **and **Python **amateur developer* 2015-06-04 23:44 GMT+02:00 Phoenix anirbit.mukher...@gmail.com: I am trying to define a

Re: [sage-support] What is wrong with this SAGE function?

2015-06-04 Thread Phoenix
Thanks! Is there otherwise any standard operation in SAGE to create such vectors? If you have time can you also look into another question I had about vectors in SAGE: Given a vector $v$ and a matrix $A$ of dimension $n$, one would say that $v$ is a cyclic vector of $A$ if the following

Re: [sage-support] What is wrong with this SAGE function?

2015-06-04 Thread Michael Orlitzky
On 06/04/2015 05:53 PM, Phoenix wrote: Thanks! Is there otherwise any standard operation in SAGE to create such vectors? If the construction isn't too complicated, a list comprehension usually suffices. This will do what you want, I think: def elem(i,n): return [ ZZ(i == j) for j

[sage-support] What is wrong with this SAGE function?

2015-06-04 Thread Phoenix
I am trying to define a function elem which will create me a list of length n which has 1 at the i^th position. def elem (i,n): A = [] for k in range [n-1]: if k != i: A.append([0]) if k == i: A.append([1]) return A elem (1,5) Why does the above not