Commit Graph

15 Commits

Author SHA1 Message Date
Neil Toronto
e5eb9751f0 Initial `math/matrix' documentation, and some changes
* At least stubbed out all (or almost all) `math/matrix' exports; many
  have complete documentation (e.g. types, predicates, accessors,
  constructors, for loops, conversion, much of "Comparing Matrices")

* Moved `matrix-zero?' and fixed to use (matrix-error-norm) as its norm

* Added `matrix-basis-cos-angle' (currently a stub; should return smallest
  singular value of a certain matrix multiplication)
2013-01-01 18:19:43 -07:00
Neil Toronto
5981535686 Made Gaussian elimination faster (half the scaled additions) and more
accurate (always produces zeros in the lower half)
2013-01-01 18:19:43 -07:00
Neil Toronto
c29c4056a1 Added back partial pivoting to Gaussian elimination 2013-01-01 12:12:07 -07:00
Neil Toronto
c8e3b45e38 Added QR decomposition tests (mostly a pretty thorough randomized test);
fixed error in `matrix-cols-orthogonal?' revealed by testing
2012-12-31 15:20:25 -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
7ac8e1bbce Slightly more `math/matrix'
* Moved to-do list in "matrix-operations.rkt" to the wiki

* Added more mutating vector ops

* Added "matrix-basis.rkt" (unfinished)
2012-12-27 17:30:04 -07:00
Neil Toronto
fc02d40a66 Faster LU decomposition 2012-12-27 17:30:03 -07:00
Neil Toronto
1aebd171c5 Moar matrix review/refactoring
* Consolidated Gauss and Gauss-Jordan elimination

* Fixed Gaussian elimination to return all indexes for pivotless columns,
  not just those < m

* Consolidated `matrix-row-echelon' and `matrix-reduced-row-echelon'

* Specialized row reduction for determinants; removed option to not do
  partial pivoting (it's never necessary otherwise)

* Added `matrix-invertible?'

* Removed `matrix-solve-many'; now `matrix-solve' solves for multiple
  columns

* Gave `matrix-inverse' and `matrix-solve' optional failure thunk arguments

* Made some functions that return multiple columns return arrays instead
  (i.e. `matrix-column-space')

* Added more tests
2012-12-21 22:59:59 -07:00
Neil Toronto
3bc4c1ffdc More efficient Gaussian elimination using vectors of vectors (non-strict
arrays can't help an inherently sequential algorithm)
2012-12-21 22:59:59 -07:00
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
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
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
Matthew Flatt
9a48e5d1e5 math: avoid import at unnecessary phase
This repair avoids using at compile time external libraries that
are needed at run time.
2012-11-16 14:10:32 -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