Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

matrix base ring changes by a complex multiplication

asked 5 years ago

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.

Preview: (hide)

Comments

Just use CDF(I) instead of I

FrédéricC gravatar imageFrédéricC ( 5 years ago )

Thank you very much.

cxrjdd gravatar imagecxrjdd ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

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.

Preview: (hide)
link

Comments

1

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

slelievre gravatar imageslelievre ( 5 years ago )

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: 5 years ago

Seen: 340 times

Last updated: Jan 15 '20