import Jama.Matrix;
public class T5 {
public static void main(String args[]){
Matrix C=new Matrix(new double[][]{{1,0,0,},{0,1,0},{0,0,1}});
Scanner x;
try {
x=new Scanner(new File("D://out.txt"));
for (int i = 0; i < 100; i++) {
double a1= x.nextDouble();
Double b1=x.nextDouble();
double c1=x.nextDouble();
Matrix data1 = new Matrix(new double[][]{{a1, b1, c1}});
double a = data1.get(i, 0);
double b = data1.get(i, 1);
double c = data1.get(i, 2);
double[][] val = {{a}, {b}, {c}};
Matrix A_new = new Matrix(val);
Matrix newobser = C.times(A_new);
newobser.print(9, 6);
}
}
catch (Exception e){
System.out.println(e);
}
}
}
There is problem with this code. In this code there is a matrix data1
which have three column and 1 rows which iterate over time. I have file in hard disk name out.txt
.This file contain 100 rows and 3 columns.I try to take column 1 of out.txt in variable a1,column 2 of out.txt in variable b1,column 3 of out.txt in variable c1.Then input that a1,b1,c1 in Matrix data1.Here I use JAMA matrix which is a in build matrix package. Get
and print
, times(use for matrix multiplication)
are functions of JAMA matrix package. How could I proceed to taken input from an outside file?My process doesn't work.