home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
test
/
floats
/
Matrix.java
< prev
next >
Wrap
Text File
|
1996-09-28
|
662b
|
35 lines
public class Matrix {
private double data[][];
private int size_x;
private int size_y;
public Matrix(int rows, int cols) {
size_x=cols;
size_y=rows;
data=new double[size_y][size_x];
}
public static Matrix Identity(int n) {
Matrix ret=new Matrix(n,n);
for(int m=0;m<n;m++)
ret.data[m][m]=1.0;
return ret;
}
public String toString(){
String ret=new String();
int n,m;
for(n=0;n<size_y;n++){
for(m=0;m<size_x;m++)
ret+=(data[n][m]+" ");
ret+="\n";
}
return ret;
}
public static void main(String args[]){
Matrix a=Matrix.Identity(20);
System.out.println(a);
}
}