Hi Dmitry,

One thing I've seen quite frequently in Clojure numerical code is some ugly 
code for manipulating Java arrays with areduce / aset / aget etc. It's one 
of the few areas where it's genuinely easier to write code in Java at the 
moment.

So it would be awesome if the Clojure NDArray could make this kind of thing 
much easier by allowing users to wrap / unwrap Java arrays into a 1D 
NDArray. This would then enable Java arrays to be modified via the standard 
core.matrix API functions.

Something like:

(def arr (double-array [1 2 3 4 5]))

(def ndarr (wrap-ndarray arr))  ;; wrap array as an NDArray

;; now use regular core.matrix functions to mutate the NDArray
(add! ndarr 1.0)  ;; add a scalar
(mul! ndarr 2.0)  ;; multiply by a scalar
(sub! ndarr [0 0 0 4 8])  ;; subtract a vector

(seq arr)
=> (4.0 6.0 8.0 6.0 4.0)

(esum ndarr) ;; calculate sum of array elements
=> 28.0

Note that the wrapped array has been mutated in place. I think this 
approach would generally be much more readable, more convenient and less 
error prone than trying to code the equivalent operations with loop / recur 
/ aset / aget / areduce etc.

On Tuesday, 28 May 2013 16:25:49 UTC+8, Dmitry Groshev wrote:
>
> Hello, Clojurians.
>
> I was selected during GSoC process to implement a core.matrix-compatible 
> NDArray in Clojure. More info about this project can be found at [1] and 
> [2]. However, I would be really happy to know if there are any comments, 
> wishes or feature requests regarding that proposals (please take note that 
> there is also a clojurecheck / QuickCheck mention in my proposal) from you, 
> the community, so I can plan ahead my commitment to the project.
>
> So, please, feel free to speak about your matrix- (or 
> pure-function-testing-) related itches.
>
> [1] 
> https://google-melange.appspot.com/gsoc/proposal/review/google/gsoc2013/si14/10001
> [2] 
> http://dev.clojure.org/display/community/Project+Ideas#ProjectIdeas-NDArrayImplementationinClojure
>

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to