Re: Dynamic multi-dimensional arrays.

From: Steven T. Hatton (susudata_at_setidava.kushan.aa)
Date: 06/04/04


Date: Fri, 04 Jun 2004 10:17:15 -0400

Havatcha wrote:

>> Wow. I don't even know what three stars in a row mean. C++ lets you
>> define fixed multi-dimensional arrays, so I'd assumed it would let you
>> define them dynamically with something similar to the usual notation.
>>
>
>
> Yeah, that would be lovely. You should consider using the Standard
> Template Library stuff
> (http://www.msoe.edu/eecs/cese/resources/stl/index.htm#WhatIs) for this
> kind of thing.

It depends what your objectives are. Things such as vector, of vector of
vector, are easier to implement than multidimensional mappings over
valarray. OTOH, valarray is designed to support maximum efficiency and
will most likely run faster than any of the other alternatives from the
Standard Library. Various people have proposed a real array template for
the standard. That is, a 'vector' of fixed size.

Check out the last three examples from this page:
http://www.research.att.com/~bs/3rd_code.html

Somewhere on Josuttis's site there is an example of an implementation of a
multidimensional array.
http://www.josuttis.com/libbook/index.html

> A raw array of pointers like the implementation described is very fast,
> but can make life difficult.

There are a lot of different matrix and multidimensional array
implementations such as are found at www.boost.org, Blitz++, MTL, etc.

>> I knew what vectors and some of that other stuff were, at one time. I'll
>> have to find out again. It's a lot of stuff to keep in one head.

I had taken a course in C++ just before templates came into the mainstream.
When I picked up C++ again this year, I thought it was going to be
relatively easy to get up to speed. I have never worked so hard at
learning anything in all my life, and I've read the
_Feynman_Lectures_on_Physics_ and worked the problems in the exercise
manual.

I should add that part of the reason it's been tough going is because I am
learning by using the latest gcc and the CVS images of KDevelop. It's not
called 'bleeding edge' for naught.

-- 
STH 
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org  SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org


Relevant Pages

  • Re: STL-Streams und Unicode/UTF-16
    ... Template von Haus aus eine Eierlegende Wollmilchsau ist. ... eigene Facette schreibt und diese dem Stream gibt. ... codecvt-Facette vorhanden ist (der Standard verlangt das). ...
    (microsoft.public.de.vc)
  • Re: Project 2007: how do I change indicated names of variables?
    ... Unfortunately, it does not work, since also in the copy of "Standard", I am only offered a selection of the original variables, the names of which I cannot change. ... You'll find the Data template used in many circumstances is "Standard" and unfortunately, ... In the Data Template Definition dialog you can select each cell in the box and in the "Show label in cell" enter whatever label you prefer. ... Project MVP ...
    (microsoft.public.project)
  • Re: Templates - Make Change to Normal.dotm
    ... "You need to go the Workgroup template route" do you mean making a template ... for every standard document and place them in the workgroup template folder ... and set this folder as standard for every user. ...
    (microsoft.public.word.newusers)
  • Re: Help Required: Operator overloaded function template and Friend
    ... the inability to deduce T is the correct behaviour. ... follow the Standard requirements precisely. ... > other compilers do with this situation since I have only gcc. ... > type of a class template whose type parameter needs to be deduced from ...
    (comp.lang.cpp)
  • Re: AW: GNAT compiler switches and optimization
    ... Can you point me to the section of the standard which specifies ... the memory layout of a multidimensional array? ... multidimensional array in row-major order, ...
    (comp.lang.ada)