apache-commons-matrix for clojure not playing well with core.matrix?

123 Views Asked by At

I'm trying to use https://github.com/adereth/apache-commons-matrix to access the functionality of Apache Commons Math, via the Maven repo https://mvnrepository.com/artifact/org.apache.commons/commons-math3 .

My main guide is Matt Adereth's http://adereth.github.io/blog/2013/11/08/core-dot-matrix-plus-apache-commons-math/ , from 2013!? Surprise, surprise, there seems to have been some code rot. Several issues in particular:

  1. The code in the mvn repo is missing an extension (extend-protocol mp/PMatrixMultiply) present in the github repo here https://github.com/adereth/apache-commons-matrix/blob/ef1e2bccbee7f8b8f5d9fbfdfe7639c23f6c406f/src/apache_commons_matrix/core.clj#L192 ?

  2. Matt's guide suggests using (m/set-current-implementation :apache-commons), but clojure.core.matrix.implementations/KNOWN-IMPLEMENTATIONS has as its entry :commons-math apache-commons-matrix.core

  3. But (m/set-current-implementation :commons-math) throws a different error:

     Error loading core.matrix implementation:  apache-commons-matrix.core
     #error {
     :cause Too many arguments to throw, throw expects a single Throwable instance
     :via
     [{:type clojure.lang.Compiler$CompilerException
     :message Syntax error compiling throw at (apache_commons_matrix/core.clj:19:13).
     :data #:clojure.error{:phase :compile-syntax-check, :line 19, :column 13, :source apache_commons_matrix/core.clj, :symbol throw}
     :at [clojure.lang.Compiler analyzeSeq Compiler.java 7132]}
    

    indeed, the referenced line uses what looks like a bad call to clojure' (throw):

     (throw (ex-info "Apache Commons Math matrices only supports up to 2 dimensions") {:requested-shape dims})
    

anyone trying to make this potentially useful interop work?

0

There are 0 best solutions below