From -3758659439026482573
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,94e9c2bbb0060b48
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-07-30 16:57:01 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Allan_W@my-dejanews.com (Allan W)
Newsgroups: comp.std.c++
Subject: Re: Proposals for small vectors?
Date: Tue, 30 Jul 2002 23:56:50 GMT
Organization: http://groups.google.com/
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <23b84d65.0207301527.38062bdd@posting.google.com>
References: <87wurryywb.fsf@grue.ucsd.edu> <3D38FB4F.1020909@animats.com> <kyN_8.21$706.2733255@newssvr21.news.prodigy.com> <3D3CB3C6.20106@animats.com>
X-Trace: mail2news.demon.co.uk 1028073415 mail2news:11363 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Date: 30 Jul 2002 23:27:51 GMT
X-MailScanner: Passed
Lines: 51
Xref: archiver1.google.com comp.std.c++:12904

John Nagle <nagle@animats.com> wrote
>     "valmatrix" would support N x M matrices, with
> the size defined at template instantiation.  The
> underlying representation would be guaranteed to
> be a built-in array of the specified element type,
> and the underlying representation data would be
> accessable from the outside if needed.
> (There are many APIs in existence that use such
> a representation; this allows efficient C++
> use or encapsulation of them.)
>
>      Both row-major and column-major representations
> would be supported, again, determined at template
> instantiation time.  (OpenGL and Direct-X use 4x4
> matrices of different direction, so we must
> support both.)

I'm worried that a less-than-careful implementation could cause
major code bloat. If my program a 4x4, 4x8, 8x4, and 8x8 valmatrixes,
would a lot of code be instanciated four times? If I have both
row-major and column-major representations, would this grow to 8
times?

Judicious use of inheritance can drastically reduce the amount of
code generated from a template instanciation -- but in some
circumstances this can provide a (very modest) performance penalty.
Most code wouldn't even notice the performance difference, but I
suppose that video updates very well could -- and that could make
this type of code factoring inappropriate for graphics.

>      Like "valarray", the implementation would be
> optimized for performance, not generality.  If
> generality is needed, Boost's "Matrix" class
> is probably more appropriate.

I'm not a graphics programmer. Maybe it's reasonable to say, "this
is only appropriate for a graphics app where 'optimize' means
'optimize for speed, burn as much memory as you need'." But I'd
want that to be VERY explicit -- maybe in the class name (i.e.
GraphicsQuickValMatrix).

Among C++ novices, templates already have an (undeserved) reputation
for code bloat. If valmatrix ends up using a lot of code space, this
will be the first place that people point to "prove" this allegation.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



