Rock a écrit :

> What if I wanted to use Clojure for scientific computing, and in
> particular for doing linear algebra and matrix computations a la
> MATLAB?
> 
> What would my options be for representing matrices, not to mention,
> especially, MULTIDIMENSIONAL ARRAYS?
> 
> Would java arrays be the way to go, or nested vectors?

There are a couple of Java libraries that you can use. Unfortunately the 
  efforts to make everyone agree on a single library a few years ago 
have failed, so now you have to choose between a couple of incompatible 
libraries.

For matrix computations and linear algebra, your best choice is probably 
  the Colt library developed at CERN, or the somewhat parallelized 
version called Parallel Colt. Colt has arrays up to three dimensions for 
a couple of data types, enough for matrix stuff but not much more.

If you need higher-dimensional arrays, e.g. to store complex data sets, 
your best bet would be the netCDF implementation for Java, which 
contains a very complete array library that handles any number of 
dimensions. However, it provides no linear algebra at all.

Another library in this category is JAMA. It looks rather similar to 
Colt, but I never looked at it more closely.

There's also an array package developed by IBM in conjunction with an 
optimizing Java compiler to go with it, but apparently it is no longer 
maintained.


> at the moment. For instance, once you have a multidimensional array
> (whatever kind it is) you can't, I believe, access any property of
> that object at runtime to know its rank and dimensions, like you can
> do with MATLAB or Scientifc Python (NumPy), or other similar
> languages. And slicing, such as a[2:20:4, 1:9:3], which means every
> element in a with indices that go from start to finish with a certain
> step, seem to be problematic.

All the libraries listed above provide most of this functionality. Like 
NumPy, they represent an array as a 1D Java array containing the data 
elements plus bookkeeping information about the shape and strides.

> Actually the whole buiseness of having to deal with immutable (and
> lazy) data structures appears to make computing with matrices and
> multidimensional arrays a lot more difficult. Maybe this is just an
> impression. Opinions?

The array packages listed above all permit modification of the array 
elements. Fully immutable arrays are probably of little practical 
interest, but something similar to Clojures transients (data types that 
can be initialized once by the function that creates them and then 
become immutable) would probably be sufficient to change this. There is 
little practial experience with this at the moment.


Konrad.


__________ Information provenant d'ESET NOD32 Antivirus, version de la base des 
signatures de virus 4537 (20091023) __________

Le message a été vérifié par ESET NOD32 Antivirus.

http://www.eset.com



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