[Haskell-cafe] Python?
karczma at info.unicaen.fr
karczma at info.unicaen.fr
Wed May 11 16:17:12 EDT 2005
Tim Rowe writes:
> On 5/11/05, Jerzy Karczmarczuk <karczma at info.unicaen.fr> wrote:
>
>> Give me one single language where [3-d arrays are] natural and immediate.
>
> I don't know how Matlab does it, but I find the C++ standard library
> vector<vector<vector<float> > >
> entirely intuitive (apart, perhaps, for the need for those two spaces)!
Let's precise what I consider to be important in order to call it natural
and immediate. And, in general, useful.
1. The definition of a concrete object, not just its type, but, say,
the initialization with constants. Or/and, global initialization with
zeros.
2. Easy synthesis of multi-dim matrices out of "planes", of submatrices
of lesser dimensions;
it can be an 'overlay', like, say, making a colour image out of three
R/G/B planes, or making a 3D surfaces, or aking tensors through
external products.
3. Easy indexing, and not only A[i][j][k], etc., but slicing, the extraction
of sub-dimensional matrices, e.g., one column vector out of a 2D matrix
in Matlab: A(3,:). Also, extracting parts (e.g. sub-images).
Also, in mathematical context, "intelligent" indexing, e.g. treating
a matrix as implicitly anti-symmetric. Here the CAS systems as Maple
or Mathematica provide the adequate tools. C++ of course doesn't,
unless you overload [] yourself.
4. Readable iterators, perhaps something more compact than insipid do-loops.
5. If those matrices are used as mathematical objects: tensors, etc.,
I want to have some simple notation for inner multiplications/
contractions, etc. This is not just the syntax problem, but the
existence of good libraries as well...
6. Reshaping of those arrays. I thought that Matlab 'reshape' (or something
similar in Numeric Python) is a baroque, rarely used construction. Now
I use it quite often...
So, plenty of things. That's why this is not so trivial...
Jerzy Karczmarczuk
More information about the Haskell-Cafe
mailing list