2

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?

rikb
  • 630
  • 5
  • 18
  • 1
    if linear algebra is what you need I suggest looking at dtype-next and neanderthal which are well-maintained and fast – alex314159 May 02 '22 at 10:25
  • Another option, [denisovan](https://github.com/cailuno/denisovan) is a core.matrix implementation backed by [Neanderthal](https://neanderthal.uncomplicate.org/). – Steffan Westcott May 02 '22 at 11:22
  • Good thoughts, and i've used neaderthal on x86 hardware. i'm looking for a solution that works on the M1/arm64. – rikb May 02 '22 at 17:22
  • For a simple, pure-java solution, I would also suggest looking at JAMA: https://math.nist.gov/javanumerics/jama/ – Alan Thompson May 02 '22 at 17:51

0 Answers0