Commit Graph

15 Commits

Author SHA1 Message Date
Neil Toronto
986e695bd5 Made arrays strict by default; please merge to release
* Added parameter `array-strictness', default #t

* Added `array-default-strict!' and `array-default-strict', which act
  like the functions without "default" in the name when
  `array-strictness' is #t; otherwise they do nothing

* Lots of small changes to existing array functions, mostly to ensure
  computations are done using nonstrict arrays, but return values are
  strict when `array-strictness' is #t

* Added strictness tests

* Added tests to ensure untyped code can use `math/array'

* Rewrote `array-map' exported to untyped code using untyped Racket

* Rearranged a lot of `math/array' documentation
2013-01-15 13:53:28 -07:00
Neil Toronto
f5fa93572d Moar `math/matrix' review/refactoring
* Gram-Schmidt using vector type

* QR decomposition

* Operator 1-norm and maximum norm; stub for 2-norm and angle between
  subspaces (`matrix-basis-angle')

* `matrix-absolute-error' and `matrix-relative-error'; also predicates
  based on them, such as `matrix-identity?'

* Lots of shuffling code about

* Types that can have contracts, and an exhaustive test to make sure
  every value exported by `math/matrix' has a contract when used in
  untyped code

* Some more tests (still needs some)
2012-12-31 14:17:17 -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
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
6ca52be0ae Stopped exporting `slice-indexes-array' 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
5a43f2c6bc Finished array documentation!
Cleaned up other docs in preparation for alpha-testing announcement

Created `math/utils' module for stuff that doesn't go anywhere else (e.g.
FFT scaling convention, max-math-threads parameters)

Reduced the number of macros that expand to applications of `array-map'

Added `flvector-sum', defined `flsum' in terms of it

Reduced the number of pointwise `flvector', `flarray' and `fcarray' operations

Reworked `inline-build-flvector' and `inline-flvector-map' to be faster and
expand to less code in both typed and untyped Racket

Redefined conversions like `list->flvector' in terms of for loops (can do
it now that TR has working `for/flvector:', etc.)
2012-11-29 15:45:17 -07:00
Neil Toronto
6009eed8d2 Moved flvector functions into math/flonum
Sped up normal distribution sampling procedure (2x for large samples)
2012-11-29 15:45:17 -07:00
Neil Toronto
cd002d5830 Documented `math/array' folds
Refactored many of the fold functions (e.g. `array-axis-andmap' is gone,
replaced by short-cutting `array-axis-and', which is sufficient because the
result of `array-map' is non-strict; added `array-count', `array-all-fold';
removed `array-all=' and friends)

Turned common folds into macros (preserves return types better, speeds up
compilation time)

Exposed a safe variant of `unsafe-array-axis-reduce'
2012-11-29 15:45:17 -07:00
Neil Toronto
9249929c45 Documented array printing, broadcasting, and transformations 2012-11-29 15:45:17 -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
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