[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-17 Thread Alec Mihailovs
On Mar 16, 10:47 pm, Alec Mihailovs wrote: > By the way, vector doesn't work with integer numpy arrays, > > from numpy import array > vector(array([1,2])) > > Traceback (most recent call last): That shouldn't be too hard to implement - in particular, the following works, sage: from numpy import

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
By the way, vector doesn't work with integer numpy arrays, from numpy import array vector(array([1,2])) Traceback (most recent call last): File "", line 1, in File "_sage_input_60.py", line 5, in vector(array([_sage_const_1 ,_sage_const_2 ])) File "", line 1, in File "free_module_

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Mike Hansen
On Tue, Mar 16, 2010 at 1:06 PM, Alec Mihailovs wrote: > What about vector(3,f), f.vector(3), and f.matrix(3,4) or > f.matrix(5) ? I didn't do anything about vector() -- I could probably get to it later. There's no good way to make a syntax like f.matrix() or f.vector() work, and it's not someth

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
On Mar 16, 3:57 pm, Mike Hansen wrote: > On Tue, Mar 16, 2010 at 12:38 PM, Alec Mihailovs > > wrote: > > Will it work as matrix(5,f) as well, or only as matrix(5,5,f) ? > > It now works with both. > > --Mike That's great! What about vector(3,f), f.vector(3), and f.matrix(3,4) or f.matrix(5) ?

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Mike Hansen
On Tue, Mar 16, 2010 at 12:38 PM, Alec Mihailovs wrote: > Will it work as matrix(5,f) as well, or only as matrix(5,5,f) ? It now works with both. --Mike -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
On Mar 16, 2:32 am, Mike Hansen wrote: > On Mon, Mar 15, 2010 at 10:16 PM, Jason Grout > > wrote: > > Whoever takes care of this original issue gets to claim a 3-digit ticket! > > >http://trac.sagemath.org/sage_trac/ticket/261 > > Patch up for review. > > --Mike Will it work as matrix(5,f) as we

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Mike Hansen
On Mon, Mar 15, 2010 at 10:16 PM, Jason Grout wrote: > Whoever takes care of this original issue gets to claim a 3-digit ticket! > > http://trac.sagemath.org/sage_trac/ticket/261 Patch up for review. --Mike -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe fr

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Jason Grout
On 03/15/2010 10:58 PM, Alec Mihailovs wrote: By the way, if that will go into a ticket, it would be nice if also the possibility of defining a matrix through a function be added to the matrix constructor (along David Joyner's suggestion). Whoever takes care of this original issue gets to cla

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Alec Mihailovs
On Mar 15, 3:48 am, Alec Mihailovs wrote: > That seems to be a bug introduced in Sage, not in numpy, > > sage: fromfunction(lambda i,j:i-j+3,(1,1),dtype=int) > > array([[3]]) > > sage: matrix(_) > > [0 0 0] > [0 0 0] > [0 0 0] Yes, and that happens with other numpy 1x1 arrays as well, converted

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Eckhard Kosin
Am Montag, den 15.03.2010, 10:38 -0700 schrieb Mike Hansen: > On Mon, Mar 15, 2010 at 10:32 AM, Eckhard Kosin > wrote: > > sage: fromfunction(lambda i,j:i-j+3,(1,1),dtype=int) > > --- > > NameError

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Mike Hansen
On Mon, Mar 15, 2010 at 10:32 AM, Eckhard Kosin wrote: > sage: fromfunction(lambda i,j:i-j+3,(1,1),dtype=int) > --- > NameError                                 Traceback (most recent call > last) > > /home/ecki/ in () > > Name

Re: [sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Eckhard Kosin
Am Montag, den 15.03.2010, 00:48 -0700 schrieb Alec Mihailovs: > On Mar 15, 3:39 am, Alec Mihailovs wrote: > > The second problem is that something strange happens for 1x1 matrices, > > with any dtype, > > > > matrix(fromfunction(lambda i,j:i-j,(1,1),dtype=int)) > > > > [] > > > > matrix(fromfunct

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Alec Mihailovs
On Mar 15, 3:39 am, Alec Mihailovs wrote: > The second problem is that something strange happens for 1x1 matrices, > with any dtype, > > matrix(fromfunction(lambda i,j:i-j,(1,1),dtype=int)) > > [] > > matrix(fromfunction(lambda i,j:i-j+3,(1,1),dtype=int)) > > [0 0 0] > [0 0 0] > [0 0 0] That seem

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Alec Mihailovs
On Mar 14, 6:15 pm, Alec Mihailovs wrote: > That could be also done as > > from numpy import fromfunction > > matrix(fromfunction(lambda i,j:i-j, (6,6), dtype=int)) > > [ 0 -1 -2 -3 -4 -5] > [ 1  0 -1 -2 -3 -4] > [ 2  1  0 -1 -2 -3] > [ 3  2  1  0 -1 -2] > [ 4  3  2  1  0 -1] > [ 5  4  3  2  1  0]

[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-14 Thread Alec Mihailovs
That could be also done as from numpy import fromfunction matrix(fromfunction(lambda i,j:i-j, (6,6), dtype=int)) [ 0 -1 -2 -3 -4 -5] [ 1 0 -1 -2 -3 -4] [ 2 1 0 -1 -2 -3] [ 3 2 1 0 -1 -2] [ 4 3 2 1 0 -1] [ 5 4 3 2 1 0] _.parent() Full MatrixSpace of 6 by 6 dense matrices over Int