Good question.

Let's see. Now, nested vectors ... I don't like them too much for
these things. Why? Because they're just that: nested vectors. They're
not truly multidimensional vectors, and the more I think about them,
the more they really suck from that point of view. For instance, first
of all they're not that safe to use (for these purposes): you could
potentially have a RAGGED nested vector, which you might end up
passing to a function that's expecting a true multidimensional array!
What is one to do? Implement checks all over the place just to make
sure that it's ok? Don't like that. But it gets worse. I imagine, when
dealing with nested vectors, that there's no guarantee that the data
will be contiguous as when you're dealing with a linear vector. So, as
far as efficiency is concerned, maybe they're not that good, but I'm
not sure about that (don't know the implementation details.)

Most of all they're not FLEXIBLE. This point I would like to stress.
You can't easily know the size, rank, and dimensions at runtime, or in
general, with this data-structure. It's just all more complicated. You
have to basically always make sure you're dealing with a true
multidimensional array, and you have to devise a set of functions to
discover the characteristics of that array (and I'm not sure it's an
easy task). Not to mention changing views! That would really be even
more challenging. Maybe I haven't thought about this long enough, I
don't know. But my instincts tell me that nested vectors are no good
when it comes to this kind of stuff.

Rock

On Oct 27, 5:52 pm, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
> On 27.10.2009, at 17:46, Rock wrote:
>
> > What if we created a structmap (a sort of class), where we have a
> > flattened out one-dimensional clojure vector containing all the data
> > of our potentially multidimensional (rank n) array, together with its
> > dimensions and possibly other info? I believe the C scienitific
>
> That's certainly possible. In fact, this is very much how Colt and  
> netCDF represent multidimensional arrays, except that they use a Java  
> array as the 1D element storage space.
>
> The real question is what you gain from such an implementation.  
> Compared to
> 1) nested Clojure vectors
> 2) Colt or netCDF arrays
> what is the practical advantage of your proposed new data structure?
>
> One answer could be "the best of those two worlds", but do you have a  
> concrete application in mind where this would be a real advantage?
>
> > I think such an approach could be more flexible. You can have the
> > vector as a data pool, and the rest would be sort of like a view on
> > that data (which can be changed at runtime if one chooses to). For
>
> That's how nested Clojure vectors behave as well. With Colt and netCDF  
> arrays, creating such views is simple as well (but they are not  
> immutable).
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to