William Stein wrote:
> On Fri, Nov 27, 2009 at 7:37 AM, Dag Sverre Seljebotn
> <da...@student.matnat.uio.no> wrote:
>> I need a convenient matrix class for some numerical work. SciPy doesn't
>> accept GPL code and besides I heavily dislike the NumPy matrix class. So
>> why not put my efforts into improving Sage (or at least write something
>> Sage-compatible for myself)...
> 
> Cool.   Make sure to also look into CVXOPT
> (http://abel.ee.ucla.edu/cvxopt/) which is included in Sage and does
> accept GPL code.

Yep, that's what I use now.

>> 2) I haven't checked but I think converting all my sparse values to a
>> Python dict to get it into a Sage matrix would be too slow, at least it
>> is wasteful. So I'd like something like
>>
>> matrix(CDF, I=I, J=J, V=V, sparse=True)
>>
>> where I, J, and V are vectors containing respectively rows, columns, and
>> values, element by element.
> 
> I don't quite understand this yet.   Note that you can directly access
> your Matrix_sparse_rdf from Cython, if you so choose.

Yes, but it would be nice to have an efficient way of constructing a 
sparse matrix from Python-space as well. Both SciPy and CVXOPT supports 
passing three vectors (with row indices, col indices, and values) to 
initialize a sparse matrix. For instance, the 3x3 identity matrix would be

matrix(RDF, I=[0, 1, 2], J=[0, 1, 2], V=[1, 1, 1], sparse=True)

(Where we could use different keywords for I, J, V, or combine them in a 
tuple).

The point is that I, J and V could be NumPy arrays or vector instances, 
which would allow for efficient construction without creating millions 
of Python objects in a dictionary.

The indices need not be sorted, and in fact in NumPy you can pass the 
same index pair many times (which results in summation over 
corresponding values, which they claim is useful sometimes).

-- 
Dag Sverre

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to