On Sep 7, 2008, at 6:56 AM, Jason Merrill wrote:

>
> On Sep 7, 6:30 am, "John Cremona" <[EMAIL PROTECTED]> wrote:
>> It should be lightly easier than it is to convert a vector of  
>> length n
>> to either an nx1 matrix or a 1xn matrix:
>>
>> sage: v = vector(srange(5))
>> sage: v
>> (0, 1, 2, 3, 4)
>> sage: matrix(QQ,1,5,[v])
>> [0 1 2 3 4]
>> sage: matrix(QQ,5,1,list(v))
>>
>> [0]
>> [1]
>> [2]
>> [3]
>> [4]
>>
>> I got neither of those right the first time!  I know that v*v is  
>> short
>> for the dot product, which is also (row v)*(col v), but sometimes one
>> wants (col v)*(row v) as a rank 1 nxn matrix:
>>
>> sage: matrix(QQ,5,1,list(v)) * matrix(QQ,1,5,[v])
>>
>> [ 0  0  0  0  0]
>> [ 0  1  2  3  4]
>> [ 0  2  4  6  8]
>> [ 0  3  6  9 12]
>> [ 0  4  8 12 16]
>>
>> I suggest that vector methods row_matrix() and col_matrix() would  
>> be useful.
>
> It might be nice to have row_matrix() and col_matrix(), as you
> suggest, but you can do the conversions right now like this:
>
> sage: matrix(v)
> [0 1 2 3 4]
>
> sage: transpose(v)
>
> [0]
> [1]
> [2]
> [3]
> [4]
>
> sage: parent(transpose(v))
> Full MatrixSpace of 5 by 1 dense matrices over Integer Ring

I'm not sure I like this... I think it makes more sense to do  
transpose(matrix(v)).

>
> # This is a bug, I guess
> sage: matrix(transpose(v))
> Traceback (most recent call last)
> ...
> TypeError: _matrix_() takes exactly one argument (0 given)

Yep, I'd say that's a bug.

- Robert

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to