I am using the Java linear algebra library (ojalgo 32.0) for a scala project, and I ran into a strange problem. Each ojalgo method that I used works fine (for example, matrix and element multiplication, inverse and random matrix generation), with the exception of two seemingly simple matrix sizes. I have never had a problem calling java libraries before, and I am very interested in what happens. Here is a sample code in java that works fine:
public static void main(String[] arg) { MatrixFactory tmpFactory = PrimitiveMatrix.FACTORY; BasicMatrix wMat = tmpFactory.makeRandom(5,5,new Weibull(5.0, 2.0)); System.out.println(wMat.getColDim()); }
Simple translation into scala (using version 2.9.2):
object DataGen { def main(args:Array[String]):Unit = { val tmpFactory = PrimitiveMatrix.FACTORY val wMat = tmpFactory.makeRandom(5,5,new Weibull(5.0, 2.0)) println(wMat.getColDim) }
The scala code calls the following:
Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.ojalgo.access.Structure2D from class DataGen$ at DataGen$.main(DataGen.scala:11) at DataGen.main(DataGen.scala)
Line 11
println(wMat.getColDim).
A search for other cases of this error indicates that there are some known issues with access errors in scala, but I'm still not sure what the cause of the problem or the easiest workaround might be.
Chris source share