
* 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.
40 lines
1.2 KiB
Racket
40 lines
1.2 KiB
Racket
#lang racket/base
|
|
|
|
(require (for-syntax racket/base)
|
|
typed/untyped-utils
|
|
(prefix-in typed: "typed-matrix-arithmetic.rkt")
|
|
(rename-in "untyped-matrix-arithmetic.rkt"
|
|
[matrix-map untyped:matrix-map]))
|
|
|
|
(define-typed/untyped-identifier matrix-map
|
|
typed:matrix-map untyped:matrix-map)
|
|
|
|
(define-syntax (define/inline-macro stx)
|
|
(syntax-case stx ()
|
|
[(_ name pat inline-fun typed:fun)
|
|
(syntax/loc stx
|
|
(define-syntax (name inner-stx)
|
|
(syntax-case inner-stx ()
|
|
[(_ . pat) (syntax/loc inner-stx (inline-fun . pat))]
|
|
[(_ . es) (syntax/loc inner-stx (typed:fun . es))]
|
|
[_ (syntax/loc inner-stx typed:fun)])))]))
|
|
|
|
(define/inline-macro matrix* (a . as) inline-matrix* typed:matrix*)
|
|
(define/inline-macro matrix+ (a . as) inline-matrix+ typed:matrix+)
|
|
(define/inline-macro matrix- (a . as) inline-matrix- typed:matrix-)
|
|
(define/inline-macro matrix-scale (a x) inline-matrix-scale typed:matrix-scale)
|
|
|
|
(provide
|
|
;; Equality
|
|
(rename-out [typed:matrix= matrix=])
|
|
;; Mapping
|
|
inline-matrix-map
|
|
matrix-map
|
|
;; Multiplication
|
|
matrix*
|
|
;; Pointwise operators
|
|
matrix+
|
|
matrix-
|
|
matrix-scale
|
|
(rename-out [typed:matrix-sum matrix-sum]))
|