Commit Graph

20 Commits

Author SHA1 Message Date
Neil Toronto
8d5a069d41 Moar `math/matrix' review/refactoring
* Split "matrix-constructors.rkt" into three parts:
 * "matrix-constructors.rkt"
 * "matrix-conversion.rkt"
 * "matrix-syntax.rkt"

* Made `matrix-map' automatically inline (it's dirt simple)

* Renamed a few things, changed some type signatures

* Fixed error in `matrix-dot' caught by testing (it was broadcasting)

* Rewrote matrix comprehensions in terms of array comprehensions

* Removed `in-column' and `in-row' (can use `in-array', `matrix-col' and
  `matrix-row')

* Tons of new rackunit tests: only "matrix-2d.rkt" and
  "matrix-operations.rkt" are left (though the latter is large)
2012-12-20 17:32:16 -07:00
Neil Toronto
155ec7dc41 Reviewing and refactoring `math/matrix', part 1
* Finally added `array-axis-expand' as a dual for `array-axis-reduce'
  in order to implement `vandermonde-matrix' elegantly

* Better, shorter matrix multiply; reworked all matrix arithmetic

* Split "matrix-operations.rkt" into at least 5 parts:
 * "matrix-operations.rkt"
 * "matrix-basic.rkt"
 * "matrix-comprehension.rkt"
 * "matrix-sequences.rkt"
 * "matrix-column.rkt"

Added "matrix-constructors.rkt"

Added `matrix', `row-matrix', and `col-matrix' macros

A lot of other little changes

Currently, `in-row' and `in-column' are broken. I intend to implement
them in a way that makes them work in untyped and Typed Racket.
2012-12-20 17:32:16 -07:00
Neil Toronto
b8efd58aca Array changes in response to user feedback (and my personal neuroses)
* `list->array' now accepts an optional shape argument, and always returns
  an immutable array

* `vector->array' now accepts an optional shape argument, and always
  returns a mutable array

* Removed `make-mutable-array' because `vector->array' does its job now (I
  never liked the name anyway)

* Renamed `unsafe-mutable-array' to `unsafe-vector->array'

* Added optional type annotation to `array' macro to match `mutable-array'

* Reworded error messages in array broadcasting functions

* Made minor array doc fixes
2012-12-17 15:54:29 -07:00
Neil Toronto
60dd8d065f Fixes for errors Pierpaolo Bernardi found by reviewing the docs; also,
renamed `partition-count' to `partitions' to be consistent with
`permutations', and gave better examples in `multinomial' docs

 * (flulp-error +inf.0 +nan.0) was returning +nan.0 instead of +inf.0

 * Type of `multinomial' didn't match its docs or `flmultinomial'

 * Reworded docs for `diagonal-array'

 * Reworked/reordered quite a few things in docs for `math/bigfloat'

 * Fixed first identity given in `gamma-inc' docs

 * Fixed descrption for `+max.0', etc.
2012-12-17 11:40:37 -07:00
Matthew Flatt
5d57f6e497 ffi/unsafe/custodian: fix weak-reference problem
Also fix a related problem in the `math' MPFR binding (which was
masked by the `ffi/unsafe/custodian' bug).
2012-12-11 09:30:15 -07:00
Neil Toronto
9865182df4 Fixes, docs, and API changes for `math/statistics'
* Fixed and added tests for `quantile' and `median', documented them

* Added `sort-samples', documented it

* Removed `real-quantile' and `real-median' (too many design choices
  right now; will revisit when implementing Kernel Density Estimators)

* Documented `absdev' and `absdev/median'

* Fixed `update-statistics*': now uses O(1) space as advertised (if the
  sequences of values and weights both use O(1) space)

* Changed types of binning functions: allows using #:key in the future
  (when TR supports function type cases that differ only by keyword
  argument types better), places optional weights at the end like other
  statistics functions

* Clarified binning docs about sort stability and half-open intervals
2012-12-10 16:45:18 -07:00
Neil Toronto
04fbb02f63 Changed argument order of binning functions for consistency with other
math/statistics functions
2012-12-08 22:50:13 -07:00
Neil Toronto
73395eed94 Finished and documented counting and binning functions in `math/statistics' 2012-12-08 22:11:41 -07:00
Neil Toronto
769e8b47ec Added `array->list-array'
Cleaned up expected value code a little

Refactored running statistics objects (hid private fields, added
`update-statistics*')

Documented expected value functions and running statistics

Removed `bfpsi0' from bigfloat tests (DrDr's libmpfr doesn't have it)

Commented out custodian shutdown callback that frees MPFR's cache
(something's broken)
2012-12-06 22:52:22 -07:00
Neil Toronto
6e02d12beb Reimplemented `mpfr_set_z_2exp' in Racket as a fallback for older versions
of libmpfr (like DrDr's) that don't have it

Reimplemented really simple FFI functions (e.g. mpfr-prec, mpfr-exp) to
avoid calling overhead

Renamed `bigfloat-sign' to `bigfloat-signbit'

Renamed `bigfloat-sig+exp' to `bigfloat->sig+exp' (for symmetry with
`sig+exp->bigfloat')
2012-12-06 13:43:23 -07:00
Neil Toronto
6ca52be0ae Stopped exporting `slice-indexes-array' 2012-12-03 22:45:31 -07:00
Neil Toronto
d935bc0643 Split "mpfr.rkt" into "gmp.rkt" and "mpfr.rkt"
Fixed bigfloat functions that assumed (fixnum? x) means x fits in a _long
(not true on Win64)

Hopefully fixed dangling pointer errors that broke `math/bigfloat' on Win64.
It apparently had no _long/_int mismatches, but GC on Win64 will run between
creating an `_mpz' and using its value after passing it as an output argument
to MPFR functions. That doesn't seem to happen on 64-bit Linux or Mac. No
idea why, but Win64 exposed the problem so... that's good, I guess.

Rewrote `rational->bigfloat' to not use GMP's rationals

More/better bigfloat tests

Added bigfloat stress test w/ weak leak detection

Reenabled custodian shutdown callback that clears MPFR constants, because it
seems to work now

Removed `mpfr-available?' because it would only return non-#f
2012-12-03 22:45:31 -07:00
Neil Toronto
8f17913d55 Fixed memory leak in making arrays strict: doing so wouldn't clear
the reference to the original procedure, which itself could hold on
to a lot of memory
2012-12-02 22:21:28 -07:00
Neil Toronto
e4f5a0598f Changed how array strictness works: `array-strict' now makes the
original array strict instead of returning a new strict array.
(Finally!) The hard part is keeping the Array type covariant. The
solution is to keep the store in the closure of the array's
procedure instead of in the Array struct itself.
2012-11-29 22:17:06 -09:00
Neil Toronto
0182a6c491 Worked around new typed/rackunit limitations in "array-tests.rkt" and
"mandelbrot-test.rkt"

Fixed error in `array-count' revealed by correctly failing test

Simplified Mandelbrot test
2012-11-29 15:45:17 -07:00
Neil Toronto
96d1400654 Renamed functions
* bernoulli -> bernoulli-number
 * farey -> farey-sequence
 * fibonacci/mod -> modular-fibonacci
 * order -> unit-group-order
 * orders -> unit-group-orders

Documented `make-fibonacci' and `make-modular-fibonacci'

Reworked text about loading external libraries in docs for `math/bigfloat'

Removed type aliases like Z, Q, Prime (I like them, but TR was printing them
in unexpected places like array return types)
2012-11-27 22:23:42 -07:00
Neil Toronto
3670916a11 Initial commit for `math/array' documentation; about 65% finished
Replaced pointwise operators with macros that expand to applications of `array-map'; allows more precise return types and reduces compilation time

Changed literal array syntax to use #() to delimit rows instead of [] (still suggest using square parens, though)

Minor refactoring

Fixed a macro so that the only problem with "array-tests.rkt" now is that typed/rackunit is b0rked
2012-11-24 22:13:24 -07:00
Jens Axel Søgaard
50c03c3622 Renamed polygonal functions to include -number the name. 2012-11-23 16:09:28 +01:00
Jens Axel Søgaard
bbef490fb0 Fixed missing import for curry 2012-11-17 21:02:36 -09:00
Neil Toronto
f2dc2027f6 Initial math library commit. The history for these changes is preserved
in the original GitHub fork:

  https://github.com/ntoronto/racket

Some things about this are known to be broken (most egregious is that the
array tests DO NOT RUN because of a problem in typed/rackunit), about half
has no coverage in the tests, and half has no documentation. Fixes and
docs are coming. This is committed now to allow others to find errors and
inconsistency in the things that appear to be working, and to give the
author a (rather incomplete) sense of closure.
2012-11-16 11:39:51 -07:00