;;; .EnTete "Le-Lisp (c) version 15.2" "" "Test de l'arithme'tique ge'ne'rique"
;;; .EnPied "testgenr.ll" "%" " "
;;;
;;; .SuperTitre "Test de l'arithme'tique ge'ne'rique sur R"
;;;
;;;
;;; .Centre "*****************************************************************"
;;; .Centre " Ce fichier est en lecture seule hors du projet ALE de l'INRIA.  "
;;; .Centre " Il est maintenu par ILOG SA, 2 Avenue Gallie'ni, 94250 Gentilly "
;;; .Centre " (c) Le-Lisp est une marque de'pose'e de l'INRIA                 "
;;; .Centre "*****************************************************************"
;;;
;;; .Centre "$Header: testgenr.ll,v 4.1 88/01/13 12:31:40 kuczynsk Rel $"

(unless (>= (version) 15.2)
        (error 'load 'erricf 'testfn))

(unless (featurep 'testcomm)
        (libload testcomm t))

(unless (featurep 'genr)
        (print "Je charge les generiques interpretes")
        (libload genr t))

(testfn ())

    (test-serie "Test de l'arithmetique generique sur R" ())

     12                               12
     12345678910                      12345678910
     00000123                         123
     -123                             -123
     -32768                           -32768
     (- 32768)                        -32768
     (+ -16384 -16384)                -32768
     (+ -16383 -16385)                -32768
     (* 2 -16384)                     -32768
     (quotient -32768 2)              -16384
     2/3           		      2/3
     4/6           		      2/3
     -10/2         	              -5
     (setq a 52/4096)                 13/1024

     (1+ 99999)                       100000
     (1+ 5/7)                         12/7

     (1- 7/2)                         5/2
     (1- 1/2)                         -1/2

     (abs 7/2)                         7/2
     (abs -1/2)                        1/2

     (+ 1 2 1/2)                       7/2
     (+ 1 -1/2 1/3)                    5/6
     (+ 1/3 2/3)                       1
     (+ -3 100000)                     99997
     (+ -3 -100000)                    -100003

     (- -3/2)                          3/2
     (- 3/2)                           -3/2
     (- 1/2 1/3 1)                     -5/6
     (- 5/3 2/3)                       1
     (- 1000000 1)                     999999
     (- 1/100000)                      -1/100000

     (* 12345679 81)                   999999999
     (* 1/2 -1/3 1/4)                  -1/24
     (* 5/3 6/25)                      2/5
     (* 22/7 7/11)                     2
     (* 22/7 7/11 -1/3)                -2/3      

     (/ 1 24)                          1/24
     (/ 5/3 2/3)                       5/2
     (/ 1/3)                           3

     (numberp 2)                       2
     (numberp -4/6)                    -2/3
     (numberp (tcons 'C 2))            ()

     (rationalp 3)                     3
     (rationalp 2.0)                   ()

     (integerp 2)                      2
     (integerp 4/3)                    ()
     (integerp 2.0)                    ()

     (integerp 23)                     23
     (integerp -2)                     -2

     (<?> 2 4/2)                       0
     (<?> 3/2 2/3)                     1
     (<?> 2/3 3/4)                     -1

     (setq a 1234567)                  1234567
     (setq b 123456)                   123456

     (+ (* (quotient a b) b) (modulo a b))                        1234567
     (+ (* (quotient (- a) (- b)) (- b)) (modulo (- a) (- b)))    -1234567
     (+ (* (quotient a (- b)) (- b)) (modulo a (- b)))            1234567
     (+ (* (quotient (- a) (- b)) (- b)) (modulo (- a) (- b)))    -1234567

     (/ 1. 100000)                     1.e-05

     (quotient 7/2 3)                  1
     (modulo 7/2 3)                    1/2
     (quotient 3 2/5)                  7
     (modulo 3 2/5)                    1/5

     (quotient 7/2 -3)                  -1
     (modulo 7/2 -3)                    1/2
     (quotient -3 2/5)                  -8
     (modulo -3 2/5)                    1/5
     (quomod -100000 12342342345)       -1
     

     (quotient 22/7 3)                  1
     (modulo 22/7 3)                    1/7
     (quotient -22/7 3)                 -2
     (modulo -22/7 3)                   20/7
     (quotient 22/7 113/47)             1
     (modulo 22/7 113/47)               243/329
     (+ (* 113/47 (quomod 22/7 113/47)) #:ex:mod)      22/7
     (+ (* -113/47 (quomod 22/7 -113/47)) #:ex:mod)    22/7


     (** 10 10)   		        10000000000
     (** 2/3 10)                        1024/59049
     (** 2/3 0)                         1
     (** 0 2/3)                         0
     (** 1 2/3)                         1

     (** 2 -3)                          1/8
     (** 2 -6)                          1/64

     123456/7                           123456/7
     123456/7                           17636.57142857142857142857
     (truncate 123456/7)                17636
     (truncate -123456/7)               -17636
     (truncate 2/3)                     0
     (truncate -2/3)                    0

     (exp 1/3)                          1.39561242508608952862
     (exp 230.25)                       9915268022112193112773804101189156238276877088319739277383448394081381854101321126361892449463681647.60477040681493387718
     (exp -19)                          .00000000560279643755
     (log .00000000560279643755)        -18.99999999999772748124
     (log 1/3)                          -1.09861228866810969140
     (log 123456)                       11.72364009626540093516
     (atan 1/3)                         .32175055439664219339
     (atan 123456)                      1.57078822674305646460
     (atan -123456)                     -1.57078822674305646460
     (sin 1/3)                          .32719469679615224417
     (sin 123456)                       -.7402834538866575367
     (sin -123456)                      .7402834538866575367
     (asin 1/3)                         .3398369094541219
     (cos 1/3)                          .94495694631473766438
     (cos 123456)                       -.67229488165658451960
     (cos -123456)                      -.67229488165658451960
     (acos 1/3)                         1.230959417340775

     (/= 3 3)                           ()
     (exp 2/3)                          1.94773404105467585662
     (** 8 1/3)                         2.
     (<?> 123456. 123456)               0

     (test-serie "Fin du test" ())

     ()                            ()