Changeset 36639 in project


Ignore:
Timestamp:
09/18/18 16:47:37 (3 months ago)
Author:
kon
Message:

use global inlines (test)

Location:
release/5/fp-utils/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/fp-utils/trunk/fp-inlines.scm

    r36575 r36639  
    66;; - all instances of (fl< -0.0 0.0) found ?
    77
    8 (declare (bound-to-procedure ##sys#flonum-fraction))
     8(module fp-inlines
     9
     10(;export
     11  fpzero?
     12  fppositive?
     13  fpnatural?
     14  fpnegative?
     15  fpnon-positive?
     16  fpeven?
     17  fpodd? fpclosed-right? fpclosed?
     18  fpclosed-left?
     19  fpclosedr? fpclosedl?
     20  fpadd1 fpsub1
     21  fpsqr fpcub
     22  fplog2 fplog10
     23  fpdegree->radian fpradian->degree
     24  fp~= fp~<= fp~>=
     25  fpprecision-factor)
    926
    1027(import scheme
     
    1431;;;(mathh/mathh-constants)
    1532
    16 (define-constant FPLN2 0.6931471805599453094172321214581765680755)  ;ln(2)
    17 (define-constant FPLN10 2.3025850929940456840179914546843642076011) ;ln(10)
     33;(define-constant FPLN2 0.6931471805599453094172321214581765680755)  ;ln(2)
     34;(define-constant FPLN10 2.3025850929940456840179914546843642076011) ;ln(10)
    1835
    19 (define-constant FPDEG2RAD 0.0174532925199432957692369076848861271344)  ;pi/180
     36;(define-constant FPDEG2RAD 0.0174532925199432957692369076848861271344)  ;pi/180
    2037
    2138;;;
     
    2542(: fpzero? (float --> boolean))
    2643;
    27 (define-inline (fpzero? n) (or (fp= 0.0 n) (fp= -0.0 n)))
     44(define (fpzero? n) (or (fp= 0.0 n) (fp= -0.0 n)))
    2845
    2946(: fppositive? (float --> boolean))
    3047;
    31 (define-inline (fppositive? n) (fp< 0.0 n))
     48(define (fppositive? n) (fp< 0.0 n))
    3249
    3350(: fpnatural? (float --> boolean))
    3451;
    35 (define-inline (fpnatural? n) (fp<= 0.0 n))
     52(define (fpnatural? n) (fp<= 0.0 n))
    3653
    3754(: fpnegative? (float --> boolean))
    3855;
    39 (define-inline (fpnegative? n) (fp> 0.0 n))
     56(define (fpnegative? n) (fp> 0.0 n))
    4057
    4158(: fpnon-positive? (float --> boolean))
    4259;
    43 (define-inline (fpnon-positive? n) (fp>= 0.0 n))
    44 
    45 ;;
    46 
    47 (: fpquotient (float float --> float))
    48 ;
    49 (define-inline (fpquotient x y) (fptruncate (fp/ x y)))
    50 
    51 ;;
    52 
    53 (: fpfraction (float --> float))
    54 ;
    55 (define-inline (fpfraction n) (##sys#flonum-fraction n))
     60(define (fpnon-positive? n) (fp>= 0.0 n))
    5661
    5762;;
     
    5964(: fpeven? (float --> boolean))
    6065;
    61 (define-inline (fpeven? n) (fpzero? (fpfraction (fp/ n 2.0))))
     66(define (fpeven? n) (fpinteger? (fp/ n 2.0)))
    6267
    6368(: fpodd? (float --> boolean))
    6469;
    65 (define-inline (fpodd? n) (not (fpeven? n)))
     70(define (fpodd? n) (not (fpeven? n)))
    6671
    6772;;
     
    6974(: fpclosed-right? (float float float --> boolean))
    7075;
    71 (define-inline (fpclosed-right? l x h) (and (fp< l x) (fp<= x h)))
     76(define (fpclosed-right? l x h) (and (fp< l x) (fp<= x h)))
    7277
    7378(: fpclosed? (float float float --> boolean))
    7479;
    75 (define-inline (fpclosed? l x h) (and (fp<= l x) (fp<= x h)))
     80(define (fpclosed? l x h) (and (fp<= l x) (fp<= x h)))
    7681
    7782(: fpclosed-left? (float float float --> boolean))
    7883;
    79 (define-inline (fpclosed-left? l x h) (and (fp<= l x) (fp< x h)))
     84(define (fpclosed-left? l x h) (and (fp<= l x) (fp< x h)))
    8085
    81 (define-inline (fpclosedr? l x h) (fpclosed-right? l x h))
    82 (define-inline (fpclosedl? l x h) (fpclosed-left? l x h))
     86(define (fpclosedr? l x h) (fpclosed-right? l x h))
     87(define (fpclosedl? l x h) (fpclosed-left? l x h))
    8388
    8489;;
     
    8691(: fpadd1 (float --> float))
    8792;
    88 (define-inline (fpadd1 n) (fp+ n 1.0))
     93(define (fpadd1 n) (fp+ n 1.0))
    8994
    9095(: fpsub1 (float --> float))
    9196;
    92 (define-inline (fpsub1 n) (fp- n 1.0))
     97(define (fpsub1 n) (fp- n 1.0))
    9398
    9499;;
     
    96101(: fpsqr (float --> float))
    97102;
    98 (define-inline (fpsqr n) (fp* n n))
     103(define (fpsqr n) (fp* n n))
    99104
    100105(: fpcub (float --> float))
    101106;
    102 (define-inline (fpcub n) (fp* n (fp* n n)))
     107(define (fpcub n) (fp* n (fp* n n)))
    103108
    104109;;
     
    106111(: fplog2 (float --> float))
    107112;
    108 (define-inline (fplog2 x) (fp/ (fplog x) FPLN2))
     113(define (fplog2 x) (fp/ (fplog x) 0.6931471805599453094172321214581765680755))
    109114
    110115(: fplog10 (float --> float))
    111116;
    112 (define-inline (fplog10 x) (fp/ (fplog x) FPLN10))
     117(define (fplog10 x) (fp/ (fplog x) 2.3025850929940456840179914546843642076011))
    113118
    114119;;
     
    116121(: fpdegree->radian (float --> float))
    117122;
    118 (define-inline (fpdegree->radian deg) (fp* deg FPDEG2RAD))
     123(define (fpdegree->radian deg) (fp* deg 0.0174532925199432957692369076848861271344))
    119124
    120125(: fpradian->degree (float --> float))
    121126;
    122 (define-inline (fpradian->degree rad) (fp/ rad FPDEG2RAD))
     127(define (fpradian->degree rad) (fp/ rad 0.0174532925199432957692369076848861271344))
    123128
    124129;;
    125130
    126 (define-constant FP~EPS flonum-epsilon)
     131;(define-constant FP~EPS flonum-epsilon)
    127132
    128133;;
     
    130135(: fp~= (float float #!optional float --> boolean))
    131136;
    132 (define-inline (fp~= x y #!optional (eps FP~EPS)) (fp<= (fpabs (fp- x y)) eps))
     137(define (fp~= x y #!optional (eps flonum-epsilon)) (fp<= (fpabs (fp- x y)) eps))
    133138
    134139(: fp~<= (float float #!optional float --> boolean))
    135140;
    136 (define-inline (fp~<= x y #!optional (eps FP~EPS)) (or (fp< x y) (fp~= x y eps)))
     141(define (fp~<= x y #!optional (eps flonum-epsilon)) (or (fp< x y) (fp~= x y eps)))
    137142
    138143(: fp~>= (float float #!optional float --> boolean))
    139144;
    140 (define-inline (fp~>= x y #!optional (eps FP~EPS)) (or (fp> x y) (fp~= x y eps)))
     145(define (fp~>= x y #!optional (eps flonum-epsilon)) (or (fp> x y) (fp~= x y eps)))
    141146
    142147;;
     
    144149(: fpprecision-factor ((or float fixnum) #!optional float --> float))
    145150;
    146 (define-inline (fpprecision-factor p #!optional (base 10.0)) (fpexpt base (exact->inexact p)))
     151(define (fpprecision-factor p #!optional (base 10.0)) (fpexpt base (exact->inexact p)))
     152
     153) ;fp-inlines
  • release/5/fp-utils/trunk/fp-utils.egg

    r36575 r36639  
    33
    44((synopsis "fp utilities")
    5  (version "4.0.0")
     5 (version "4.1.0")
    66 (category misc)
    77 (author "[[kon lovett]]")
     
    99 (test-dependencies test)
    1010 (components
    11   (scheme-include fp-inlines
    12     (files "fp-inlines.scm"))
     11  (extension fp-inlines
     12    (inline-file)
     13    (types-file)
     14    (csc-options "-O3" "-d1" "-local" "-no-procedure-checks") )
    1315  (extension fp-utils
    1416    #;(inline-file)
    1517    (types-file)
    16     ;FIXME Error: (apply) bad argument type: #f
    17     #;(component-dependencies fp-inlines)
     18    (component-dependencies fp-inlines)
    1819    (csc-options "-O3" "-d1" "-local" "-no-procedure-checks") ) ) )
  • release/5/fp-utils/trunk/fp-utils.scm

    r36573 r36639  
    1313  fprandom
    1414  ;
    15   fpmodulo
    16   fpremainder
     15  fpmodulo fpquotient fpremainder
    1716  ;
    1817  fptruncate-with-precision
     
    3130  (chicken flonum)
    3231  (chicken fixnum)
    33   fx-utils)
    34 
    35 ;;;
    36 
    37 (include "fp-inlines")
     32  fx-utils
     33  fp-inlines)
    3834
    3935;;;
     
    5248;
    5349(define (fpmodulo x y) (fptruncate (C_fmod x y)))
     50
     51(: fpquotient (float float --> float))
     52;
     53(define (fpquotient x y) (fptruncate (fp/ x y)))
    5454
    5555(: fpremainder (float float --> float))
Note: See TracChangeset for help on using the changeset viewer.