Hello Harald, > > Hi, well, basically, I don't think you have to convert it except you > need it for some special applications. Sage can do arithmetic over the > matrices. However, this short session should answer all your > questions:
> > > sage: m = matrix(RDF, 2, range(4)); m > [0.0 1.0] > [2.0 3.0] > sage: type(m) > <type 'sage.matrix.matrix_real_double_dense.Matrix_real_double_dense'> > > sage: n = m.numpy() > sage: type(n) > <type 'numpy.ndarray'> > > # and back again: > sage: type(matrix(n)) > <type 'sage.matrix.matrix_real_double_dense.Matrix_real_double_dense'> > > sage: n > array([[ 0., 1.], > [ 2., 3.]]) > > sage: n*n > array([[ 0., 1.], > [ 4., 9.]]) > > # n*n is not the matrix product! > # but it is for sage matrices: > > sage: m*m > [ 2.0 3.0] > [ 6.0 11.0] > > # you need "dot" from numpy > > sage: from numpy import dot > sage: dot(n,n) > array([[ 2., 3.], > [ 6., 11.]]) > > last note: RDF = real-double-field, i.e. the "pseudo" field of double > values the cpu and numpy uses by default. Thanks a lot! The .numpy method was exactly what I was looking for. (Where should I have looked in the documentation to find out by myself?, Maybe there are more useful hints.) Now I can do: sympy.Matrix(m.numpy()) for example. Or use numpys resize and reshape facilities. Thanks also for the hint with .dot and the note on RDF. Greetings, Bastian -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org