User`s guide
Using Class Methods
Method Description
“maximumNonZeros”
on page 4-57
Returns the allocated capacity of a sparse array.
If the underlying array is nonsparse, this m ethod
returns the same value as
numberOfElements().
“numberOfNonZeros”
on page 4-58
Returns the number of nonzero elements in
a sparse array. If the underlying array is
nonsparse, this method returns the sam e value as
numberOfElements().
The examples that follow use the sparse MWArray object cons tructed below
using the “newSparse” on page 4-66 method of
MWNumericArray:
double[] Adata = { 0, 10, 0, 0, 40, 50, 60, 0, 0, 90};
int[] ri = {1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
int[] ci = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
MWNumericArray A = MWNumericArray.newSparse(ri, ci,
Adata, MWClassID.DOUBLE);
System.out.println(A.toString());
Here are the contents of the sparse MWArray:
(2,1) 50
(1,2) 10
(2,2) 60
(1,5) 40
(2,5) 90
isSparse. This method returns true if the MWArray object is sparse, and
false otherwise.
The prototype for the
isSparse method is as follows:
public boolean isSparse()
4-55