Add new utility functions for homogeneous coords

This commit is contained in:
Kiana Sheibani 2022-07-05 18:09:07 -04:00
parent ff50ebfd70
commit 97bd20d722
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 84 additions and 20 deletions

View file

@ -65,7 +65,7 @@ identity : Num a => {n : _} -> Matrix' n a
identity = repeatDiag 1 0
||| Calculate the matrix that scales a vector by the given value.
||| Construct the matrix that scales a vector by the given value.
export
scaling : Num a => {n : _} -> a -> Matrix' n a
scaling x = repeatDiag x 0
@ -104,6 +104,17 @@ getColumn : Fin n -> Matrix m n a -> Vector m a
getColumn c mat = rewrite sym (minusZeroRight m) in indexRange [All, One c] mat
export
diagonal' : Matrix m n a -> Vector (minimum m n) a
diagonal' mat with (viewShape mat)
_ | Shape [m,n] = fromFunctionNB _ (\[i] => indexUnsafe [i,i] mat)
export
diagonal : Matrix' n a -> Vector n a
diagonal mat with (viewShape mat)
_ | Shape [n,n] = fromFunctionNB [n] (\[i] => indexUnsafe [i,i] mat)
--------------------------------------------------------------------------------
-- Operations
--------------------------------------------------------------------------------