From 226b2ff2ba4d0f0e7c99eb122e3243ea1bdc015f Mon Sep 17 00:00:00 2001 From: Ben Greenman Date: Thu, 3 Dec 2015 00:31:41 -0500 Subject: [PATCH 1/2] #lang mechanics --- lang/main.rkt | 7 +++++++ lang/reader.rkt | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 lang/main.rkt create mode 100644 lang/reader.rkt diff --git a/lang/main.rkt b/lang/main.rkt new file mode 100644 index 0000000..2cde736 --- /dev/null +++ b/lang/main.rkt @@ -0,0 +1,7 @@ +#lang racket/base + +(require mechanics) + +(provide + (all-from-out racket/base) + (all-from-out mechanics)) diff --git a/lang/reader.rkt b/lang/reader.rkt new file mode 100644 index 0000000..1e7a6f6 --- /dev/null +++ b/lang/reader.rkt @@ -0,0 +1,2 @@ +#lang s-exp syntax/module-reader +mechanics/lang/main From 4d46d43010016ef81f971f94df8da9daabcd6eeb Mon Sep 17 00:00:00 2001 From: Ben Greenman Date: Thu, 3 Dec 2015 00:31:50 -0500 Subject: [PATCH 2/2] ** convert to #lang mechanics --- private/kernel/interval.rkt | 3 +-- private/kernel/vector.rkt | 2 +- private/numerics/functions/bessel.rkt | 11 +---------- private/numerics/functions/bessjs.rkt | 4 +--- private/numerics/functions/elliptic-flo.rkt | 6 +----- private/numerics/functions/elliptic.rkt | 13 +++---------- private/numerics/integer/continued-fractions.rkt | 3 +-- private/numerics/integer/farey.rkt | 3 +-- 8 files changed, 10 insertions(+), 35 deletions(-) diff --git a/private/kernel/interval.rkt b/private/kernel/interval.rkt index ac7597c..c3d5d4c 100644 --- a/private/kernel/interval.rkt +++ b/private/kernel/interval.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang mechanics ;; Utilities for working with subsets of the real line. ;; Alternatively, for representing data points that have a tolerance. @@ -11,7 +11,6 @@ ;; (arranged from lowest lo bound upward, all intervals disjoint) (require - mechanics (for-syntax racket/base syntax/parse) (only-in racket/match match-define) ) diff --git a/private/kernel/vector.rkt b/private/kernel/vector.rkt index 685c462..e000999 100644 --- a/private/kernel/vector.rkt +++ b/private/kernel/vector.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang mechanics ;; Vector functions missing from racket & racket/math diff --git a/private/numerics/functions/bessel.rkt b/private/numerics/functions/bessel.rkt index dc76a34..cb9fc4f 100644 --- a/private/numerics/functions/bessel.rkt +++ b/private/numerics/functions/bessel.rkt @@ -1,7 +1,6 @@ -#lang racket/base +#lang mechanics ;; This module defines the bessel functions of integer order -(require racket/contract/base) (provide (contract-out [bessj₀ (-> number? number?)] @@ -14,14 +13,6 @@ [bessh₁ (-> number? complex?)] [bessh (-> integer? number? complex?)])) -(require - (only-in mechanics - π - π/4 - π/2 - 3π/4 - 2/π)) - (require (only-in math/number-theory factorial)) diff --git a/private/numerics/functions/bessjs.rkt b/private/numerics/functions/bessjs.rkt index 258f5ff..b6dac39 100644 --- a/private/numerics/functions/bessjs.rkt +++ b/private/numerics/functions/bessjs.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang mechanics ;;;; Bessel Functions: @@ -10,7 +10,6 @@ ;;; ( J0(x) ... Jn(x) ) ;;; that is good to machine precision for x < 2 and large n. -(require racket/contract/base) (provide (contract-out [bessjs (-> exact-nonnegative-integer? positive? (listof number?))])) @@ -67,7 +66,6 @@ (module+ test (require rackunit rackunit/text-ui - (only-in mechanics π/2 π 3π/2 2π) math/matrix (only-in racket/vector vector-map) (only-in racket/format ~a) diff --git a/private/numerics/functions/elliptic-flo.rkt b/private/numerics/functions/elliptic-flo.rkt index c1e47ce..1ad387d 100644 --- a/private/numerics/functions/elliptic-flo.rkt +++ b/private/numerics/functions/elliptic-flo.rkt @@ -1,6 +1,4 @@ -#lang racket/base - -(require racket/contract/base) +#lang mechanics (provide (contract-out @@ -21,8 +19,6 @@ fl* fl-)) -(require (only-in mechanics π π/2 *machine-ε*)) - (define (first-elliptic-integral k) (let loop ([a 1.0] [b (flsqrt (fl- 1.0 diff --git a/private/numerics/functions/elliptic.rkt b/private/numerics/functions/elliptic.rkt index 785719c..37c65e5 100644 --- a/private/numerics/functions/elliptic.rkt +++ b/private/numerics/functions/elliptic.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang mechanics ;; Consult "Numerical Computation of Real or Complex Elliptic ;; Integrals" Carlson (1994) http://arxiv.org/pdf/math/9409227v1.pdf @@ -8,7 +8,6 @@ ;; ;; Consider also exporting under the more familiar names Rf, Rj, Rc, ;; Rd. Is there any input method that gets those names as subscripts. -(require racket/contract/base) (provide (contract-out ;; Carlson elliptic integrals R_F @@ -72,12 +71,7 @@ number?)) (require - (only-in mechanics π π/2 square *machine-ε*)) - -(require - (only-in racket/math cosh tanh)) - -(require + (only-in racket/math cosh tanh) (only-in racket/fixnum fx< fx+)) (define (Rf x y z) @@ -307,8 +301,7 @@ (module+ test (require rackunit - rackunit/text-ui - (only-in mechanics π/2)) + rackunit/text-ui) (define test-suite-ε 1e-7) (run-tests diff --git a/private/numerics/integer/continued-fractions.rkt b/private/numerics/integer/continued-fractions.rkt index 0bb7f7b..8eda812 100644 --- a/private/numerics/integer/continued-fractions.rkt +++ b/private/numerics/integer/continued-fractions.rkt @@ -1,9 +1,8 @@ -#lang racket/base +#lang mechanics ;; Continued Fractions stream approximations of real numbers. ;; http://en.wikipedia.org/wiki/Continued_fraction -(require mechanics) (provide/api continued-fraction #:contract (-> real? (sequenceof integer?)) diff --git a/private/numerics/integer/farey.rkt b/private/numerics/integer/farey.rkt index 01a7743..f6a6e54 100644 --- a/private/numerics/integer/farey.rkt +++ b/private/numerics/integer/farey.rkt @@ -1,4 +1,4 @@ -#lang racket/base +#lang mechanics ;; Farey Trees (aka Stern-Brocot Trees) ;; http://mathworld.wolfram.com/FareySequence.html @@ -10,7 +10,6 @@ ;; Because the mediants are always between the given fractions ;; the levels are ordered if the first one is ordered. -(require mechanics) (provide/api farey #:contract (-> natural? natural? (-> natural? (listof exact-rational?)))