CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

Calculating polynomials in OF source

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   May 28, 2014, 13:44
Default Calculating polynomials in OF source
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 10
r08n is on a distinguished road
I noticed that the class member Foam:: polynomial::value() seems to calculate a polynomial by actually calculating the powers:

  167     forAll(coeffs_, i)
  168     {
  169         y += coeffs_[i].first()*pow(x, coeffs_[i].second());
  170     }
while Foam:: polynomialFunction::value () uses the Horner scheme:

  168     // avoid costly pow() in calculation
  169     scalar powX = x;
  170     for (label i=1; i<coeffs.size(); ++i)
  171     {
  172         val += coeffs[i]*powX;
  173         powX *= x;
  174     }
I'm just curious -- is there any reason to use the 'pow ()' function (rather than multiplication) in the former?
r08n is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Pre-Processing 25 March 6, 2017 11:03
wmake compiling new solver mksca OpenFOAM Programming & Development 13 August 18, 2014 22:26
problem on installing swak4Foam navid2 OpenFOAM Installation 2 May 30, 2012 04:32
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18
Version 15 on Mac OS X gschaider OpenFOAM Installation 120 December 2, 2009 11:23

All times are GMT -4. The time now is 06:03.