Using Class Methods
System.out.println("The real data in matrix A is:");
x = (double[]) A.getData();
for (int i = 0; i < x.length; i++)
System.out.print(" " + x[i]);
System.out.println();
System.out.println();
System.out.println("The imaginary data in matrix A is:");
x = (double[]) A.getImagData();
for (int i = 0; i < x.length; i++)
System.out.print(" " + x[i]);
System.out.println();
When run, the example displays this output:
The real data in matrix A is:
2.0 8.0 14.0 3.0 9.0 15.0 4.0 10.0 16.0
The imaginary data in matrix A is:
6.0 7.0 1.0 5.0 1.0 1.0 14.0 23.0 9.0
getImagDouble. This method returns the imaginary part of the
MWNumericArray element located at the specified one-based index or index
array. The return value is given type
double.
Use either of the following prototypes f or the
getImagDouble method, where
index can be of type int or int[]:
public double getImagDouble(int index)
public double getImagDouble(int[] index)
Example — Getting Complex Data of a Specific Type
Using the same array as in the example for “getImag” on page 4 -81, get the
real and imaginary parts of one element of the
MWNumericArray:
int[] index = {2, 3};
System.out.println("The real part of A(2,3) = " +
A.getDouble(index));
4-83
Komentarze do niniejszej Instrukcji