Add operator form for unsafe indexing

This commit is contained in:
Kiana Sheibani 2022-08-04 15:13:00 -04:00
parent 1ebf0dcbe9
commit 7916e10aef
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 5 additions and 2 deletions

View file

@ -101,12 +101,12 @@ 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)
_ | Shape [m,n] = fromFunctionNB _ (\[i] => mat!#[i,i])
export
diagonal : Matrix' n a -> Vector n a
diagonal mat with (viewShape mat)
_ | Shape [n,n] = fromFunctionNB [n] (\[i] => indexUnsafe [i,i] mat)
_ | Shape [n,n] = fromFunctionNB [n] (\[i] => mat!#[i,i])
--------------------------------------------------------------------------------