Great Konrad! Thank you. My code is similar to yours. I think I will put what you've just shown me to good use. There are a few good points I hadn't thought about. I'm so happy that you are working on this as well. I think Clojure has immense potential for scientific and mathematical computing, but this aspect has been somewhat neglected until now for some reason. Let's hope for a big change in this respect as soon as possible.
Rock On Jan 10, 10:01 am, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > On 09.01.2010, at 21:22, Rock wrote: > > > I'm working on implementing a solution for extracting slices of > > multidimensional vectors, in the sense of vectors of vectors. I'm > > taking the recursive route. > > I have some code for working with nested vectors here: > > > http://code.google.com/p/clj-multiarray/source/browse/src/clj_multiar... > > It's work in progress, but it may give you some ideas. > > > > > > > Anyway, I'm trying to follow the MATLAB path. For instance, suppose > > this is a 5x5 matrix: > > > (def a [[2 3 5 7 11] [13 17 19 23 29] [31 37 41 43 47] [53 59 61 > > 67 71] [73 79 83 89 97]]) > > > This: > > > (submvec a [[0 2 4] [0 2 4]]) > > > would yield: > > > [[2 5 11] [13 19 29] [31 41 47] [53 61 71] [73 83 97]] (actually a > > sequence) > > > In other words, [0 2 4] is to be interpreted as [START STRIDE END]. > > STRIDE should be optional. > > That's my "sample" function: > > (defn nv-sample > [x dim start end step] > (assert (vector? x)) > (if (zero? dim) > (vec (take-nth step (subvec x start end))) > (vec (map #(nv-sample % (dec dim) start end step) x)))) > > Just call it once for each dimension (0 and 1). > > Konrad.
-- 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