Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

construct a structure

Dear all,

I want to construct a structured array which has 2 fields storing 2 different data type, one is a float number and the other is a polynomial matrix.

Structured Arrays (and Record Arrays) Can I use this NumPy method or any other else? NumPy doesn't know/understand the data type of a polynomial matrix defined in SAGE.

sage: R.<s> = PolynomialRing(QQ); R
Univariate Polynomial Ring in s over Rational Field
sage: H = matrix(1,2, [(s+5)**2, s]); H
[s^2 + 10*s + 25               s]
sage: H.parent()
Full MatrixSpace of 1 by 2 dense matrices over Univariate Polynomial Ring in s over Rational Field
sage: type(H[0,0])
<type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>
sage: sys = np.zeros(1, dtype=[('TF','sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint',(1,2)),('Ts','f4')])
TypeError                                 Traceback (most recent call last)
/home/xxx/Programs/sage-5.10-linux-64bit/local/lib/python2.7/site-packages/sage/all_cmdline.pyc in <module>()
----> 1 sys = np.zeros(Integer(1), dtype=[('TF','sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint',(Integer(1),Integer(2))),('Ts','f4')])

TypeError: data type "sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint" not understood

Thanks in advance!