On 28 Oct 2009, at 22:21, Rock wrote:

> Your analysis is crystal clear and very helpful Konrad. But you
> haven't addressed the issue of dealing with useful information
> regarding the data structure itself. What if, for example, a function
> wanted to know the rank and dimensions of a multidimensional array it
> was being passed, and that array were represented by means of a nested
> vector?

I didn't address such issues because there is no point in discussing  
them before making the fundamental decision whether to use an abstract  
or an exposed data type for array data. That choice dictates the  
priorities for everything that follows.

> Suppose we're dealing with rank n objects. Do you think it
> would be an easy task to figure all that out dealing with nested
> vectors?

If you can assume the array is well-formed, it is rather easy.  
Otherwise it isn't.

> And by the way, How would you go about implementing in detail
> a check to see if a nested vector is actually an authentic
> multidimensional array or not?

That's a rather simple recursive function. The only problem is its run- 
time cost.

> I honestly prefer your first case scenario. Seems much more efficient,
> less resource-consuming, and just straightforward. But I really would
> like to know what your preference is. If you had to choose, which way
> would you go?

If I were to design an array interface for Clojure, it would consist  
of multimethods implemented for both an efficient array data structure  
for internal use and for nested vectors. The implementation for the  
latter would convert the nested vectors to the efficient structure and  
do all the necessary checks. It would be there for convenience and  
clarity in user code. Ideally I would then implement the same  
interface for Colt arrays and netCDF arrays as well, both for having  
an effcient structure for large data sets and for interoperability.  
And once we are at it, why not have another implementation for sparse  
arrays, using a suitable data structure?

Unfortunately, a good design and implementation represents a lot of  
work. At the moment I am not sure if we have the critical mass of  
people interested in working on this to get the job done in a  
reasonable amount of time.


On 28 Oct 2009, at 23:07, harrison clarke wrote:

> maps could also be an option. you can use vectors of ints as keys.  
> (and you can stick dimensions and such in there with keywords)
>
> i'm not sure how that compares to nested vectors for perforance. you  
> have the overhead of the hash function, but you don't have any  
> nesting.
> it's also pretty handy if you want to represent a sparse matrix.

Maps could be a good choice for sparse arrays. For dense ones, they  
would represent an enormous waste of memory, and probably time as well.

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