Logo

Programming-Idioms

History of Idiom 77 > diff from v17 to v18

Edit summary for version 18 by programming-idioms.org:
New Java implementation by user [programming-idioms.org]

Version 17

2016-10-02, 16:00:20

Version 18

2016-12-04, 22:22:25

Idiom #77 Complex number

Declare a complex x and initialize it with value (3i - 2). Then multiply it by i.

Illustration

Idiom #77 Complex number

Declare a complex x and initialize it with value (3i - 2). Then multiply it by i.

Illustration
Imports
import org.apache.commons.math4.complex.Complex;
Code
Complex x = new Complex(-2.0, 3.0);
x = x.multiply(Complex.I);
Comments bubble
This uses the Apache Commons Math library.
Doc URL
http://commons.apache.org/proper/commons-math/userguide/complex.html