From: Noah Stein (noah_at_[hidden])
Date: 2008-03-28 03:25:00
Arash Partow wrote:
> Bruno Lalande wrote:
> > Indeed, things have to be clear on that point, and I'm a bit
> > about what really constitutes the concept of a point. What I have
> > understood until now is that a class is the point if it exposes:
> > * the value<>() getter and setter
> > * coordinate_type
> > * coordinate_count
> This is somewhat correct but might be an over-engineering of things to
> the point where it may be unuseable to a group of potential users
> (people that have large data sets that need things done efficiently).
> I have 10^9 x,y values as doubles give me the convex hull - can you
> imagine in the overhead if each of those pairs were to be converted to a
There's not any overhead. Back in 2002, inspired by Blitz++ I wrote a
template class that is entirely conceptual. The vector doesn't store any
data, it merely defines a conceptual vector of N dimensions to the outside
world and a an interface to get & set those elements to the subclasses that
define storage layouts. In the case of vectors that just a simple array of
numbers, the code was just as optimal as if I'd hand-coded the arithmetic
operators (+, -, dot product, cross product) inside a concrete class.
Instead, the algorithms were written for the abstract class. To give an
example of optimization, please examine the following code:
Matrix<float, 3, 3> m1, m2, m3;
m1 = 1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f,
7.0f, 8.0f, 9.0f;
m2 = 3.0f, 5.0f, 2.0f,
7.0f, 1.0f, 3.0f,
9.0f, 6.0f, 4.0f;
m3 = m1 + m2;
If you look at how the comma-delimited assignment works, there is a 9-level
recursively defined set of template class instances. The above code has two
of those. Then there's the addition. MSVC6 would optimize that down to
simply copying the 9 float values into m3 directly.
There is no inherent penalty for programming to abstractions, at least in
release mode. There is the possibility of expressivity and optimization.
> Actually most algorithm implementations I've seen use index operators
> thats possibly because the underlying point types were always nD
> structures so it makes it easy to do something like the following:
This is what I'm used to also. I have toyed with using enums to tailor
access to simulate domains. In game engines, you could have geometry
vectors & points accessed using X, Y, & Z whereas you could have texture
coordinates accessed with S, T and whatnot.
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.1/1346 - Release Date: 3/27/2008
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk