mikera / vectorz-clj

Fast matrix and vector maths library for Clojure - as a core.matrix implementation
203 stars 19 forks source link

Exponential with matrices #49

Closed marthall closed 9 years ago

marthall commented 9 years ago

Would it be possible to add support for doing exponential with matrices.

In python numpy, it is possible to do

$ A = np.array([[1,2],[3,4]])
$ 2 ** A
array([[ 2,  4],
       [ 8, 16]])

# as well as
$ A ** 2
array([[ 1,  4],
       [ 9, 16]])

This would be super-useful in more complex equations. I'm looking forward to hear from you!

mikera commented 9 years ago

I think this works already if you do something like the following:

(pow 2 (array :vectorz [[1 2] [3 4]]))
=> #object[mikera.matrixx.Matrix 0x70bdd4da "[[2.0,4.0],\n[8.0,16.0]]"]

Does that solve your issue?

marthall commented 9 years ago

Oh, that's awesome! I tried with (expt 2 (array :vectorz [[1 2] [3 4]])) where expt is from clojure.math.numeric-tower. Stupid of me :smile:

This will solve my problem. Thank you so much for this awesome library!