I am using Universal Java Matrix Package to creating Matrix,Sparse Matrix,Identity Matrix and Matrix operation like addition,subtraction,transpose etc. I have some problem to implementing a code.
How to create identity Matrix using UJMP?
Here is my code
import org.ujmp.core.Matrix;
import java.io.File; import java.io.IOException; import java.util.Scanner; public class odou { public static void main(String args[])throws IOException { double t = 0.002; double time=0.0,forwardvelocity=0.0,angularvelocity=0.0; Matrix Gt=Matrix.Factory.zeros(3,3); Scanner x=new Scanner(new File("/home/froboticscse/IdeaProjects/UJMPtest/src/main/java/Robot1_O.txt")); while(x.hasNext()) { time = x.nextDouble(); forwardvelocity = x.nextDouble(); angularvelocity = x.nextDouble(); Gt.setAsDouble(1.0,0,0); Gt.setAsDouble(0.0,0,1); Gt.setAsDouble((-forwardvelocity*t*Math.sin(theta_initialU+(angularvelocity*t)/2)),0,2); Gt.setAsDouble(0.0,1,0); Gt.setAsDouble(1.0,1,1); Gt.setAsDouble((forwardvelocity*t*Math.cos(theta_initialU+(angularvelocity*t)/2)),1,2); Gt.setAsDouble(0.0,2,0); Gt.setAsDouble(0.0,2,1); Gt.setAsDouble(1.0,2,2); } }}
I have a file name Robot1_O.txt which consist of 3 column and various row. I am using Scanner class to scan this value. This value is loop within
Gt
matrix.Gt
is a 3*3 matrix. I also wanted to create a 3*3 identity matrix.After creating this identity matrix I create another matrix say
New
which is like(I -Gt)
. I cannot find any documentation about how to create identity matrix using UJMP.If any one know that please share it.