-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
Should there be a lens constructor for matrices as functions from column-vectors to column-vectors?
For square invertable matrices it could be an isomorphism lens.
(define (matrix-lens/invertable m)
(define m^-1 (matrix-inverse m))
(make-isomorphism-lens
(λ (a) (matrix* m a))
(λ (b*) (matrix* m^-1 b*))))But for non-invertable matrices (including non-square?), the setter function will sometimes have infinitely many results that would be valid.
(define (matrix-lens/noninvertable m)
(make-lens
(λ (a)
;; M*A = B
(matrix* m a))
(λ (a b*)
;; M*A = B
(define b (matrix* m a))
;; M*A' = B'
;; What is A'?
;; There are many solutions if M has no inverse;
;; Which is the best one, which follows the lens laws?
;; The lens laws make the constraint that when B = B', the result should be A.
;; But that only helps in one specific case. What should this do?
(define a->b (matrix- b a))
(define b->b* (matrix- b* b))
(error 'matrix-lens "I don't know what do if it's not an invertable matrix"))))Are there any other constraints having to do with continuous-ness or anything else that would help make a sensible lens out of a non-invertable matrix?