User`s guide
4 Using MWArra y Classes
for (index[0] = 1; index[0] <= dims[0]; index[0]++)
sum += row[index[0]-1]*b.getDouble(index);
result[i][index[0]] = sum;
}
}
return result;
}
Working with Lo gical Arrays
The MWLogicalArray class provides a Java interface to a MATLAB logical
array.
MWLogicalArrays can be d ense or sparse.
Constructing an MWLogicalArray
The MWLogicalArray class provides a set of constructors and factory methods
for creating logical arrays. T he following table lists the supplied constructors.
Constructor Usage
MWLogicalArray()
Empty logical array
MWLogicalArray(type)
Logical
array w ith values initialized with
supplied data
Here, type represents supported Java types. MWLogicalArray supports the
following Java primitive types:
double, float, byte, short, int, long,
and
boolean. The following object types are also supported: subclasses of
java.lang.Number, java.lang.String,andjava.lang.Boolean. In addition
to supporting scalar values of the types listed, general N-dimensional arrays
of each type are also supported.
When numeric types are used, the values in the logical array are set to
true
if the input value is nonzero, and false otherw is e. The following exam ples
create a scalar logical array with its va lu e initialized to
true:
MWLogicalArray a1 = new MWLogicalArray(true);
MWLogicalArray a2 = new MWLogicalArray(1);
MWLogicalArray a3 = new MWLogicalArray("true");
MWLogicalArray a4 = new MWLogicalArray(new Boolean(true));
4-22