On Freitag, 9. April 2004 14:39, Jon Berndt wrote:
> I am afraid it is much simpler than that: all I need is a 2 dimensional
> array, n X m.
For such a simple array it is best to use
data = new double[n*m]
and have access functions:
double Entry(unsigned int i,unsigned int j) const { return
data[(i-1)*n+j-1]; }
double& Entry(unsigned int i,unsigned int j) { return data[(i-1)*n+j-1]; }
Where the -1 terms are usually optimized away by the compiler.
Alternatively you can start indexing with 0 ...
For constants in the arguments to the Entry(..) function, this will be faster
than having an array of arrays, since the compiler can compute the offset to
the array pointer at compile time. If you have an array of arrays the
compiler needs to lookup array pointer in the first array and can then use
the precomputed offset.
For nonconst indices this kind of depends on the architecture and the
compiler ...
You will use more memory if you use this array of arrays ...
Greetings
Mathias
--
Mathias Fr�hlich, email: [EMAIL PROTECTED]
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel