On 26.05.2009, at 00:31, aperotte wrote:

> I don't expect to yield the same results.  I would expect (.index m
> (int-array [0 1])) and (-> m (nth 1) (nth 0)) to yield the same
> results.  This is because the first is equivalent to taking item 0 in
> the first dimension (always rows) and item 1 in the second dimension
> (always columns), whereas the second type of statement would say (in
> your example) take item 0 of the last dimension (columns in this case)
> and then take item 1 of next to last dimension (rows in this case).

The documentation of nth does indeed say "last dimension", but I  
thought that was just a typo...

Given my example

        (def data [[1 2] [3 4] [5 6]])
        (def m (PersistentMatrix/create (int-array [1]) true))

I'd certainly expect

        (nth data 1)

and

        (nth m 1)

to return equivalent data structures, but that requires nth to select  
along the first dimension. And that's indeed what it does at the moment.

> On a related note, I am currently representing the matrices in column-
> major order, which is different from how C and Numpy represent
> matrices internally.  Thinking about matrices in column major order
> came more naturally to me (and I think the Colt library also
> represents in column major order), but I have been thinking about
> changing it.

Column-major order smells like Fortran... but there is nothing wrong  
with it, of course. It's an arbitraray convention, just like row- 
major order. Anyway, this shouldn't be visible to the user of the  
Clojure interface except when reshaping an array.

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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to