Ask Your Question
1

matrix base ring changes by a complex multiplication

asked 2020-01-15 03:59:29 -0500

cxrjdd gravatar image

The complex multiplication of matrix changes the base ring.

A = matrix(CDF,[[1,2],[3,4]]); print(A)
B = 2*A
C = I*A
print(type(A))
print(type(B))
print(type(C))

The result is

[1.0 2.0]
[3.0 4.0]
<class 'sage.matrix.matrix_complex_double_dense.Matrix_complex_double_dense'>
<class 'sage.matrix.matrix_complex_double_dense.Matrix_complex_double_dense'>
<class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>

So the multiplication by an imaginary number breaks the CDF property. This is very inconvenient for numerical calculations, because the symbolic computation is very slow.

edit retag flag offensive close merge delete

Comments

Just use CDF(I) instead of I

FrédéricC gravatar imageFrédéricC ( 2020-01-15 06:41:14 -0500 )edit

Thank you very much.

cxrjdd gravatar imagecxrjdd ( 2020-01-21 13:46:35 -0500 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2020-01-15 06:42:50 -0500

rburing gravatar image

Indeed this is an old issue: I.parent() should not be the symbolic ring [trac ticket #18036]. When you know your base field, you should use the $i$ from that base field. You can access it e.g. by CDF(I) or CDF.gens()[0] or CDF.0. If you have a complex number z which is not in your base field for whatever reason (e.g. it is symbolic, e.g. because you used I), then you can do CDF(z) to convert it into your base field. You can also change the ring of a matrix e.g. by C.change_ring(CDF); it returns a new matrix, over the new ring.

edit flag offensive delete link more

Comments

1

To obtain the CDF version of I you can also use CDF.gen() or CDF.gen(0).

slelievre gravatar imageslelievre ( 2020-01-16 18:10:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-01-15 03:59:29 -0500

Seen: 27 times

Last updated: Jan 15