Operations on matrixes

30 views
Skip to first unread message

C. Arel

unread,
Nov 9, 2012, 1:54:58 PM11/9/12
to inca...@googlegroups.com
Hi all,
I am trying to modify elements in a matrix that I created with (def the-matrix (matrix 1000 3)) .
I know that I can do the most operations with ($= the-matrix operator other-matrix).
The problem is that I have a seq of elements that corresponds to the matrix but can't figure out how to loop and add from the seq.

I have tried with (for [x seq] ($= the-matrix + x)) but it keeps freezing my repl. 

So it looks like this but with fewer elements in the colllections.

matrix = [0.0 0.0 0.0]  
seq = (23.33 333.3  9898.0)

How can I put the values from the sequence into the matrix??

Thanks,
 

Linus Ericsson

unread,
Nov 9, 2012, 6:46:37 PM11/9/12
to inca...@googlegroups.com
Just give the seq as the argument to the matrix-function, like this

(def m1 (matrix the-seq))

(def m1 (matrix '(23.33 333.3 9898.0)))
#'incanter.main/m1
incanter.main=> m1
[  23.3300
 333.3000
9898.0000]

Further info here: https://github.com/liebke/incanter/wiki/matrices

/L

C. Arel

unread,
Nov 10, 2012, 10:48:57 AM11/10/12
to inca...@googlegroups.com
Awesome!
Thanks Linus!
Reply all
Reply to author
Forward
0 new messages