I have been trying some simple tests using Clojure and its Java interop capabilities, and am running into some issues. I am interfacing with the Parallel Colt Java library, trying a LU factorization - a feature offered by Parallel Colt. I see errors of the form
" NoSuchMethodError edu.emory.mathcs.utils.ConcurrencyUtils.getThreadsBeginN_1D " ...
Here's some simple code I am using:
(ns colt-test.core
(:import [cern.colt.matrix.tdouble DoubleMatrix1D DoubleMatrix2D]
[cern.colt.matrix.tdouble.impl DenseDoubleMatrix2D DenseDoubleMatrix1D]
[cern.colt.matrix.tdouble.algo.decomposition DenseDoubleLUDecomposition]
[cern.colt.list.tdouble DoubleArrayList])
;; make a 1D double array, size N of random values up to val
(defn make-1D-rand-array [N val]
(let [v (repeatedly N #(rand val))]
(double-array v)))
;; make a 2D double array, size NxN of random values up to val
(defn make-2D-rand-array [N val]
(let [v (repeatedly N #(make-1D-rand-array N val))]
(into-array v)))
;; Test LU factorization
;; matrix A size 10 x 10, random values
(def A (DenseDoubleMatrix2D. (make-2D-rand-array 5 10.0)))
;; vector b of size 10, random values
(def b (DenseDoubleMatrix1D. (make-1D-rand-array 5 10.0)))
I can call some functions on "b", the DenseDoubleMatrix1D, such as size(), and elements(). Also, I can call
set(int index, double value)
using the clojure interop syntax as
(.set b 0 10.5)
and it will update the first element of "b" to 10.5.
However, when I call some other methods on "b", such as
assign(double value)
as
(.assign b 10.0)
to set all the elements of b to 10.0, I get a NoSuchMethodError. Essentially, I seem to have correct calls for some interop methods, but not others, and I am not sure what I am doing wrong.
I see the same error when I try
(DenseDoubleLUDecomposition. A)
For reference, here is the parallel colt javadoc ( http://incanter.org/docs/parallelcolt/api/ ) Note, I am using a slightly newer version of parallel colt.
I have figured out how to get this to work. I was using parallel-colt 0.10.0, and when I upgraded to version 0.10.1, everything works as expected.
Hope this helps someone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.