Fix primitive array functions handling empty arrays

This commit is contained in:
Kiana Sheibani 2023-09-26 00:39:47 -04:00
parent b924d960b5
commit c3c14eba04
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 13 additions and 108 deletions

View file

@ -512,9 +512,12 @@ decompLUP : FieldCmp a => (mat : Matrix m n a) -> DecompLUP mat
decompLUP {m,n} mat with (viewShape mat)
decompLUP {m=0,n} mat | Shape [0,n] = MkLUP mat identity 0
decompLUP {m=S m,n=0} mat | Shape [S m,0] = MkLUP mat identity 0
decompLUP {m=S m,n=S n} mat | Shape [S m,S n] =
iterateN (S $ minimum m n) gaussStepSwap (MkLUP mat identity 0)
decompLUP {m=S m,n=S n} mat | Shape [S m,S n] = undelay $
iterateN (S $ minimum m n) gaussStepSwap (MkLUP (convertRep Delayed mat) identity 0)
where
undelay : DecompLUP mat -> DecompLUP mat
undelay (MkLUP mat' p sw) = MkLUP (convertRep _ @{getRepC mat} mat') p sw
maxIndex : (s,a) -> List (s,a) -> (s,a)
maxIndex x [] = x
maxIndex _ [x] = x