math - C++ polynomials: indefinite integrals -


i trying find indefinite integral of polynomial, neither maths nor coding great. code compiles believe have wrong formula:

polynomial  polynomial :: indefiniteintegral() const {     polynomial result;     result.fdegree = fdegree + 1;     ( int = fdegree; > 0 ; i--){         result.fcoeffs[i] = pow(fcoeffs[i], (result.fdegree)) / (result.fdegree);     }     return result; } 

looks want is

for ( int = fdegree; > 0; --i ) {   result.fcoeffs[i]  = fcoeffs[i-1] / static_cast<float>(i); } 

i don't know underlying implementation of class, don't know how you're implementing fcoeffs (if doubles or floats) , if need worry i being out of bounds. if vector needs initialized right size; if map, may not need to.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -