7.6 Polymorphic Operations
procedure
(matrix-ref M i j) → A
M : (Matrix A) i : Integer j : Integer
Examples: | |||||||
|
procedure
(matrix-row M i) → (Matrix A)
M : (Matrix A) i : Integer
procedure
(matrix-col M j) → (Matrix A)
M : (Matrix A) j : Integer
Examples: | |||||||
|
procedure
M : (Matrix A) is : (U Slice (Sequenceof Integer)) js : (U Slice (Sequenceof Integer))
Examples: | ||||||
|
procedure
(matrix-diagonal M) → (Array A)
M : (Matrix A)
Example: | ||||
|
procedure
(matrix-upper-triangle M [zero]) → (Matrix A)
M : (Matrix A) zero : A = 0
procedure
(matrix-lower-triangle M [zero]) → (Matrix A)
M : (Matrix A) zero : A = 0
Examples: | |||||||||||||||||||||||||||||||||||||||
|
procedure
(matrix-rows M) → (Listof (Matrix A))
M : (Matrix A)
procedure
(matrix-cols M) → (Listof (Matrix A))
M : (Matrix A)
Examples: | |||||||
|
procedure
(matrix-augment Ms) → (Matrix A)
Ms : (Listof (Matrix A))
procedure
(matrix-stack Ms) → (Matrix A)
Ms : (Listof (Matrix A))
Examples: | |||||||||||||
|
procedure
(matrix-map-rows f M) → (Matrix B)
f : ((Matrix A) -> (Matrix B)) M : (Matrix A) (matrix-map-rows f M fail) → (U F (Matrix B)) f : ((Matrix A) -> (U #f (Matrix B))) M : (Matrix A) fail : (-> F)
Examples: | ||||||||
|
> (define Z (make-matrix 4 4 0))
> Z - : (Array Zero)
(array #[#[0 0 0 0] #[0 0 0 0] #[0 0 0 0] #[0 0 0 0]])
> (matrix-map-rows (λ: ([r : (Matrix Real)]) (matrix-normalize r 2 (λ () #f))) Z (λ () 'FAILURE)) - : (U (Array Real) 'FAILURE)
'FAILURE
procedure
(matrix-map-cols f M) → (Matrix B)
f : ((Matrix A) -> (Matrix B)) M : (Matrix A) (matrix-map-cols f M fail) → (U F (Matrix B)) f : ((Matrix A) -> (U #f (Matrix B))) M : (Matrix A) fail : (-> F)