MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / SetBernoulliNumbersMore

Function SetBernoulliNumbersMore

extern/ttmath/ttmath.h:2284–2326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2282 */
2283 template<class ValueType>
2284 bool SetBernoulliNumbersMore(CGamma<ValueType> & cgamma, uint start, const volatile StopCalculating * stop = 0)
2285 {
2286 ValueType denominator, temp, temp2, temp3, m_, sum, sum2, n_, k_;
2287
2288 const uint n = 2;
2289 n_ = n;
2290
2291 // start is >= 2
2292 for(uint m=start ; m<cgamma.bern.size() ; ++m)
2293 {
2294 if( (m & 1) == 1 )
2295 {
2296 cgamma.bern[m].SetZero();
2297 }
2298 else
2299 {
2300 m_ = m;
2301
2302 temp = n_; // n_ = 2
2303 temp.Pow(m_);
2304 // temp = 2^m
2305
2306 denominator.SetOne();
2307 denominator.Sub(temp);
2308 if( denominator.exponent.AddOne() ) // it means: denominator.MulInt(2)
2309 denominator.SetNan();
2310
2311 // denominator = 2 * (1 - 2^m)
2312
2313 cgamma.bern[m] = SetBernoulliNumbersSum(cgamma, n_, m, stop);
2314
2315 if( stop && stop->WasStopSignal() )
2316 {
2317 cgamma.bern.resize(m); // valid numbers are in [0, m-1]
2318 return false;
2319 }
2320
2321 cgamma.bern[m].Div(denominator);
2322 }
2323 }
2324
2325 return true;
2326 }
2327
2328
2329 /*!

Callers 1

SetBernoulliNumbersFunction · 0.85

Calls 10

SetBernoulliNumbersSumFunction · 0.85
SetZeroMethod · 0.80
SetOneMethod · 0.80
WasStopSignalMethod · 0.80
sizeMethod · 0.45
PowMethod · 0.45
SubMethod · 0.45
AddOneMethod · 0.45
resizeMethod · 0.45
DivMethod · 0.45

Tested by

no test coverage detected