4 Using MWArra y Classes
Example — Getting the Maximum Number of Nonzeros in an
MWArray
Display the maximum number of nonzeros for this array:
System.out.println("Maximum number of nonzeros for matrix A is "
+ A.maximumNonZeros());
When run, the example displays this output:
Maximum number of nonzeros for matrix A is 10
numberOfNonZeros. This method returns the number of nonzero elements
in a sparse array. If the underlying array is nonsparse, this method returns
the same value as
numberOfElements.
The prototype for the
numberOfNonZeros method is as follows:
public int numberOfNonZeros()
Input Parameters.
None
Example — Getting the Number of Nonzeros in an MWArray
Display the number of nonzero values in this array:
System.out.println("The number of nonzeros for matrix A is " +
A.numberOfNonZeros());
When run, the example displays this output:
The number of nonzeros for matrix A is 5
Using MWNumericArray
This section cov ers the following topics:
• “Constructing an MWNumericArray” on page 4-59
4-58
Komentarze do niniejszej Instrukcji