In order to debug a numeric discrepancy between a new Clojure version and an old Common Lisp versions of a program, I thought I'd see what happened if I switched to BigDecimals in the Clojure version. I've been using the vectorz-cl implementation of core.matrix, which only allows Doubles, but it's trival to switch the entire program over to ndarray (I love that!). It looked as if ndarray allowed BigDecimals, but they get lost during computations:
user=> (class (mget (matrix [[1 2][3 4]]) 0 0))
java.lang.Long
user=> (class (mget (matrix [[1.0 2.0][3.0 4.0]]) 0 0))
java.lang.Double
user=> (class (mget (matrix [[1.0M 2.0M][3.0M 4.0M]]) 0 0))
java.math.BigDecimal
user=> (class (mget (mmul (matrix [[1.0M 2.0M][3.0M 4.0M]]) (matrix [1.0M 1.0M]))))
java.lang.Double
user=> (class (mget (mmul (matrix [[1M 2M][3 4]]) (matrix [1 1]))))
java.lang.Double
Is that a policy, or does it have to do with the current implementation of operations such as addition? Might ndarray eventually support allowing a non-Double numeric type to be used everywhere? So far I haven't found anything that answers this question in this group or in core.matrix, but I might have missed something. Thanks-
Marshall