Changeset 84

Show
Ignore:
Timestamp:
08/01/06 02:35:00 (2 years ago)
Author:
Don Clugston
Message:

Added nextup(), nextdown() functions from IEEE 754R.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mathextra/RealAnalysis.d

    r82 r84  
    154154 
    155155unittest { 
     156    int numCalls; 
    156157    real cubicfn (real x) { 
     158       ++numCalls; 
     159       if (x>float.max) x = float.max; 
     160       if (x<-double.max) x = -double.max; 
    157161       return 0.386*x*x*x + 23*x*x + 15.7*x + 525.2; 
    158162    } 
    159  
    160163    void testbrent(real delegate(real) f, real x1, real x2) { 
    161164        real result = findRoot(f, x1, x2); 
     
    175178    testbrent( (real x) { return sin(x); }, 6, 90); 
    176179    testbrent(&cubicfn, -100, 100); 
    177     // This case performs extremely poorly, requiring 2000 iterations to converge. 
    178     // I think there may be a problem with the algorithm. 
    179     testbrent(&cubicfn, double.max, -double.max); 
     180    numCalls = 0; 
     181    // This case performs extremely poorly, requiring 17000 iterations to converge. 
     182    // The algorithm needs a logarithmic binary chop for these cases. 
     183    testbrent(&cubicfn, real.max, -double.max); 
     184    writefln("Num calls = ",numCalls); 
    180185} 
    181186 
  • trunk/test.d

    r82 r84  
    1717import mathextra.mathutil; 
    1818import mathextra.leastsqr; 
     19import mathextra.ieee; 
    1920 
    2021import std.stdio;