RE: Proposal for new Physics Vector classes in ROOT

From: alan coelho <alan.coelho_at_attglobal.net>
Date: Thu, 9 Jun 2005 17:04:09 +0200


>- Throughout the code you are using templates (it's good and bad)
> why not to use templates and class inheritance with method
overloading
> for classes like BasicLorentzVector, PositionVector3D etc. -
> they are all "vectors" and should be derived from a single base
class.

Valeriy

You are partly right. Code that contains inheritance and virtual functions are more flexible and easy to read than something like the STL. Virtual functions however cannot be inlined and this can result in a severe performance hit.

Consider the simple loop:

	double s = 0.0;
	for (int i = 0; i < 1000000000; i++) {	
		s += 1.0;
	}

If you were to instead invoke a function call inside of this loop to do the add then this run around 6 times slower. If you had two unnecessary function calls (two adds) then it would run 12 times slower. If you made everything a function call then you would end up with interpreter speeds. There are ways of rearranging functons in memory to avoid a casche miss but this leads to more complications.

Thus virtual function are nice but unfortunately we are tied to a physical world where hardware dictates how we write code.

cheers
Alan

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch
[mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Valeriy Onuchin Sent: Thursday, June 09, 2005 2:16 PM
To: Lorenzo Moneta; roottalk_at_cern.ch; Andras Zsenei; Mf Mf; Walter E Brown
Subject: Re: [ROOT] Proposal for new Physics Vector classes in ROOT

Hi Lorenzo,
this is my personal impression (ignore it).

Regards. Valeriy

Valeriy Onuchin wrote:

> Hi Lorenzo,
> as Linus Torvalds says - "show me the code".
> Where can I find the latest sources of this library?
>
> Thanks. Regards. Valeriy
>
> Lorenzo Moneta wrote:
>
> > Dear ROOT users,
> >
> > This is a proposal describing new Physics Vector classes for 3D
> > (geometrical Points and Vectors) and 4D (LorentzVectors) with their
> > operations and transformations (rotations).
> >
> > The proposal is available, together with a prototype describing the
> > API for the classes at
> >
> >

http://seal.web.cern.ch/seal/MathLibs/GenVector/0-1-0/html/index.html
> >
> > These new  classes will be part of the new mathcore package
> > (part of libCore) and also available as a standalone library
> > (libMathCore).
> >
> > The main characteristics as explained in the linked Web page are:
> >
> >    -possibility to have Vector based on various coordinate systems
> >     such as  Cartesian, Polar and Cylindrical
> >    -distinction between position vectors (Points) and displacement
> > vectors
> >    -possibility to have classes based on arbitrary scalar type
(they
> >     are templated on the scalar value type)
> >
> > An easy connection to Linear Algebra Vector and Matrices classes is
> > also provided.

> >
> > The plan is to release a first version in the new ROOT version 5 at the
> > end of the month.
> > The current Physics classes, TVector3, TLorentzVector, .. will be kept,
> > and eventually they will be reimplemented using the new Vector classes
> > (but still being back compatible).
> >
> > It is also planned to add to libMathCore other classes such as
> >
> >    -Random number generators
> >    -Numerical algorithms such as adaptive integration,
> > differentiation, root finders
> >   - Some basics mathematical functions
> >
> > In addition we will provide a libMathMore library with a more
> > complete set of functions and algorithms
> > based on the GNU GSL library.
> >
> > Any comments, or feedback or criticism is highly welcomed,
> >
> >   Best Regards
> >
> >   Lorenzo Moneta  (on behalf of the ROOT Math Library Team)
Received on Thu Jun 09 2005 - 17:13:56 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET