after having looked at many discussions like for example :
I am still stuck and I am not able to make the following code to work :
import org.apache.commons.math3.linear;
class linearAlgebraLearning{
public static void main(String[] args){
// Create a real matrix with two rows and three columns, using a factory
// method that selects the implementation class for us.
double[][] matrixData = { {1d,2d,3d}, {2d,5d,3d}};
RealMatrix m = MatrixUtils.createRealMatrix(matrixData);
// One more with three rows, two columns, this time instantiating the
// RealMatrix implementation class directly.
double[][] matrixData2 = { {1d,2d}, {2d,5d}, {1d, 7d}};
RealMatrix n = new Array2DRowRealMatrix(matrixData2);
// Note: The constructor copies the input double[][] array in both cases.
// Now multiply m by n
RealMatrix p = m.multiply(n);
System.out.println(p.getRowDimension()); // 2
System.out.println(p.getColumnDimension()); // 2
// Invert p, using LU decomposition
RealMatrix pInverse = new LUDecomposition(p).getSolver().getInverse();
}
}
So here are what I have done step by step.
First I installed Apache using
sudo apt-get install libcommons-math3-java
Then I have looked where commons-math3-java has been installed.
dpkg -L libcommons-math3-java
/.
/usr
/usr/share
/usr/share/maven-repo
/usr/share/maven-repo/org
/usr/share/maven-repo/org/apache
/usr/share/maven-repo/org/apache/commons
/usr/share/maven-repo/org/apache/commons/commons-math3
/usr/share/maven-repo/org/apache/commons/commons-math3/3.2
/usr/share/maven-repo/org/apache/commons/commons-math3/3.2/commons-math3-3.2.pom
/usr/share/maven-repo/org/apache/commons/commons-math3/debian
/usr/share/maven-repo/org/apache/commons/commons-math3/debian/commons-math3-debian.pom
/usr/share/doc
/usr/share/doc/libcommons-math3-java
/usr/share/doc/libcommons-math3-java/changelog.Debian.gz
/usr/share/doc/libcommons-math3-java/copyright
/usr/share/java
/usr/share/java/commons-math3.jar
/usr/share/maven-repo/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar
/usr/share/maven-repo/org/apache/commons/commons-math3/debian/commons-math3-debian.jar
/usr/share/java/commons-math3-3.2.jar
then I used ( as told in the Install commons math library for java in Ubuntu )
javac -cp .:/usr/share/java/commons-math3-3.2.jar linearAlgebraLearning.java
however I still an import error message :
linearAlgebraLearning.java:1: error: cannot find symbol
import org.apache.commons.math3.linear;
And additional errors since the compiler does not find the classes (like RealMatrix). I know that this kind question has been asked many times. People here might be tired of seeing this question... But I would be really happy if you could help me.
Ps : Because there is some bug with Eclipse on my linux distribution I am not using IDE and use gedit and the terminal.