Add new utility functions for homogeneous coords
This commit is contained in:
parent
ff50ebfd70
commit
97bd20d722
3 changed files with 84 additions and 20 deletions
|
|
@ -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
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue