Java Reference
In-Depth Information
for
for ( int
int i = 0 ; i < rows ; i ++) {
System . out . print ( "{" );
for
int j = 0 ; j < cols ; j ++)
System . out . print ( " " + a [ i ][ j ] + "," );
System . out . println ( "}," );
for ( int
}
System . out . println ( "};" );
}
}
Here is a program that uses the Matrix class to multiply two arrays of int s:
int
int x [][] = {
{ 3 , 2 , 3 },
{ 5 , 9 , 8 },
};
int
int y [][] = {
{ 4 , 7 },
{ 9 , 3 },
{ 8 , 1 },
};
int
int z [][] = Matrix . multiply ( x , y );
Matrix . mprint ( x );
Matrix . mprint ( y );
Matrix . mprint ( z );
See Also
Consult a topic on numerical methods for more things to do with matrices; one of our re-
viewers recommends Numerical Recipes in Fortran by Teukolsky, Flannery, et al., available
as a PDF and for online viewing . The example recipes in that topic have been translated into
Java but are only available in this form to licensed purchasers of the software .
Commercial software packages can do some of these calculations for you; for one example,
see the numeric libraries available from Rogue Wave Software .
Search WWH ::




Custom Search