core.matrix question: how to compute sum of elements in an array or matrix?
62 views
Skip to first unread message
Joachim De Beule
unread,
Nov 28, 2016, 3:43:39 PM11/28/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Numerical Clojure
I can't seem to find any specialised way in the clojure.core.matrix api docs for getting the sum of all elements in an array or matrix, or for summing all rows etc.
How should I go about this in core.matrix?
Thanks,
Joachim.
Joachim De Beule
unread,
Nov 28, 2016, 4:55:18 PM11/28/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Numerical Clojure
never mind, found it: esum, and then
And this for a matrix m I guess
(reduce + (map esum (rows ma)))
Mike Anderson
unread,
Dec 6, 2016, 11:22:09 PM12/6/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Numerical Clojure
You should be able to do (esum my-array) on the whole array.