Power function in TMath

From: Alexander Voigt <Alexander.Voigt_at_cern.ch>
Date: Tue, 20 Jul 2010 20:41:27 +0200


Dear ROOT developers,

I would like to make a suggestion for an improvement within the TMath class.

Physicists working with ROOT make heavy use of mathematics functions in TMath. Often they want to calculate powers with an integer exponent and are therefore doing things like

    TMath::Power(x, 2)

According to this ATLAS recommendation

    https://twiki.cern.ch/twiki/bin/view/Atlas/CalculatingIntegerPowers

one should always use std::pow() for these purposes (#include <cmath>), because of a factor 10 in performance gain. For this reason I propose the implementation of a function

    Double_t TMath::Power(Double_t, Int_t)

which simply encapsulates

    double std::pow( double, int );

or

    long double std::pow( long double, int );

from the cmath module of the C++ standard library.

Many thanks in advance,
Alexander Voigt Received on Tue Jul 20 2010 - 20:41:23 CEST

This archive was generated by hypermail 2.2.0 : Tue Jul 20 2010 - 23:50:02 CEST