#8719: convert RDF/CDF matrices to numpy
------------------------------+---------------------------------------------
Reporter: jason | Owner: jason, was
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.4
Component: linear algebra | Keywords:
Author: Jason Grout | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Description changed by jason:
Old description:
> This patch makes the following work:
>
> {{{
> sage: import numpy
> sage: m = matrix(RDF, 2, range(6)); m
> [0.0 1.0 2.0]
> [3.0 4.0 5.0]
> sage: numpy.array(m)
> array([[ 0., 1., 2.],
> [ 3., 4., 5.]])
> sage: numpy.array(m).dtype
> dtype('float64')
> sage: m = matrix(CDF, 2, range(6)); m
> [ 0 1.0 2.0]
> [3.0 4.0 5.0]
> sage: numpy.array(m)
> array([[ 0.+0.j, 1.+0.j, 2.+0.j],
> [ 3.+0.j, 4.+0.j, 5.+0.j]])
> sage: numpy.array(m).dtype
> dtype('complex128')
> }}}
New description:
This patch makes the following work:
{{{
sage: import numpy
sage: m = matrix(RDF, 2, range(6)); m
[0.0 1.0 2.0]
[3.0 4.0 5.0]
sage: numpy.array(m)
array([[ 0., 1., 2.],
[ 3., 4., 5.]])
sage: numpy.array(m).dtype
dtype('float64')
sage: m = matrix(CDF, 2, range(6)); m
[ 0 1.0 2.0]
[3.0 4.0 5.0]
sage: numpy.array(m)
array([[ 0.+0.j, 1.+0.j, 2.+0.j],
[ 3.+0.j, 4.+0.j, 5.+0.j]])
sage: numpy.array(m).dtype
dtype('complex128')
sage: import numpy
sage: b=numpy.array(a); b
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
sage: b.dtype
dtype('int64')
sage: b.shape
(3, 4)
}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8719#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.