On Tue, Nov 18, 2008 at 11:44 AM, everyman <[EMAIL PROTECTED]> wrote: > > The signature for the Java constructor I am trying to use is: > ; Matrix(double[][] A) > > (ns clojure-matrix > (:import (Jama Matrix))) > > clojure-matrix=> (new Matrix (to-array-2d [[1.0 2.0] [3.0 4.0]]))) > > java.lang.ClassCastException: [[Ljava.lang.Object; cannot be cast to > [[D
Java arrays are a bit tricky because of the various types involved. What you created is an array of Objects, each of which is an array of Objects, each of which is a (big-D) Double, or a [[Ljava.lang.Object. What you want to create is a [[D, or an array of Objects, each of which is an array of (small-d) doubles. This should build what you want: user=> (def my-tricky-array (into-array (map #(into-array Double/TYPE %) [[1 2][3 4]]))) #'user/my-tricky-array Take a look at it, and see that the type signature looks good: user=> my-tricky-array #<double[][] [EMAIL PROTECTED]> To unpack it into Clojure seqs again: user=> (map seq my-tricky-array) ((1.0 2.0) (3.0 4.0)) --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---