Hi,

Why does ml.getComplex() throw an exception in the following code?

ml.evaluate("1+I");

ml.waitForAnswer();

System.out.println(myML.getComplex());

What is a good strategy for getting complex numbers out of Mathematica with JLink?

Many thanks in advance!

Aaron Fude

Aaron,

Because Java does not have a built-in class to represent complex numbers,

you have to tell J/Link what class you want it to use for this purpose. You

do this by calling the setComplexClass() method:

ml.setComplexClass(MyComplexClass.class);

Look at the JavaDocs for this method for information on what features a

class needs to have to be able to be used for this (such as re() and im()

methods or fields--things that any self-respecting complex class is certain

to have already.) You can get a complex number class from

http://www.yqcomputer.com/ 't already have one

and don't want to write one.

Todd Gayley

Wolfram Research

1. New real number handling using some feedback from studying complex numbers

2. Getting an image with JLink

3. getting freqz from fft (complex numbers)

4. Finding the Value (of text and numbers) between N/A's

5. regexp for reg language that has an even number of a's and b's

6. from image to complex number (complex valued matrix)

7. Getting number of days in a month -- getting the number of weeks in a year.

8. HP-35s Complex numbers and using deg min and sec

9. Using Matrix functions on complex numbers

10. Labview IFFT using Complex numbers

11. Complex number calculation using library

12. IFFT using complex numbers

13. can subs( ) used in solving for complex numbers??

14. solving differential equation using complex number

2 post • Page:**1** of **1**