unimportant changes
This commit is contained in:
parent
6dff42fe3c
commit
a66c6af575
@ -23,7 +23,7 @@ public class Matrix {
|
|||||||
public Matrix(int[][] matrix) {
|
public Matrix(int[][] matrix) {
|
||||||
this.matrix = matrix;
|
this.matrix = matrix;
|
||||||
rowLength = matrix.length;
|
rowLength = matrix.length;
|
||||||
columnLength = rowLength;
|
columnLength = matrix[0].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix multiply(Matrix m) {
|
public Matrix multiply(Matrix m) {
|
||||||
@ -66,13 +66,12 @@ public class Matrix {
|
|||||||
|
|
||||||
matrix = new int[rowLength][columnLength];
|
matrix = new int[rowLength][columnLength];
|
||||||
|
|
||||||
for(int columnIndex = 0; line != null && columnIndex < matrix.length; columnIndex++, line = br.readLine()) {
|
for(int columnIndex = 0; line != null; columnIndex++, line = br.readLine()) {
|
||||||
lineArray = line.split(";");
|
lineArray = line.split(";");
|
||||||
for(int rowIndex=0; rowIndex < matrix[columnIndex].length; rowIndex++) {
|
for(int rowIndex=0; rowIndex < matrix[columnIndex].length; rowIndex++) {
|
||||||
matrix[rowIndex][columnIndex] = Integer.parseInt(lineArray[rowIndex]);
|
matrix[rowIndex][columnIndex] = Integer.parseInt(lineArray[rowIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
br.close();
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -3,12 +3,12 @@ public class TestMatrix {
|
|||||||
Matrix matrix = new Matrix("/home/old/projects/Java/graphprogram/24n_01.csv");
|
Matrix matrix = new Matrix("/home/old/projects/Java/graphprogram/24n_01.csv");
|
||||||
Matrix scalarProduct;
|
Matrix scalarProduct;
|
||||||
|
|
||||||
System.out.println(matrix.getRowLength());
|
System.out.println("RowLength: " + matrix.getRowLength());
|
||||||
System.out.println(matrix.getColumnLength());
|
System.out.println("ColumnLength: " +matrix.getColumnLength());
|
||||||
|
|
||||||
System.out.println(matrix);
|
System.out.println("\nMatrix A: \n" + matrix);
|
||||||
|
|
||||||
scalarProduct = matrix.multiply(matrix);
|
scalarProduct = matrix.multiply(matrix);
|
||||||
System.out.println(scalarProduct);
|
System.out.println("\nScalarProduct A²: \n" + scalarProduct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user