Changeset 8510 in project


Ignore:
Timestamp:
02/17/08 06:34:45 (12 years ago)
Author:
Kon Lovett
Message:

Save w/ canonical dir form.

Location:
release/3/mathh
Files:
3 added
3 copied
12 moved

Legend:

Unmodified
Added
Removed
  • release/3/mathh/trunk/doc.scm

    r8501 r8510  
    1313      "<math.h>") " that are not defined by Chicken."))
    1414
    15     (author "John Cowan")
    16 
    17     (history
    18       (version "1.903" "Added C int & float types. [Kon Lovett]")
    19       (version "1.9.2" "Added log1p (approx.) for Windows, scalbn. Native log2 for linux/macosx/bsd. [Kon Lovett]")
    20       (version "1.9.1" "Added integer-log-base2, count-set-bits, count-unset-bits [Kon Lovett]")
    21       (version "1.9" "Changed conditional compilation [Kon Lovett]")
    22       (version "1.8" "fixes in setup script and .meta file")
    23       (version "1.7" "installs mathh-constants.scm in include path [felix]")
    24       (version "1.6" "make-log/base [Kon Lovett]")
    25       (version "1.5" "fpclassify, fpclass, fxlog2 [Kon Lovett]")
    26       (version "1.4" "Added some limits [Kon Lovett]")
    27       (version "1.3" "Removed fpclassify (for now), tgamma -> gamma [Kon Lovett]")
    28       (version "1.2" "Added missing setup-header [felix]")
    29       (version "1.1" "More math.h functions & constants [Kon Lovett]")
    30       (version "1.0" "Initial release"))
     15    (author "John Cowan and Kon Lovett")
    3116
    3217    (usage)
     
    11398      )
    11499
    115       (subsection "Integer Procedures & Constants"
    116 
    117         (usage "(require-extension matth-int)")
     100      #;
     101      (subsection "Fixnum Procedures"
     102
     103        (usage "(require-extension fixnum-extras)")
    118104
    119105        (procedure "(fxlog2 N)"
     
    126112          (p "Returns the number of zero bits in the " (tt "N") " fixnum."))
    127113
    128         (procedure "(integer-log-base2 N)"
    129           (p "Returns the ceiling of log2 of the " (tt "N") " fixnum or integer flonum."))
    130 
    131         (procedure "(count-set-bits N)"
    132           (p "Returns the number of one bits in the " (tt "N") " fixnum or integer flonum."))
    133 
    134         (procedure "(count-unset-bits N)"
    135           (p "Returns the number of zero bits in the " (tt "N") " fixnum or integer flonum."))
     114        (procedure "(bitwise-count-bits N [FLAG #t])"
     115          (p "Returns the number of " (tt "FLAG") " bits in the integer"
     116          (tt "N") "."))
     117      )
     118
     119      #;
     120      (subsection "Bitwise Procedures"
     121
     122        (usage "(require-extension bitwise-extras)")
     123
     124      )
     125
     126      (subsection "Integer Constants"
     127
     128        (usage "(require-extension matth-int)")
    136129
    137130        (symbol-table
     
    156149      )
    157150
    158       (subsection "Floating-point Procedures & Constants"
     151      (subsection "Floating-point Constants"
    159152
    160153        (usage "(require-extension matth-float)")
     
    201194      )
    202195
    203       (subsection "Constants"
     196      (subsection "Math Constants"
    204197
    205198        (usage "(include \"mathh-constants\")")
     
    249242          (describe COS1 "cos(1)")
    250243          (describe ZETA3 "theta(3)") )
    251         )
    252       )
     244      )
     245    )
     246
     247    (history
     248      (version "1.10" "Cygwin compile fix. Removed \"count-set-bits\" & \"count-unset-bits\". [Kon Lovett]")
     249      (version "1.903" "Added C int & float types. [Kon Lovett]")
     250      (version "1.9.2" "Added log1p (approx.) for Windows, scalbn. Native log2 for linux/macosx/bsd. [Kon Lovett]")
     251      (version "1.9.1" "Added integer-log-base2, count-set-bits, count-unset-bits [Kon Lovett]")
     252      (version "1.9" "Changed conditional compilation [Kon Lovett]")
     253      (version "1.8" "fixes in setup script and .meta file")
     254      (version "1.7" "installs mathh-constants.scm in include path [felix]")
     255      (version "1.6" "make-log/base [Kon Lovett]")
     256      (version "1.5" "fpclassify, fpclass, fxlog2 [Kon Lovett]")
     257      (version "1.4" "Added some limits [Kon Lovett]")
     258      (version "1.3" "Removed fpclassify (for now), tgamma -> gamma [Kon Lovett]")
     259      (version "1.2" "Added missing setup-header [felix]")
     260      (version "1.1" "More math.h functions & constants [Kon Lovett]")
     261      (version "1.0" "Initial release"))
    253262
    254263      (section "License" (pre ,license))
  • release/3/mathh/trunk/mathh-fpclass.scm

    r8501 r8510  
    3131(define fpclass
    3232  (cond-expand
    33     [windows
    34       (foreign-lambda* symbol ((double x))
    35         "char *name;
     33    [(and windows (not cygwin))
     34      (foreign-lambda* symbol ((double x)) #<<END
     35        char *name;
    3636        switch (_fpclass(x)) {
    3737        case _FPCLASS_SNAN:
    38           name = \"signaling-nan\";
     38          name = "signaling-nan";
    3939          break;
    4040        case _FPCLASS_QNAN:
    41           name = \"quiet-nan\";
     41          name = "quiet-nan";
    4242          break;
    4343        case _FPCLASS_NINF:
    44           name = \"negative-infinite\";
     44          name = "negative-infinite";
    4545          break;
    4646        case _FPCLASS_NN:
    47           name = \"negative-normal\";
     47          name = "negative-normal";
    4848          break;
    4949        case _FPCLASS_ND:
    50           name = \"negative-subnormal\";
     50          name = "negative-subnormal";
    5151          break;
    5252        case _FPCLASS_NZ:
    53           name = \"negative-zero\";
     53          name = "negative-zero";
    5454          break;
    5555        case _FPCLASS_PZ:
    56           name = \"positive-zero\";
     56          name = "positive-zero";
    5757          break;
    5858        case _FPCLASS_PD:
    59           name = \"positive-subnormal\";
     59          name = "positive-subnormal";
    6060          break;
    6161        case _FPCLASS_PN:
    62           name = \"positive-normal\";
     62          name = "positive-normal";
    6363          break;
    6464        case _FPCLASS_PINF:
    65           name = \"positive-infinite\";
     65          name = "positive-infinite";
    6666          break;
    6767        default:
    68           name = \"unclassified\";
     68          name = "unclassified";
    6969          break;
    7070        }
    7171        C_return (name);
    72 ")] [else
    73       (foreign-lambda* symbol ((double x))
    74         "char *name;
     72END
     73        ) ]
     74    [else
     75      (foreign-lambda* symbol ((double x)) #<<END
     76        char *name;
    7577        switch (fpclassify(x)) {
    7678        case FP_INFINITE:
    77           name = x < 0 ? \"negative-infinite\" : \"positive-infinite\";
     79          name = x < 0 ? "negative-infinite" : "positive-infinite";
    7880          break;
    7981        case FP_NAN:
    8082          /*FIXME A quiet nan can be distinguished by bit inspection*/
    81           name = \"signaling-nan\";
     83          name = "signaling-nan";
    8284          break;
    8385        case FP_NORMAL:
    84           name = x < 0 ? \"negative-normal\" : \"positive-normal\";
     86          name = x < 0 ? "negative-normal" : "positive-normal";
    8587          break;
    8688        case FP_SUBNORMAL:
    87           name = x < 0 ? \"negative-subnormal\" : \"positive-subnormal\";
     89          name = x < 0 ? "negative-subnormal" : "positive-subnormal";
    8890          break;
    8991        case FP_ZERO:
    90           name = x == -0.0 ? \"negative-zero\" : \"positive-zero\";
     92          name = x == -0.0 ? "negative-zero" : "positive-zero";
    9193          break;
    9294        default:
    93           name = \"unclassified\";
     95          name = "unclassified";
    9496          break;
    9597        }
    9698        C_return (name);
    97 ")] ) )
     99END
     100        ) ] ) )
    98101
    99102;; Returns a symbol denoting the kind of floating-point number.
     
    101104(define fpclassify
    102105  (cond-expand
    103     [windows
    104       (foreign-lambda* symbol ((double x))
    105         "char *name;
     106    [(and windows (not cygwin))
     107      (foreign-lambda* symbol ((double x)) #<<END
     108        char *name;
    106109        switch (_fpclass(x)) {
    107110        case _FPCLASS_SNAN:
    108111        case _FPCLASS_QNAN:
    109           name = \"nan\";
     112          name = "nan";
    110113          break;
    111114        case _FPCLASS_NINF:
    112115        case _FPCLASS_PINF:
    113           name = \"infinite\";
     116          name = "infinite";
    114117          break;
    115118        case _FPCLASS_NN:
    116119        case _FPCLASS_PN:
    117           name = \"normal\";
     120          name = "normal";
    118121          break;
    119122        case _FPCLASS_ND:
    120123        case _FPCLASS_PD:
    121           name = \"subnormal\";
     124          name = "subnormal";
    122125          break;
    123126        case _FPCLASS_NZ:
    124127        case _FPCLASS_PZ:
    125           name = \"zero\";
     128          name = "zero";
    126129          break;
    127130        default:
    128           name = \"unclassified\";
     131          name = "unclassified";
    129132          break;
    130133        }
    131134        C_return (name);
    132 ")] [else
    133       (foreign-lambda* symbol ((double x))
    134         "char *name;
     135END
     136        ) ]
     137    [else
     138      (foreign-lambda* symbol ((double x)) #<<END
     139        char *name;
    135140        switch (fpclassify(x)) {
    136141        case FP_INFINITE:
    137           name = \"infinite\";
     142          name = "infinite";
    138143          break;
    139144        case FP_NAN:
    140           name = \"nan\";
     145          name = "nan";
    141146          break;
    142147        case FP_NORMAL:
    143           name = \"normal\";
     148          name = "normal";
    144149          break;
    145150        case FP_SUBNORMAL:
    146           name = \"subnormal\";
     151          name = "subnormal";
    147152          break;
    148153        case FP_ZERO:
    149           name = \"zero\";
     154          name = "zero";
    150155          break;
    151156        default:
    152           name = \"unclassified\";
     157          name = "unclassified";
    153158          break;
    154159        }
    155160        C_return (name);
    156 ")] ) )
     161END
     162        ) ] ) )
  • release/3/mathh/trunk/mathh-int.scm

    r8501 r8510  
    55        (usual-integrations)
    66        (generic)
     7        (no-bound-checks)
    78        (no-procedure-checks-for-usual-bindings)
    89  (export
    9         fxlog2 fx1bits fx0bits
    10     count-set-bits count-unset-bits
    11     ;;last-set-bit first-set-bit
    12     ;;bit-count bitwise-merge any-bits-set?
     10    ;
     11    unsigned-integer32-size
     12    maximum-unsigned-integer32
     13    ;
    1314    machine-word-bits
     15    machine-word-precision
    1416    maximum-machine-word
    15     most-negative-machine-word most-positive-machine-word
    16     most-positive-fixnum most-negative-fixnum
     17    most-negative-machine-word
     18    most-positive-machine-word
     19    ;
     20    fixnum-bits
    1721    fixnum-precision
    18     unsigned-char-size unsigned-short-size unsigned-int-size unsigned-long-size unsigned-long-long-size
    19     char-size short-size int-size long-size long-long-size
    20     unsigned-integer32-size maximum-unsigned-integer32) )
     22    most-positive-fixnum
     23    most-negative-fixnum
     24    ;
     25    char-size       unsigned-char-size
     26    short-size      unsigned-short-size
     27    int-size        unsigned-int-size
     28    long-size       unsigned-long-size
     29    long-long-size  unsigned-long-long-size ) )
     30
     31;;;
    2132
    2233#>
    23 /* Chicken.h includes one of these but be specific */
    24 #ifdef HAVE_STDINT_H
    25 # include <stdint.h>
     34#if defined (HAVE_LONG_LONG) && HAVE_LONG_LONG
     35# define UNSIGNED_LONG_LONG_SIZE  sizeof( unsigned long long )
     36# define LONG_LONG_SIZE           sizeof( long long )
    2637#else
    27 # include <sys/types.h>
    28   typedef u_int8_t  uint8_t;
    29   typedef u_int16_t uint16_t;
    30   typedef u_int32_t uint32_t;
    31   typedef u_int64_t uint64_t;
     38# define UNSIGNED_LONG_LONG_SIZE  0
     39# define LONG_LONG_SIZE           0
    3240#endif
    33 
    34 /* bitsizeof is C++, sigh */
    35 #define BITS_PER_BYTE 8
    36 #define bitsizeof(t) (sizeof(t) * BITS_PER_BYTE)
    37 
    38 /* UWORD_PRECISION - # of bits in magnitude */
    39 #ifdef C_SIXTY_FOUR
    40 #       define UWORD_PRECISION (64 - (1 + 1))
    41 #else
    42 #       define UWORD_PRECISION (32 - (1 + 1))
    43 #endif
    44 
    45 #ifdef C_SIXTY_FOUR
    46 #else
    47   static const
    48   int MultiplyDeBruijnBitPosition[32] =
    49   {
    50     0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
    51     31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
    52   };
    53 # define DeBruijnSequence 0x077CB531UL
    54 #endif
    55 
    56 /* FX_BITS_LIMIT - bitsizeof fixnum */
    57 #define FX_BITS_LIMIT (UWORD_PRECISION + 1)
    58 
    59 /*
    60  * Unsigned Integer Routines
    61  */
    62 
    63 /* Log2 for integer */
    64 #ifdef C_SIXTY_FOUR
    65 static
    66 C_uword uint_log2 (C_uword n)
    67 {
    68         C_uword r = 0;
    69   while (n >>= 1) ++r;
    70   return (r);
    71 }
    72 #else
    73 static
    74 C_uword uint_log2 (C_uword n)
    75 {
    76   n |= n >> 1; /* first round down to power of 2 */
    77   n |= n >> 2;
    78   n |= n >> 4;
    79   n |= n >> 8;
    80   n |= n >> 16;
    81   n = (n >> 1) + 1;
    82 
    83   return (MultiplyDeBruijnBitPosition[(n * DeBruijnSequence) >> 27]);
    84 }
    85 #endif
    86 
    87 /* Number of binary factors */
    88 #ifdef C_SIXTY_FOUR
    89 static
    90 C_word uint_log2_factors (C_uword n)
    91 {
    92   return (0 == n ? -1 : (uint_log2 (n & -n) - 1));
    93 }
    94 #else
    95 static
    96 C_word uint_log2_factors (C_uword n)
    97 {
    98   return (0 == n ? -1 : MultiplyDeBruijnBitPosition[((n & -n) * DeBruijnSequence) >> 27]);
    99 }
    100 #endif
    101 
    102 /* Number of 1 bits */
    103 static
    104 C_uword uint_1bits (C_uword n)
    105 {
    106 #       define TWO(c)     (0x1u << (c))
    107 #       define MASK(c)    (((C_uword)(-1)) / (TWO(TWO(c)) + 1u))
    108 #       define COUNT(x,c) ((x) & MASK(c)) + (((x) >> (TWO(c))) & MASK(c))
    109 
    110         n = COUNT(n, 0);
    111         n = COUNT(n, 1);
    112         n = COUNT(n, 2);
    113         n = COUNT(n, 3);
    114         n = COUNT(n, 4);
    115 #       ifdef C_SIXTY_FOUR
    116         n = COUNT(n, 5);
    117 #       endif
    118 
    119         return (n);
    120 }
    121 
    122 /* Number of 0 bits */
    123 static
    124 C_uword uint_0bits (C_uword n)
    125 {
    126         return (bitsizeof (n) - uint_1bits (n));
    127 }
    128 
    129 /* Merge under mask */
    130 static
    131 C_uword uint_if (C_uword mask, C_uword a, C_uword b)
    132 {
    133   return (a ^ ((a ^ b) & mask));
    134 }
    135 
    136 /* Bit intersection */
    137 static
    138 C_uword uint_test (C_uword a, C_uword b)
    139 {
    140   return ((a & b) != 0);
    141 }
    142 
    143 /*
    144  * Fixnum Routines
    145  */
    146 
    147 static
    148 C_uword fx_1bits (C_uword n)
    149 {
    150   n = uint_1bits (n);
    151         /* Account for the fixnum range limit due to the type bit */
    152         return (n > FX_BITS_LIMIT ? FX_BITS_LIMIT : n);
    153 }
    154 
    155 static
    156 C_uword fx_0bits (C_uword n)
    157 {
    158         return (FX_BITS_LIMIT - fx_1bits (n));
    159 }
    160 
    161 /*
    162  * Signed Integer Routines
    163  */
    164 
    165 static
    166 C_uword int_log2 (C_word n)
    167 {
    168   return (uint_log2 ((C_uword) ((n < 0) ? (-1 - n) : n)));
    169 }
    170 
    171 static
    172 C_uword int_log2_factors (C_word n)
    173 {
    174   return (uint_log2_factors ((C_uword) ((n < 0) ? (-1 - n) : n)));
    175 }
    176 
    177 /* Number of bits; 1s if pos, 0s if neg */
    178 static
    179 C_uword int_bits (C_word n)
    180 {
    181   return ((0 == n) ? 0 : uint_1bits ((C_uword) ((n < 0) ? (-1 - n) : n)));
    182 }
    183 
    184 static
    185 C_word int_if (C_word mask, C_word a, C_word b)
    186 {
    187   return (uint_if ((C_uword) mask, (C_uword) a, (C_uword) b));
    188 }
    189 
    190 static
    191 C_uword int_test (C_word a, C_word b)
    192 {
    193   return (uint_test ((C_uword) a, (C_uword) b));
    194 }
    19541<#
    19642
    19743;;;
    19844
    199 (define fxlog2 (foreign-lambda unsigned-int "uint_log2" unsigned-int))
    200 (define fx1bits (foreign-lambda unsigned-int "fx_1bits" unsigned-int))
    201 (define fx0bits (foreign-lambda unsigned-int "fx_0bits" unsigned-int))
     45(define unsigned-integer32-size (foreign-value "sizeof( uint32_t )" unsigned-int))
     46(define maximum-unsigned-integer32 (foreign-value "((uint32_t) (~0U))" unsigned-integer32))
    20247
    20348;;;
    20449
    205 (define count-set-bits (foreign-lambda unsigned-int "uint_1bits" unsigned-integer))
    206 (define count-unset-bits (foreign-lambda unsigned-int "uint_0bits" unsigned-integer))
    207 
    208 ;;;
    209 
    210 #|
    211 (define last-set-bit (foreign-lambda unsigned-int "int_log2" integer))
    212 (define first-set-bit (foreign-lambda unsigned-int "int_log2_factors" integer))
    213 (define bit-count (foreign-lambda unsigned-int "int_bits" integer))
    214 (define bitwise-merge (foreign-lambda integer "int_if" integer integer integer))
    215 (define any-bits-set? (foreign-lambda bool "int_test" integer integer))
    216 |#
    217 
    218 ;;;
    219 
    220 (define most-positive-fixnum (foreign-value "C_MOST_POSITIVE_FIXNUM" int))
    221 (define most-negative-fixnum (foreign-value "C_MOST_NEGATIVE_FIXNUM" int))
    222 
    223 (define fixnum-precision (foreign-value "UWORD_PRECISION" int))
    224 
    225 ;;;
    226 
    227 (define machine-word-bits (foreign-value "bitsizeof(C_word)" unsigned-int))
    228 
     50(define machine-word-bits (foreign-value "C_WORD_SIZE" unsigned-int))
     51(define machine-word-precision (foreign-value "(C_WORD_SIZE - 1)" unsigned-int))
    22952(define maximum-machine-word (foreign-value "C_UWORD_MAX" unsigned-long))
    230 
    23153(define most-negative-machine-word (foreign-value "C_WORD_MIN" long))
    23254(define most-positive-machine-word (foreign-value "C_WORD_MAX" long))
     
    23456;;;
    23557
    236 (define unsigned-integer32-size (foreign-value "sizeof(uint32_t)" unsigned-int))
    237 
    238 (define maximum-unsigned-integer32 (foreign-value "(uint32_t)(~0u)" unsigned-integer32))
     58(define fixnum-bits (foreign-value "(C_WORD_SIZE - 1)" int))
     59(define fixnum-precision (foreign-value "(C_WORD_SIZE - (1 + 1))" int))
     60(define most-positive-fixnum (foreign-value "C_MOST_POSITIVE_FIXNUM" int))
     61(define most-negative-fixnum (foreign-value "C_MOST_NEGATIVE_FIXNUM" int))
    23962
    24063;;;
    24164
    242 (define unsigned-char-size (foreign-value "sizeof(unsigned char)" unsigned-int))
    243 (define unsigned-short-size (foreign-value "sizeof(unsigned short)" unsigned-int))
    244 (define unsigned-int-size (foreign-value "sizeof(unsigned int)" unsigned-int))
    245 (define unsigned-long-size (foreign-value "sizeof(unsigned long)" unsigned-int))
     65(define unsigned-char-size (foreign-value "sizeof( unsigned char )" unsigned-int))
     66(define unsigned-short-size (foreign-value "sizeof( unsigned short )" unsigned-int))
     67(define unsigned-int-size (foreign-value "sizeof( unsigned int )" unsigned-int))
     68(define unsigned-long-size (foreign-value "sizeof( unsigned long )" unsigned-int))
     69(define unsigned-long-long-size (foreign-value "UNSIGNED_LONG_LONG_SIZE" unsigned-int))
    24670
    247 (define char-size (foreign-value "sizeof(unsigned char)" unsigned-int))
    248 (define short-size (foreign-value "sizeof(unsigned short)" unsigned-int))
    249 (define int-size (foreign-value "sizeof(unsigned int)" unsigned-int))
    250 (define long-size (foreign-value "sizeof(unsigned long)" unsigned-int))
    251 
    252 (cond-expand
    253   [has-long-long-type
    254     (define unsigned-long-long-size (foreign-value "sizeof(unsigned long long)" unsigned-int))
    255     (define long-long-size (foreign-value "sizeof(long long)" unsigned-int)) ]
    256   [else
    257     (define unsigned-long-long-size 0)
    258     (define long-long-size 0) ] )
    259 
     71(define char-size (foreign-value "sizeof( unsigned char )" unsigned-int))
     72(define short-size (foreign-value "sizeof( unsigned short )" unsigned-int))
     73(define int-size (foreign-value "sizeof( unsigned int )" unsigned-int))
     74(define long-size (foreign-value "sizeof( unsigned long )" unsigned-int))
     75(define long-long-size (foreign-value "LONG_LONG_SIZE" unsigned-int))
  • release/3/mathh/trunk/mathh.html

    r8501 r8510  
    154154<p>Provides access to ISO C math functions &amp; constants in <code>&lt;math.h&gt;</code> that are not defined by Chicken.</p></div>
    155155<div class="section">
    156 <h3>Author</h3>John Cowan</div>
     156<h3>Author</h3>John Cowan and Kon Lovett</div>
     157<div class="section">
     158<h3>Usage</h3><tt>(require-extension mathh)</tt></div>
     159<div class="section">
     160<h3>Download</h3><a href="mathh.egg">mathh.egg</a></div>
     161<div class="section">
     162<h3>Documentation</h3>
     163<div class="subsection">
     164<h4>Floating-point Functions</h4>
     165<p>The following procedures are provided, with their usual meaning.</p>
     166<p>Windows does not provide native implementations of log1p, lgamma, tgamma. However log1p is approximated.</p>
     167<p>The Bessel functions are prefixed by 'bessel-' to distinguish the names from common variables.</p>
     168<dt class="definition"><strong>procedure:</strong> (bessel-j0 N)</dt>
     169<dd></dd>
     170<dt class="definition"><strong>procedure:</strong> (bessel-j1 N)</dt>
     171<dd></dd>
     172<dt class="definition"><strong>procedure:</strong> (bessel-jn O N)</dt>
     173<dd></dd>
     174<dt class="definition"><strong>procedure:</strong> (bessel-y0 N)</dt>
     175<dd></dd>
     176<dt class="definition"><strong>procedure:</strong> (bessel-y1 N)</dt>
     177<dd></dd>
     178<dt class="definition"><strong>procedure:</strong> (bessel-yn O N)</dt>
     179<dd></dd>
     180<dt class="definition"><strong>procedure:</strong> (cosh N)</dt>
     181<dd></dd>
     182<dt class="definition"><strong>procedure:</strong> (sinh N)</dt>
     183<dd></dd>
     184<dt class="definition"><strong>procedure:</strong> (tanh N)</dt>
     185<dd></dd>
     186<dt class="definition"><strong>procedure:</strong> (hypot N1 N2)</dt>
     187<dd></dd>
     188<dt class="definition"><strong>procedure:</strong> (gamma N)</dt>
     189<dd></dd>
     190<dt class="definition"><strong>procedure:</strong> (lgamma N)</dt>
     191<dd></dd>
     192<dt class="definition"><strong>procedure:</strong> (log10 N)</dt>
     193<dd></dd>
     194<dt class="definition"><strong>procedure:</strong> (log2 N)</dt>
     195<dd></dd>
     196<dt class="definition"><strong>procedure:</strong> (log1p N)</dt>
     197<dd></dd>
     198<dt class="definition"><strong>procedure:</strong> (make-log/base BASE)</dt>
     199<dd>
     200<p>Returns a procedure of one argument, the logarithm function for <tt>BASE</tt>.</p></dd>
     201<dt class="definition"><strong>procedure:</strong> (ldexp N)</dt>
     202<dd></dd>
     203<dt class="definition"><strong>procedure:</strong> (scalbn N)</dt>
     204<dd></dd>
     205<dt class="definition"><strong>procedure:</strong> (fpmod N M)</dt>
     206<dd>
     207<p>Returns the modulus of <tt>N</tt> for <tt>M</tt>.</p></dd>
     208<dt class="definition"><strong>procedure:</strong> (modf N)</dt>
     209<dd>
     210<p>Returns two values, the integral and fractional part of <tt>N</tt>.</p></dd>
     211<dt class="definition"><strong>procedure:</strong> (frexp N)</dt>
     212<dd>
     213<p>Returns two values, the fraction and the exponent part of <tt>N</tt>.</p></dd></div>
     214<div class="subsection">
     215<h4>Float Classification</h4>
     216<div class="section">
     217<h3>Usage</h3>(require-extension matth-fpclass)</div>
     218<dt class="definition"><strong>procedure:</strong> (fpclassify N)</dt>
     219<dd>
     220<p>Returns a symbol denoting the kind of floating-point number.</p><table class="symbol-table">Float Class
     221<tr>
     222<td class="symbol">infinite</td>
     223<td></td></tr>
     224<tr>
     225<td class="symbol">nan</td>
     226<td></td></tr>
     227<tr>
     228<td class="symbol">normal</td>
     229<td></td></tr>
     230<tr>
     231<td class="symbol">subnormal</td>
     232<td></td></tr>
     233<tr>
     234<td class="symbol">zero</td>
     235<td></td></tr>
     236<tr>
     237<td class="symbol">unclassified</td>
     238<td></td></tr></table></dd>
     239<dt class="definition"><strong>procedure:</strong> (fpclass N)</dt>
     240<dd>
     241<p>Returns a symbol denoting the kind of floating-point number.</p><table class="symbol-table">Float Class
     242<tr>
     243<td class="symbol">positive-infinite</td>
     244<td></td></tr>
     245<tr>
     246<td class="symbol">negative-infinite</td>
     247<td></td></tr>
     248<tr>
     249<td class="symbol">quiet-nan</td>
     250<td></td></tr>
     251<tr>
     252<td class="symbol">signaling-nan</td>
     253<td></td></tr>
     254<tr>
     255<td class="symbol">positive-normal</td>
     256<td></td></tr>
     257<tr>
     258<td class="symbol">negative-normal</td>
     259<td></td></tr>
     260<tr>
     261<td class="symbol">positive-subnormal</td>
     262<td></td></tr>
     263<tr>
     264<td class="symbol">negative-subnormal</td>
     265<td></td></tr>
     266<tr>
     267<td class="symbol">positive-zero</td>
     268<td></td></tr>
     269<tr>
     270<td class="symbol">negative-zero</td>
     271<td></td></tr>
     272<tr>
     273<td class="symbol">unclassified</td>
     274<td></td></tr></table></dd></div>
     275<div class="subsection">
     276<h4>Integer Constants</h4>
     277<div class="section">
     278<h3>Usage</h3>(require-extension matth-int)</div><table class="symbol-table">
     279<tr>
     280<td class="symbol">most-positive-fixnum</td>
     281<td>Largest positive fixnum</td></tr>
     282<tr>
     283<td class="symbol">most-negative-fixnum</td>
     284<td>Smallest negative fixnum</td></tr>
     285<tr>
     286<td class="symbol">fixnum-precision</td>
     287<td>Number of bits in fixnum</td></tr>
     288<tr>
     289<td class="symbol">machine-word-bits</td>
     290<td>Number of bits in machine word - C_word</td></tr>
     291<tr>
     292<td class="symbol">maximum-machine-word</td>
     293<td>Largest machine word value - C_uword</td></tr>
     294<tr>
     295<td class="symbol">most-negative-machine-word</td>
     296<td>Smallest negative machine word value - C_word</td></tr>
     297<tr>
     298<td class="symbol">most-positive-machine-word</td>
     299<td>Largest positive machine word value - C_word</td></tr>
     300<tr>
     301<td class="symbol">unsigned-integer32-size</td>
     302<td>Sizeof uint32_t</td></tr>
     303<tr>
     304<td class="symbol">maximum-unsigned-integer32</td>
     305<td>Largest value for uint32_t</td></tr>
     306<tr>
     307<td class="symbol">unsigned-char-size</td>
     308<td>Sizeof the C type</td></tr>
     309<tr>
     310<td class="symbol">unsigned-short-size</td>
     311<td>Sizeof the C type</td></tr>
     312<tr>
     313<td class="symbol">unsigned-int-size</td>
     314<td>Sizeof the C type</td></tr>
     315<tr>
     316<td class="symbol">unsigned-long-size</td>
     317<td>Sizeof the C type</td></tr>
     318<tr>
     319<td class="symbol">unsigned-long-long-size</td>
     320<td>Sizeof the C type, 0 when unsupported</td></tr>
     321<tr>
     322<td class="symbol">char-size</td>
     323<td>Sizeof the C type</td></tr>
     324<tr>
     325<td class="symbol">short-size</td>
     326<td>Sizeof the C type</td></tr>
     327<tr>
     328<td class="symbol">int-size</td>
     329<td>Sizeof the C type</td></tr>
     330<tr>
     331<td class="symbol">long-long-size</td>
     332<td>Sizeof the C type, 0 when unsupported</td></tr></table></div>
     333<div class="subsection">
     334<h4>Floating-point Constants</h4>
     335<div class="section">
     336<h3>Usage</h3>(require-extension matth-float)</div><table class="symbol-table">
     337<tr>
     338<td class="symbol">float-radix</td>
     339<td>Representation base of floating point number</td></tr>
     340<tr>
     341<td class="symbol">maximum-float</td>
     342<td>Largest floating point number</td></tr>
     343<tr>
     344<td class="symbol">minimum-float</td>
     345<td>Smallest floating point number</td></tr>
     346<tr>
     347<td class="symbol">float-epsilon</td>
     348<td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
     349<tr>
     350<td class="symbol">float-precision</td>
     351<td>Number of digits in mantissa base radix of floating point number</td></tr>
     352<tr>
     353<td class="symbol">float-decimal-precision</td>
     354<td>Number of digits in mantissa base 10 of floating point number</td></tr>
     355<tr>
     356<td class="symbol">float-maximum-exponent</td>
     357<td>Largest exponent in base radix of floating point number</td></tr>
     358<tr>
     359<td class="symbol">float-minimum-exponent</td>
     360<td>Smallest exponent in base radix of floating point number</td></tr>
     361<tr>
     362<td class="symbol">float-maximum-decimal-exponent</td>
     363<td>Largest exponent in base 10 of floating point number</td></tr>
     364<tr>
     365<td class="symbol">float-minimum-decimal-exponent</td>
     366<td>Smallest exponent in base 10 of floating point number</td></tr>
     367<tr>
     368<td class="symbol">maximum-double</td>
     369<td>Largest floating point number</td></tr>
     370<tr>
     371<td class="symbol">minimum-double</td>
     372<td>Smallest floating point number</td></tr>
     373<tr>
     374<td class="symbol">double-epsilon</td>
     375<td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
     376<tr>
     377<td class="symbol">double-precision</td>
     378<td>Number of digits in mantissa base radix of floating point number</td></tr>
     379<tr>
     380<td class="symbol">double-decimal-precision</td>
     381<td>Number of digits in mantissa base 10 of floating point number</td></tr>
     382<tr>
     383<td class="symbol">double-maximum-exponent</td>
     384<td>Largest exponent in base radix of floating point number</td></tr>
     385<tr>
     386<td class="symbol">double-minimum-exponent</td>
     387<td>Smallest exponent in base radix of floating point number</td></tr>
     388<tr>
     389<td class="symbol">double-maximum-decimal-exponent</td>
     390<td>Largest exponent in base 10 of floating point number</td></tr>
     391<tr>
     392<td class="symbol">double-minimum-decimal-exponent</td>
     393<td>Smallest exponent in base 10 of floating point number</td></tr>
     394<tr>
     395<td class="symbol">maximum-long-double</td>
     396<td>Largest floating point number</td></tr>
     397<tr>
     398<td class="symbol">minimum-long-double</td>
     399<td>Smallest floating point number</td></tr>
     400<tr>
     401<td class="symbol">long-double-epsilon</td>
     402<td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
     403<tr>
     404<td class="symbol">long-double-precision</td>
     405<td>Number of digits in mantissa base radix of floating point number</td></tr>
     406<tr>
     407<td class="symbol">long-double-decimal-precision</td>
     408<td>Number of digits in mantissa base 10 of floating point number</td></tr>
     409<tr>
     410<td class="symbol">long-double-maximum-exponent</td>
     411<td>Largest exponent in base radix of floating point number</td></tr>
     412<tr>
     413<td class="symbol">long-double-minimum-exponent</td>
     414<td>Smallest exponent in base radix of floating point number</td></tr>
     415<tr>
     416<td class="symbol">long-double-maximum-decimal-exponent</td>
     417<td>Largest exponent in base 10 of floating point number</td></tr>
     418<tr>
     419<td class="symbol">long-double-minimum-decimal-exponent</td>
     420<td>Smallest exponent in base 10 of floating point number</td></tr>
     421<tr>
     422<td class="symbol">long-double-radix</td>
     423<td>Representation base of floating point number</td></tr>
     424<tr>
     425<td class="symbol">maximum-flonum</td>
     426<td>Largest floating point number</td></tr>
     427<tr>
     428<td class="symbol">minimum-flonum</td>
     429<td>Smallest floating point number</td></tr>
     430<tr>
     431<td class="symbol">flonum-epsilon</td>
     432<td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
     433<tr>
     434<td class="symbol">flonum-precision</td>
     435<td>Number of digits in mantissa base radix of floating point number</td></tr>
     436<tr>
     437<td class="symbol">flonum-decimal-precision</td>
     438<td>Number of digits in mantissa base 10 of floating point number</td></tr>
     439<tr>
     440<td class="symbol">flonum-maximum-exponent</td>
     441<td>Largest exponent in base radix of floating point number</td></tr>
     442<tr>
     443<td class="symbol">flonum-minimum-exponent</td>
     444<td>Smallest exponent in base radix of floating point number</td></tr>
     445<tr>
     446<td class="symbol">flonum-maximum-decimal-exponent</td>
     447<td>Largest exponent in base 10 of floating point number</td></tr>
     448<tr>
     449<td class="symbol">flonum-minimum-decimal-exponent</td>
     450<td>Smallest exponent in base 10 of floating point number</td></tr></table></div>
     451<div class="subsection">
     452<h4>Math Constants</h4>
     453<div class="section">
     454<h3>Usage</h3>(include &quot;mathh-constants&quot;)</div>
     455<p>Common constants, using 'define-constant'. As such they must be textually included.</p><table class="symbol-table">
     456<tr>
     457<td class="symbol">E</td>
     458<td>e</td></tr>
     459<tr>
     460<td class="symbol">1/E</td>
     461<td>1/e</td></tr>
     462<tr>
     463<td class="symbol">E^2</td>
     464<td>e^2</td></tr>
     465<tr>
     466<td class="symbol">E^PI/4</td>
     467<td>e^(pi/4)</td></tr>
     468<tr>
     469<td class="symbol">LOG2E</td>
     470<td>log2(e)</td></tr>
     471<tr>
     472<td class="symbol">LOG10E</td>
     473<td>log10(e)</td></tr>
     474<tr>
     475<td class="symbol">LN2</td>
     476<td>log(2)</td></tr>
     477<tr>
     478<td class="symbol">LN3</td>
     479<td>ln(3)</td></tr>
     480<tr>
     481<td class="symbol">LNPI</td>
     482<td>ln(pi)</td></tr>
     483<tr>
     484<td class="symbol">LN10</td>
     485<td>log(10)</td></tr>
     486<tr>
     487<td class="symbol">1/LN2</td>
     488<td>1/ln(2)</td></tr>
     489<tr>
     490<td class="symbol">1/LN10</td>
     491<td>1/ln(10)</td></tr>
     492<tr>
     493<td class="symbol">PI</td>
     494<td>pi</td></tr>
     495<tr>
     496<td class="symbol">PI/2</td>
     497<td>pi/2</td></tr>
     498<tr>
     499<td class="symbol">PI/4</td>
     500<td>pi/4</td></tr>
     501<tr>
     502<td class="symbol">1/PI</td>
     503<td>1/pi</td></tr>
     504<tr>
     505<td class="symbol">2/PI</td>
     506<td>2/pi</td></tr>
     507<tr>
     508<td class="symbol">2/SQRTPI</td>
     509<td>2/sqrt(pi)</td></tr>
     510<tr>
     511<td class="symbol">SQRTPI</td>
     512<td>sqrt(pi)</td></tr>
     513<tr>
     514<td class="symbol">PI^2</td>
     515<td>pi^2</td></tr>
     516<tr>
     517<td class="symbol">DEGREE</td>
     518<td>pi/180</td></tr>
     519<tr>
     520<td class="symbol">SQRT2</td>
     521<td>sqrt(2)</td></tr>
     522<tr>
     523<td class="symbol">1/SQRT2</td>
     524<td>1/sqrt(2)</td></tr>
     525<tr>
     526<td class="symbol">SQRT3</td>
     527<td>sqrt(3)</td></tr>
     528<tr>
     529<td class="symbol">SQRT5</td>
     530<td>sqrt(5)</td></tr>
     531<tr>
     532<td class="symbol">SQRT10</td>
     533<td>sqrt(10)</td></tr>
     534<tr>
     535<td class="symbol">CUBERT2</td>
     536<td>cubert(2)</td></tr>
     537<tr>
     538<td class="symbol">CUBERT3</td>
     539<td>cubert(3)</td></tr>
     540<tr>
     541<td class="symbol">4THRT2</td>
     542<td>fourthrt(2)</td></tr>
     543<tr>
     544<td class="symbol">GAMMA1/2</td>
     545<td>gamma(1/2)</td></tr>
     546<tr>
     547<td class="symbol">GAMMA1/3</td>
     548<td>gamma(1/3)</td></tr>
     549<tr>
     550<td class="symbol">GAMMA2/3</td>
     551<td>gamma(2/3)</td></tr>
     552<tr>
     553<td class="symbol">PHI</td>
     554<td>phi</td></tr>
     555<tr>
     556<td class="symbol">LNPHI</td>
     557<td>ln(phi)</td></tr>
     558<tr>
     559<td class="symbol">1/LNPHI</td>
     560<td>1/ln(phi)</td></tr>
     561<tr>
     562<td class="symbol">EULER</td>
     563<td>euler</td></tr>
     564<tr>
     565<td class="symbol">E^EULER</td>
     566<td>e^euler</td></tr>
     567<tr>
     568<td class="symbol">SIN1</td>
     569<td>sin(1)</td></tr>
     570<tr>
     571<td class="symbol">COS1</td>
     572<td>cos(1)</td></tr>
     573<tr>
     574<td class="symbol">ZETA3</td>
     575<td>theta(3)</td></tr></table></div></div>
    157576<div class="section">
    158577<h3>Version</h3>
    159578<ul>
     579<li>1.10 Cygwin compile fix. Removed &quot;count-set-bits&quot; &amp; &quot;count-unset-bits&quot;. [Kon Lovett]</li>
    160580<li>1.903 Added C int &amp; float types. [Kon Lovett]</li>
    161581<li>1.9.2 Added log1p (approx.) for Windows, scalbn. Native log2 for linux/macosx/bsd. [Kon Lovett]</li>
     
    172592<li>1.0 Initial release</li></ul></div>
    173593<div class="section">
    174 <h3>Usage</h3><tt>(require-extension mathh)</tt></div>
    175 <div class="section">
    176 <h3>Download</h3><a href="mathh.egg">mathh.egg</a></div>
    177 <div class="section">
    178 <h3>Documentation</h3>
    179 <div class="subsection">
    180 <h4>Floating-point Functions</h4>
    181 <p>The following procedures are provided, with their usual meaning.</p>
    182 <p>Windows does not provide native implementations of log1p, lgamma, tgamma. However log1p is approximated.</p>
    183 <p>The Bessel functions are prefixed by 'bessel-' to distinguish the names from common variables.</p>
    184 <dt class="definition"><strong>procedure:</strong> (bessel-j0 N)</dt>
    185 <dd></dd>
    186 <dt class="definition"><strong>procedure:</strong> (bessel-j1 N)</dt>
    187 <dd></dd>
    188 <dt class="definition"><strong>procedure:</strong> (bessel-jn O N)</dt>
    189 <dd></dd>
    190 <dt class="definition"><strong>procedure:</strong> (bessel-y0 N)</dt>
    191 <dd></dd>
    192 <dt class="definition"><strong>procedure:</strong> (bessel-y1 N)</dt>
    193 <dd></dd>
    194 <dt class="definition"><strong>procedure:</strong> (bessel-yn O N)</dt>
    195 <dd></dd>
    196 <dt class="definition"><strong>procedure:</strong> (cosh N)</dt>
    197 <dd></dd>
    198 <dt class="definition"><strong>procedure:</strong> (sinh N)</dt>
    199 <dd></dd>
    200 <dt class="definition"><strong>procedure:</strong> (tanh N)</dt>
    201 <dd></dd>
    202 <dt class="definition"><strong>procedure:</strong> (hypot N1 N2)</dt>
    203 <dd></dd>
    204 <dt class="definition"><strong>procedure:</strong> (gamma N)</dt>
    205 <dd></dd>
    206 <dt class="definition"><strong>procedure:</strong> (lgamma N)</dt>
    207 <dd></dd>
    208 <dt class="definition"><strong>procedure:</strong> (log10 N)</dt>
    209 <dd></dd>
    210 <dt class="definition"><strong>procedure:</strong> (log2 N)</dt>
    211 <dd></dd>
    212 <dt class="definition"><strong>procedure:</strong> (log1p N)</dt>
    213 <dd></dd>
    214 <dt class="definition"><strong>procedure:</strong> (make-log/base BASE)</dt>
    215 <dd>
    216 <p>Returns a procedure of one argument, the logarithm function for <tt>BASE</tt>.</p></dd>
    217 <dt class="definition"><strong>procedure:</strong> (ldexp N)</dt>
    218 <dd></dd>
    219 <dt class="definition"><strong>procedure:</strong> (scalbn N)</dt>
    220 <dd></dd>
    221 <dt class="definition"><strong>procedure:</strong> (fpmod N M)</dt>
    222 <dd>
    223 <p>Returns the modulus of <tt>N</tt> for <tt>M</tt>.</p></dd>
    224 <dt class="definition"><strong>procedure:</strong> (modf N)</dt>
    225 <dd>
    226 <p>Returns two values, the integral and fractional part of <tt>N</tt>.</p></dd>
    227 <dt class="definition"><strong>procedure:</strong> (frexp N)</dt>
    228 <dd>
    229 <p>Returns two values, the fraction and the exponent part of <tt>N</tt>.</p></dd></div>
    230 <div class="subsection">
    231 <h4>Float Classification</h4>
    232 <div class="section">
    233 <h3>Usage</h3>(require-extension matth-fpclass)</div>
    234 <dt class="definition"><strong>procedure:</strong> (fpclassify N)</dt>
    235 <dd>
    236 <p>Returns a symbol denoting the kind of floating-point number.</p><table class="symbol-table">Float Class
    237 <tr>
    238 <td class="symbol">infinite</td>
    239 <td></td></tr>
    240 <tr>
    241 <td class="symbol">nan</td>
    242 <td></td></tr>
    243 <tr>
    244 <td class="symbol">normal</td>
    245 <td></td></tr>
    246 <tr>
    247 <td class="symbol">subnormal</td>
    248 <td></td></tr>
    249 <tr>
    250 <td class="symbol">zero</td>
    251 <td></td></tr>
    252 <tr>
    253 <td class="symbol">unclassified</td>
    254 <td></td></tr></table></dd>
    255 <dt class="definition"><strong>procedure:</strong> (fpclass N)</dt>
    256 <dd>
    257 <p>Returns a symbol denoting the kind of floating-point number.</p><table class="symbol-table">Float Class
    258 <tr>
    259 <td class="symbol">positive-infinite</td>
    260 <td></td></tr>
    261 <tr>
    262 <td class="symbol">negative-infinite</td>
    263 <td></td></tr>
    264 <tr>
    265 <td class="symbol">quiet-nan</td>
    266 <td></td></tr>
    267 <tr>
    268 <td class="symbol">signaling-nan</td>
    269 <td></td></tr>
    270 <tr>
    271 <td class="symbol">positive-normal</td>
    272 <td></td></tr>
    273 <tr>
    274 <td class="symbol">negative-normal</td>
    275 <td></td></tr>
    276 <tr>
    277 <td class="symbol">positive-subnormal</td>
    278 <td></td></tr>
    279 <tr>
    280 <td class="symbol">negative-subnormal</td>
    281 <td></td></tr>
    282 <tr>
    283 <td class="symbol">positive-zero</td>
    284 <td></td></tr>
    285 <tr>
    286 <td class="symbol">negative-zero</td>
    287 <td></td></tr>
    288 <tr>
    289 <td class="symbol">unclassified</td>
    290 <td></td></tr></table></dd></div>
    291 <div class="subsection">
    292 <h4>Integer Procedures &amp; Constants</h4>
    293 <div class="section">
    294 <h3>Usage</h3>(require-extension matth-int)</div>
    295 <dt class="definition"><strong>procedure:</strong> (fxlog2 N)</dt>
    296 <dd>
    297 <p>Returns the ceiling of log2 of the <tt>N</tt> fixnum.</p></dd>
    298 <dt class="definition"><strong>procedure:</strong> (fx1bits N)</dt>
    299 <dd>
    300 <p>Returns the number of one bits in the <tt>N</tt> fixnum.</p></dd>
    301 <dt class="definition"><strong>procedure:</strong> (fx0bits N)</dt>
    302 <dd>
    303 <p>Returns the number of zero bits in the <tt>N</tt> fixnum.</p></dd>
    304 <dt class="definition"><strong>procedure:</strong> (integer-log-base2 N)</dt>
    305 <dd>
    306 <p>Returns the ceiling of log2 of the <tt>N</tt> fixnum or integer flonum.</p></dd>
    307 <dt class="definition"><strong>procedure:</strong> (count-set-bits N)</dt>
    308 <dd>
    309 <p>Returns the number of one bits in the <tt>N</tt> fixnum or integer flonum.</p></dd>
    310 <dt class="definition"><strong>procedure:</strong> (count-unset-bits N)</dt>
    311 <dd>
    312 <p>Returns the number of zero bits in the <tt>N</tt> fixnum or integer flonum.</p></dd><table class="symbol-table">
    313 <tr>
    314 <td class="symbol">most-positive-fixnum</td>
    315 <td>Largest positive fixnum</td></tr>
    316 <tr>
    317 <td class="symbol">most-negative-fixnum</td>
    318 <td>Smallest negative fixnum</td></tr>
    319 <tr>
    320 <td class="symbol">fixnum-precision</td>
    321 <td>Number of bits in fixnum</td></tr>
    322 <tr>
    323 <td class="symbol">machine-word-bits</td>
    324 <td>Number of bits in machine word - C_word</td></tr>
    325 <tr>
    326 <td class="symbol">maximum-machine-word</td>
    327 <td>Largest machine word value - C_uword</td></tr>
    328 <tr>
    329 <td class="symbol">most-negative-machine-word</td>
    330 <td>Smallest negative machine word value - C_word</td></tr>
    331 <tr>
    332 <td class="symbol">most-positive-machine-word</td>
    333 <td>Largest positive machine word value - C_word</td></tr>
    334 <tr>
    335 <td class="symbol">unsigned-integer32-size</td>
    336 <td>Sizeof uint32_t</td></tr>
    337 <tr>
    338 <td class="symbol">maximum-unsigned-integer32</td>
    339 <td>Largest value for uint32_t</td></tr>
    340 <tr>
    341 <td class="symbol">unsigned-char-size</td>
    342 <td>Sizeof the C type</td></tr>
    343 <tr>
    344 <td class="symbol">unsigned-short-size</td>
    345 <td>Sizeof the C type</td></tr>
    346 <tr>
    347 <td class="symbol">unsigned-int-size</td>
    348 <td>Sizeof the C type</td></tr>
    349 <tr>
    350 <td class="symbol">unsigned-long-size</td>
    351 <td>Sizeof the C type</td></tr>
    352 <tr>
    353 <td class="symbol">unsigned-long-long-size</td>
    354 <td>Sizeof the C type, 0 when unsupported</td></tr>
    355 <tr>
    356 <td class="symbol">char-size</td>
    357 <td>Sizeof the C type</td></tr>
    358 <tr>
    359 <td class="symbol">short-size</td>
    360 <td>Sizeof the C type</td></tr>
    361 <tr>
    362 <td class="symbol">int-size</td>
    363 <td>Sizeof the C type</td></tr>
    364 <tr>
    365 <td class="symbol">long-long-size</td>
    366 <td>Sizeof the C type, 0 when unsupported</td></tr></table></div>
    367 <div class="subsection">
    368 <h4>Floating-point Procedures &amp; Constants</h4>
    369 <div class="section">
    370 <h3>Usage</h3>(require-extension matth-float)</div><table class="symbol-table">
    371 <tr>
    372 <td class="symbol">float-radix</td>
    373 <td>Representation base of floating point number</td></tr>
    374 <tr>
    375 <td class="symbol">maximum-float</td>
    376 <td>Largest floating point number</td></tr>
    377 <tr>
    378 <td class="symbol">minimum-float</td>
    379 <td>Smallest floating point number</td></tr>
    380 <tr>
    381 <td class="symbol">float-epsilon</td>
    382 <td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
    383 <tr>
    384 <td class="symbol">float-precision</td>
    385 <td>Number of digits in mantissa base radix of floating point number</td></tr>
    386 <tr>
    387 <td class="symbol">float-decimal-precision</td>
    388 <td>Number of digits in mantissa base 10 of floating point number</td></tr>
    389 <tr>
    390 <td class="symbol">float-maximum-exponent</td>
    391 <td>Largest exponent in base radix of floating point number</td></tr>
    392 <tr>
    393 <td class="symbol">float-minimum-exponent</td>
    394 <td>Smallest exponent in base radix of floating point number</td></tr>
    395 <tr>
    396 <td class="symbol">float-maximum-decimal-exponent</td>
    397 <td>Largest exponent in base 10 of floating point number</td></tr>
    398 <tr>
    399 <td class="symbol">float-minimum-decimal-exponent</td>
    400 <td>Smallest exponent in base 10 of floating point number</td></tr>
    401 <tr>
    402 <td class="symbol">maximum-double</td>
    403 <td>Largest floating point number</td></tr>
    404 <tr>
    405 <td class="symbol">minimum-double</td>
    406 <td>Smallest floating point number</td></tr>
    407 <tr>
    408 <td class="symbol">double-epsilon</td>
    409 <td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
    410 <tr>
    411 <td class="symbol">double-precision</td>
    412 <td>Number of digits in mantissa base radix of floating point number</td></tr>
    413 <tr>
    414 <td class="symbol">double-decimal-precision</td>
    415 <td>Number of digits in mantissa base 10 of floating point number</td></tr>
    416 <tr>
    417 <td class="symbol">double-maximum-exponent</td>
    418 <td>Largest exponent in base radix of floating point number</td></tr>
    419 <tr>
    420 <td class="symbol">double-minimum-exponent</td>
    421 <td>Smallest exponent in base radix of floating point number</td></tr>
    422 <tr>
    423 <td class="symbol">double-maximum-decimal-exponent</td>
    424 <td>Largest exponent in base 10 of floating point number</td></tr>
    425 <tr>
    426 <td class="symbol">double-minimum-decimal-exponent</td>
    427 <td>Smallest exponent in base 10 of floating point number</td></tr>
    428 <tr>
    429 <td class="symbol">maximum-long-double</td>
    430 <td>Largest floating point number</td></tr>
    431 <tr>
    432 <td class="symbol">minimum-long-double</td>
    433 <td>Smallest floating point number</td></tr>
    434 <tr>
    435 <td class="symbol">long-double-epsilon</td>
    436 <td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
    437 <tr>
    438 <td class="symbol">long-double-precision</td>
    439 <td>Number of digits in mantissa base radix of floating point number</td></tr>
    440 <tr>
    441 <td class="symbol">long-double-decimal-precision</td>
    442 <td>Number of digits in mantissa base 10 of floating point number</td></tr>
    443 <tr>
    444 <td class="symbol">long-double-maximum-exponent</td>
    445 <td>Largest exponent in base radix of floating point number</td></tr>
    446 <tr>
    447 <td class="symbol">long-double-minimum-exponent</td>
    448 <td>Smallest exponent in base radix of floating point number</td></tr>
    449 <tr>
    450 <td class="symbol">long-double-maximum-decimal-exponent</td>
    451 <td>Largest exponent in base 10 of floating point number</td></tr>
    452 <tr>
    453 <td class="symbol">long-double-minimum-decimal-exponent</td>
    454 <td>Smallest exponent in base 10 of floating point number</td></tr>
    455 <tr>
    456 <td class="symbol">long-double-radix</td>
    457 <td>Representation base of floating point number</td></tr>
    458 <tr>
    459 <td class="symbol">maximum-flonum</td>
    460 <td>Largest floating point number</td></tr>
    461 <tr>
    462 <td class="symbol">minimum-flonum</td>
    463 <td>Smallest floating point number</td></tr>
    464 <tr>
    465 <td class="symbol">flonum-epsilon</td>
    466 <td>The difference between 1.0 and the least value &gt; 1.0 of a floating point number</td></tr>
    467 <tr>
    468 <td class="symbol">flonum-precision</td>
    469 <td>Number of digits in mantissa base radix of floating point number</td></tr>
    470 <tr>
    471 <td class="symbol">flonum-decimal-precision</td>
    472 <td>Number of digits in mantissa base 10 of floating point number</td></tr>
    473 <tr>
    474 <td class="symbol">flonum-maximum-exponent</td>
    475 <td>Largest exponent in base radix of floating point number</td></tr>
    476 <tr>
    477 <td class="symbol">flonum-minimum-exponent</td>
    478 <td>Smallest exponent in base radix of floating point number</td></tr>
    479 <tr>
    480 <td class="symbol">flonum-maximum-decimal-exponent</td>
    481 <td>Largest exponent in base 10 of floating point number</td></tr>
    482 <tr>
    483 <td class="symbol">flonum-minimum-decimal-exponent</td>
    484 <td>Smallest exponent in base 10 of floating point number</td></tr></table></div>
    485 <div class="subsection">
    486 <h4>Constants</h4>
    487 <div class="section">
    488 <h3>Usage</h3>(include &quot;mathh-constants&quot;)</div>
    489 <p>Common constants, using 'define-constant'. As such they must be textually included.</p><table class="symbol-table">
    490 <tr>
    491 <td class="symbol">E</td>
    492 <td>e</td></tr>
    493 <tr>
    494 <td class="symbol">1/E</td>
    495 <td>1/e</td></tr>
    496 <tr>
    497 <td class="symbol">E^2</td>
    498 <td>e^2</td></tr>
    499 <tr>
    500 <td class="symbol">E^PI/4</td>
    501 <td>e^(pi/4)</td></tr>
    502 <tr>
    503 <td class="symbol">LOG2E</td>
    504 <td>log2(e)</td></tr>
    505 <tr>
    506 <td class="symbol">LOG10E</td>
    507 <td>log10(e)</td></tr>
    508 <tr>
    509 <td class="symbol">LN2</td>
    510 <td>log(2)</td></tr>
    511 <tr>
    512 <td class="symbol">LN3</td>
    513 <td>ln(3)</td></tr>
    514 <tr>
    515 <td class="symbol">LNPI</td>
    516 <td>ln(pi)</td></tr>
    517 <tr>
    518 <td class="symbol">LN10</td>
    519 <td>log(10)</td></tr>
    520 <tr>
    521 <td class="symbol">1/LN2</td>
    522 <td>1/ln(2)</td></tr>
    523 <tr>
    524 <td class="symbol">1/LN10</td>
    525 <td>1/ln(10)</td></tr>
    526 <tr>
    527 <td class="symbol">PI</td>
    528 <td>pi</td></tr>
    529 <tr>
    530 <td class="symbol">PI/2</td>
    531 <td>pi/2</td></tr>
    532 <tr>
    533 <td class="symbol">PI/4</td>
    534 <td>pi/4</td></tr>
    535 <tr>
    536 <td class="symbol">1/PI</td>
    537 <td>1/pi</td></tr>
    538 <tr>
    539 <td class="symbol">2/PI</td>
    540 <td>2/pi</td></tr>
    541 <tr>
    542 <td class="symbol">2/SQRTPI</td>
    543 <td>2/sqrt(pi)</td></tr>
    544 <tr>
    545 <td class="symbol">SQRTPI</td>
    546 <td>sqrt(pi)</td></tr>
    547 <tr>
    548 <td class="symbol">PI^2</td>
    549 <td>pi^2</td></tr>
    550 <tr>
    551 <td class="symbol">DEGREE</td>
    552 <td>pi/180</td></tr>
    553 <tr>
    554 <td class="symbol">SQRT2</td>
    555 <td>sqrt(2)</td></tr>
    556 <tr>
    557 <td class="symbol">1/SQRT2</td>
    558 <td>1/sqrt(2)</td></tr>
    559 <tr>
    560 <td class="symbol">SQRT3</td>
    561 <td>sqrt(3)</td></tr>
    562 <tr>
    563 <td class="symbol">SQRT5</td>
    564 <td>sqrt(5)</td></tr>
    565 <tr>
    566 <td class="symbol">SQRT10</td>
    567 <td>sqrt(10)</td></tr>
    568 <tr>
    569 <td class="symbol">CUBERT2</td>
    570 <td>cubert(2)</td></tr>
    571 <tr>
    572 <td class="symbol">CUBERT3</td>
    573 <td>cubert(3)</td></tr>
    574 <tr>
    575 <td class="symbol">4THRT2</td>
    576 <td>fourthrt(2)</td></tr>
    577 <tr>
    578 <td class="symbol">GAMMA1/2</td>
    579 <td>gamma(1/2)</td></tr>
    580 <tr>
    581 <td class="symbol">GAMMA1/3</td>
    582 <td>gamma(1/3)</td></tr>
    583 <tr>
    584 <td class="symbol">GAMMA2/3</td>
    585 <td>gamma(2/3)</td></tr>
    586 <tr>
    587 <td class="symbol">PHI</td>
    588 <td>phi</td></tr>
    589 <tr>
    590 <td class="symbol">LNPHI</td>
    591 <td>ln(phi)</td></tr>
    592 <tr>
    593 <td class="symbol">1/LNPHI</td>
    594 <td>1/ln(phi)</td></tr>
    595 <tr>
    596 <td class="symbol">EULER</td>
    597 <td>euler</td></tr>
    598 <tr>
    599 <td class="symbol">E^EULER</td>
    600 <td>e^euler</td></tr>
    601 <tr>
    602 <td class="symbol">SIN1</td>
    603 <td>sin(1)</td></tr>
    604 <tr>
    605 <td class="symbol">COS1</td>
    606 <td>cos(1)</td></tr>
    607 <tr>
    608 <td class="symbol">ZETA3</td>
    609 <td>theta(3)</td></tr></table></div></div>
    610 <div class="section">
    611594<h3>License</h3>
    612595<pre>This code is in the public domain</pre></div></div>
  • release/3/mathh/trunk/mathh.meta

    r8501 r8510  
    33(
    44 (egg "mathh.egg")
    5  (synopsis "Some ISO C math functions")
     5 (synopsis "Some ISO C math functions and more")
    66 (category math)
    77 (license "Public domain")
    8  (author "John Cowan")
     8 (author "John Cowan and Kon Lovett")
    99 (eggdoc "doc.scm")
    1010 (files
     
    1616        "mathh-float.scm"
    1717        "mathh-fpclass.scm"
     18        "bitwise-extras.scm"
     19        #;
     20        "fixnum-extras.scm"
    1821        "mathh.setup"
    1922        "mathh.html") )
  • release/3/mathh/trunk/mathh.setup

    r8501 r8510  
    11(include "setup-header.scm")
     2
     3(copy-file "mathh-constants.scm" (chicken-home))
     4
     5(install-dynld mathh-int *version* (documentation "mathh.html"))
     6
     7(install-dynld mathh-float *version* (documentation "mathh.html"))
     8
     9(install-dynld+docu mathh *version*)
    210
    311(define has_fpclassify
    412        (try-compile
    5                 "#include <math.h>
    6                 int main (int argc, char *argv[]) { int t = fpclassify (1.0); return (0); }"))
     13#<<END
     14#include <math.h>
     15int
     16main( int argc, char *argv[] )
     17{
     18    int t = fpclassify( 1.0 );
    719
    8 (define has_long_long
    9         (try-compile
    10                 "int main (int argc, char *argv[]) { long long t = 0LL; return (0); }"))
     20    return 0;
     21}
     22END
     23) )
    1124
    12 (if has_long_long
    13   (install-dynld mathh-int "1.903" -feature has-long-long-type (documentation "mathh.html"))
    14   (install-dynld mathh-int "1.903" (documentation "mathh.html")) )
     25(when (or has_fpclassify ##sys#windows-platform)
     26        (install-dynld mathh-fpclass *version* (documentation "mathh.html")))
    1527
    16 (install-dynld mathh-float "1.903" (documentation "mathh.html"))
     28#;
     29(install-dynld fixnum-extras *version* (documentation "mathh.html"))
    1730
    18 (install-dynld+docu mathh "1.903")
    19 
    20 (when (or has_fpclassify (eq? 'windows (software-type)))
    21         (install-dynld mathh-fpclass "1.903" (documentation "mathh.html")))
    22 
    23 (copy-file "mathh-constants.scm" (chicken-home))
     31(install-dynld bitwise-extras *version* (documentation "mathh.html"))
    2432
    2533(install-test "mathh-test.scm")
  • release/3/mathh/trunk/tests/mathh-test.scm

    r8509 r8510  
    11;;;; mathh-test.scm
    22
     3(use srfi-1)
    34(use testbase testbase-output-human)
    45(use mathh mathh-int mathh-float mathh-fpclass)
     6#;
     7(use fixnum-extras)
     8(use bitwise-extras)
     9
    510(include "mathh-constants")
    611
     
    1217;;;
    1318
    14 (define-test mathh-test "Functions"
     19#|
     20
     21(define (logical:ash-4 x)
     22  (if (negative? x)
     23      (+ -1 (quotient (+ 1 x) 16))
     24      (quotient x 16)))
     25
     26(define ilength
     27  (letrec ((intlen (lambda (n tot)
     28                     (case n
     29                       ((0 -1) (+ 0 tot))
     30                       ((1 -2) (+ 1 tot))
     31                       ((2 3 -3 -4) (+ 2 tot))
     32                       ((4 5 6 7 -5 -6 -7 -8) (+ 3 tot))
     33                       (else (intlen (logical:ash-4 n) (+ 4 tot)))))))
     34    (lambda (n) (intlen n 0))))
     35
     36;; log2( n ) for positive n
     37(define (ilog2 n)
     38  (let loop ([v n] [r 0])
     39    (if (= 0 v)
     40        r
     41        (loop (arithmetic-shift v -1) (+ r 1)) ) ) )
     42
     43(define (ilog2-factors n)
     44  (+ -1 (ilength (bitwise-and n (- n)))))
     45
     46;; 2 ^ log2( n ) for positive n
     47(define (ipow2log2 n)
     48  (arithmetic-shift 2 (- (bitwise-last-bit-set n) 1))
     49  #;
     50  (let loop ([r 1])
     51    (if (< r n)
     52        (loop (arithmetic-shift r 1))
     53        r ) ) )
     54|#
     55
     56#|
     57(define-test mathh-iso-c-test "ISO C Functions"
    1558
    1659        (expect-= 1.0 (bessel-j0 0.0))
     
    4992
    5093(define-test mathh-const-test "Constants"
    51         ; Well, some anyway
     94        ; Well, some
    5295        (expect-near SQRT2 (sqrt 2.0))
    5396        (expect-near DEGREE (/ PI 180.0))
     
    5699)
    57100
    58 (define-test mathh-fpclass-test "fpclass"
     101(define-test mathh-fpclass-test "Function fpclass"
    59102        (expect-eq 'negative-infinite (fpclass -inf.0))
    60103        (expect-eq 'signaling-nan (fpclass -nan.0))
     
    64107)
    65108
     109(define-test mathh-fixnum-test "Fixnum Functions"
     110)
     111|#
     112
     113(define-test mathh-bitwise-test "Bitwise Functions"
     114
     115#|
     116  (insist (bitwise-unsigned-bit-count maximum-machine-word) => machine-word-bits)
     117  (insist (bitwise-unsigned-not-bit-count maximum-machine-word) => 0)
     118  (insist (bitwise-unsigned-bit-count #b10111100) => 5)
     119
     120  (insist (bitwise-unsigned-bit-count (bitwise-not maximum-machine-word)) => 0)
     121  (insist (bitwise-unsigned-not-bit-count (bitwise-not maximum-machine-word)) => machine-word-bits)
     122  (insist (bitwise-unsigned-not-bit-count #b10111100) => (- machine-word-bits 5))
     123
     124  (insist (bitwise-unsigned-first-bit-set maximum-machine-word) => 0)
     125
     126  (insist (bitwise-unsigned-last-bit-set maximum-machine-word) => machine-word-bits)
     127|#
     128
     129  (insist (bitwise-if #b100 #b000 #b111) => #b011)
     130  (insist (bitwise-if #b011 #b000 #b100) => #b100)
     131
     132  (insist (bitwise-if-not #b100 #b000 #b111) => #b100)
     133  (insist (bitwise-if-not #b011 #b000 #b100) => #b000)
     134  (insist (bitwise-if-not #b011 #b101 #b010) => #b110)
     135
     136  (insist (bitwise-test? #b0010 #b0111) => #t)
     137  (insist (bitwise-test? #b0001 #b0100) => #f)
     138        (insist (bitwise-test? #b0100 #b1011) => #f)
     139        (insist (bitwise-test? #b0100 #b0111) => #t)
     140
     141        (insist (bitwise-bit-count #b10101010) => 4)
     142        (insist (bitwise-bit-count 0) => 0)
     143        (insist (bitwise-bit-count -2) => 1)
     144
     145        (insist (bitwise-length #b10101010) => 8)
     146        (insist (bitwise-length 0) => 0)
     147        (insist (bitwise-length #b1111) => 4)
     148        (insist (bitwise-length -27) => 5)
     149
     150        (insist (bitwise-bit-set? #b1101 0) => #t)
     151        (insist (bitwise-bit-set? #b1101 1) => #f)
     152        (insist (bitwise-bit-set? #b1101 2) => #t)
     153        (insist (bitwise-bit-set? #b1101 3) => #t)
     154        (insist (bitwise-bit-set? #b1101 4) => #f)
     155
     156  (insist (bitwise-last-bit-set 0) => 0)
     157  (insist (bitwise-last-bit-set #b10111100) => 8)
     158  (insist (bitwise-last-bit-set -1) => machine-word-bits)
     159
     160        (insist (bitwise-first-bit-set 0) => -1)
     161        (insist (bitwise-first-bit-set -1) => 0)
     162        (insist (bitwise-first-bit-set 1) => 0)
     163        (insist (bitwise-first-bit-set -2) => 1)
     164        (insist (bitwise-first-bit-set 2) => 1)
     165        (insist (bitwise-first-bit-set -3) => 0)
     166        (insist (bitwise-first-bit-set 3) => 0)
     167        (insist (bitwise-first-bit-set -4) => 2)
     168        (insist (bitwise-first-bit-set 4) => 2)
     169        (insist (bitwise-first-bit-set -5) => 0)
     170        (insist (bitwise-first-bit-set 5) => 0)
     171        (insist (bitwise-first-bit-set -6) => 1)
     172        (insist (bitwise-first-bit-set 6) => 1)
     173        (insist (bitwise-first-bit-set -7) => 0)
     174        (insist (bitwise-first-bit-set 7) => 0)
     175        (insist (bitwise-first-bit-set -8) => 3)
     176        (insist (bitwise-first-bit-set 8) => 3)
     177        (insist (bitwise-first-bit-set -9) => 0)
     178        (insist (bitwise-first-bit-set 9) => 0)
     179        (insist (bitwise-first-bit-set -10) => 1)
     180        (insist (bitwise-first-bit-set 10) => 1)
     181        (insist (bitwise-first-bit-set -11) => 0)
     182        (insist (bitwise-first-bit-set 11) => 0)
     183        (insist (bitwise-first-bit-set -12) => 2)
     184        (insist (bitwise-first-bit-set 12) => 2)
     185        (insist (bitwise-first-bit-set -13) => 0)
     186        (insist (bitwise-first-bit-set 13) => 0)
     187        (insist (bitwise-first-bit-set -14) => 1)
     188        (insist (bitwise-first-bit-set 14) => 1)
     189        (insist (bitwise-first-bit-set -15) => 0)
     190        (insist (bitwise-first-bit-set 15) => 0)
     191        (insist (bitwise-first-bit-set -16) => 4)
     192        (insist (bitwise-first-bit-set 16) => 4)
     193
     194        (insist (bitwise-copy-bit 0 0 1) => #b1)
     195        (insist (bitwise-copy-bit 0 2 1) => #b100)
     196        (insist (bitwise-copy-bit #b1111 2 0) => #b1011)
     197
     198        (insist (bitwise-copy-bit 0 0 #t) => #b1)
     199        (insist (bitwise-copy-bit 0 2 #t) => #b100)
     200        (insist (bitwise-copy-bit #b1111 2 #f) => #b1011)
     201
     202        (insist (bitwise-bit-field #b1101101010 0 4) => #b1010)
     203        (insist (bitwise-bit-field #b1101101010 4 9) => #b10110)
     204
     205        (insist (bitwise-copy-bit-field #b1101101010 0 4 0) => #b1101100000)
     206        (insist (bitwise-copy-bit-field #b1101101010 0 4 -1) => #b1101101111)
     207        (insist (bitwise-copy-bit-field #b110100100010000 5 9 -1) => #b110100111110000)
     208
     209        (insist (bitwise-rotate-bit-field #b0100 0 4 3)  => #b10)
     210        (insist (bitwise-rotate-bit-field #b0100 0 4 -1) => #b10)
     211        (insist (bitwise-rotate-bit-field #b110100100010000 5 9 -1) => #b110100010010000)
     212        (insist (bitwise-rotate-bit-field #b110100100010000 5 9 1)  => #b110100000110000)
     213
     214        (insist (bitwise-reverse-bit-field #b10100111 0 8) => #b11100101)
     215        (insist (bitwise-reverse-bit-field #b1010010 1 4) => #b1011000)
     216
     217        (insist (bitwise-list->integer '()) => 0)
     218        (insist (bitwise-list->integer '(#t #f #t)) => #b101)
     219
     220        (insist (bitwise-integer->list #b0 0) => '())
     221        (insist (bitwise-integer->list #b0) => (make-list machine-word-bits #f))
     222        (insist (bitwise-integer->list #b101) => '(#t #f #t))
     223        (insist (bitwise-integer->list #b11101 4) => '(#t #t #f #t))
     224)
     225
    66226;;;
    67227
     
    69229(test::for-each (cut test::styler-set! <> test::output-style-human))
    70230(run-test "Mathh Tests")
     231
     232(test::forget!)
Note: See TracChangeset for help on using the changeset viewer.