User`s guide
Guidelines for Working with MWArray Classes
System.out.print("] = " + a.getDouble(dims));
if (a.complexity() == MWComplexity.COMPLEX)
System.out.print(" + "+a.getImagDouble(dims)+"i");
System.out.print("\n");
}
}
The next example sums the real parts of all the elements in a numeric array
and returns the result as a
double value:
public double sumElements(MWNumericArray a)
{
double sum = 0.0;
int n = a.numberOfElements();
for (int i = 1; i <= n; i++)
sum = sum + a.getDouble(i);
return sum;
}
This example multiplies a Java double[][] with an MWNumericArray and
returns the result as a Java
double[][]:
public double[][] matrixMult(double[][] a, MWNumericArray b)
{
int[] dims = b.getDimensions();
double[][] result = new double[a.length][dims[1]];
int[] index = new int[2];
for (int i = 0; i < result.length; i++)
{
double[] row = a[i];
if (row.length != dims[0])
throw new IllegalArgumentException("Incompatible dims");
for (index[1] = 1; index[1] <= result[0].length; index[1]++)
{
double sum = 0.0;
4-21