CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Calculating polynomials in OF source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 28, 2014, 13:44
Default Calculating polynomials in OF source
  #1
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
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:

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

Code:
  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

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 14 June 22, 2018 06:29
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 10:03
[swak4Foam] problem on installing swak4Foam navid2 OpenFOAM Community Contributions 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 17:18
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23


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