Remove believe_me calls blocking evaluation
This commit is contained in:
parent
76e4137d37
commit
963f27384f
|
@ -2,6 +2,7 @@ module Data.NumIdr
|
||||||
|
|
||||||
import public Data.Permutation
|
import public Data.Permutation
|
||||||
|
|
||||||
|
import Data.NumIdr.PrimArray
|
||||||
import public Data.NumIdr.Interfaces
|
import public Data.NumIdr.Interfaces
|
||||||
import public Data.NumIdr.Array
|
import public Data.NumIdr.Array
|
||||||
import public Data.NumIdr.Scalar
|
import public Data.NumIdr.Scalar
|
||||||
|
|
|
@ -168,7 +168,8 @@ diagonal {n} mat with (viewShape mat)
|
||||||
export
|
export
|
||||||
-- TODO: throw an actual proof in here to avoid the unsafety
|
-- TODO: throw an actual proof in here to avoid the unsafety
|
||||||
minor : Fin (S m) -> Fin (S n) -> Matrix (S m) (S n) a -> Matrix m n a
|
minor : Fin (S m) -> Fin (S n) -> Matrix (S m) (S n) a -> Matrix m n a
|
||||||
minor i j mat = believe_me $ mat!!..[Filter (/=i), Filter (/=j)]
|
minor i j mat = replace {p = flip Array a} (believe_me $ Refl {x = ()})
|
||||||
|
$ mat!!..[Filter (/=i), Filter (/=j)]
|
||||||
|
|
||||||
|
|
||||||
filterInd : Num a => (Nat -> Nat -> Bool) -> Matrix m n a -> Matrix m n a
|
filterInd : Num a => (Nat -> Nat -> Bool) -> Matrix m n a -> Matrix m n a
|
||||||
|
@ -568,7 +569,7 @@ solveLowerTri' {n} mat b with (viewShape b)
|
||||||
construct {i=S i} (b :: bs) =
|
construct {i=S i} (b :: bs) =
|
||||||
let xs = construct bs
|
let xs = construct bs
|
||||||
i' = assert_total $ case natToFin i n of Just i' => i'
|
i' = assert_total $ case natToFin i n of Just i' => i'
|
||||||
in (b - sum (zipWith (*) xs (reverse $ toVect $ believe_me $
|
in (b - sum (zipWith (*) xs (reverse $ toVect $ replace {p = flip Array a} (believe_me $ Refl {x=()}) $
|
||||||
mat !!.. [One i', EndBound (weaken i')]))) / mat!#[i,i] :: xs
|
mat !!.. [One i', EndBound (weaken i')]))) / mat!#[i,i] :: xs
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,7 +582,7 @@ solveUpperTri' {n} mat b with (viewShape b)
|
||||||
construct i (b :: bs) =
|
construct i (b :: bs) =
|
||||||
let xs = construct (S i) bs
|
let xs = construct (S i) bs
|
||||||
i' = assert_total $ case natToFin i n of Just i' => i'
|
i' = assert_total $ case natToFin i n of Just i' => i'
|
||||||
in (b - sum (zipWith (*) xs (toVect $ believe_me $
|
in (b - sum (zipWith (*) xs (toVect $ replace {p = flip Array a} (believe_me $ Refl {x=()}) $
|
||||||
mat !!.. [One i', StartBound (FS i')]))) / mat!#[i,i] :: xs
|
mat !!.. [One i', StartBound (FS i')]))) / mat!#[i,i] :: xs
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Data.List
|
||||||
import Data.Vect
|
import Data.Vect
|
||||||
import Data.NumIdr.Array.Rep
|
import Data.NumIdr.Array.Rep
|
||||||
import Data.NumIdr.Array.Coords
|
import Data.NumIdr.Array.Coords
|
||||||
|
import Data.NumIdr.PrimArray.Linked
|
||||||
|
|
||||||
%default total
|
%default total
|
||||||
|
|
||||||
|
@ -21,8 +22,8 @@ export
|
||||||
indexRange : {s : _} -> (rs : CoordsRange s) -> PrimArrayDelayed s a -> PrimArrayDelayed (newShape rs) a
|
indexRange : {s : _} -> (rs : CoordsRange s) -> PrimArrayDelayed s a -> PrimArrayDelayed (newShape rs) a
|
||||||
indexRange [] v = v
|
indexRange [] v = v
|
||||||
indexRange (r :: rs) v with (cRangeToList r)
|
indexRange (r :: rs) v with (cRangeToList r)
|
||||||
_ | Left i = indexRange rs (\is' => v (believe_me i :: is'))
|
_ | Left i = indexRange rs (\is' => v (assertFin i :: is'))
|
||||||
_ | Right is = \(i::is') => indexRange rs (\is'' => v (believe_me (Vect.index i (fromList is)) :: is'')) is'
|
_ | Right is = \(i::is') => indexRange rs (\is'' => v (assertFin (Vect.index i (fromList is)) :: is'')) is'
|
||||||
|
|
||||||
export
|
export
|
||||||
indexSetRange : {s : _} -> (rs : CoordsRange s) -> PrimArrayDelayed (newShape rs) a
|
indexSetRange : {s : _} -> (rs : CoordsRange s) -> PrimArrayDelayed (newShape rs) a
|
||||||
|
|
|
@ -23,19 +23,25 @@ update : Coords s -> (a -> a) -> Vects s a -> Vects s a
|
||||||
update [] f v = f v
|
update [] f v = f v
|
||||||
update (i :: is) f v = updateAt i (update is f) v
|
update (i :: is) f v = updateAt i (update is f) v
|
||||||
|
|
||||||
|
export %unsafe
|
||||||
|
assertFin : Nat -> Fin n
|
||||||
|
assertFin n = natToFinLt n @{believe_me Oh}
|
||||||
|
|
||||||
export
|
export
|
||||||
indexRange : {s : _} -> (rs : CoordsRange s) -> Vects s a -> Vects (newShape rs) a
|
indexRange : {s : _} -> (rs : CoordsRange s) -> Vects s a -> Vects (newShape rs) a
|
||||||
indexRange [] v = v
|
indexRange [] v = v
|
||||||
indexRange (r :: rs) v with (cRangeToList r)
|
indexRange (r :: rs) v with (cRangeToList r)
|
||||||
_ | Left i = indexRange rs (Vect.index (believe_me i) v)
|
_ | Left i = indexRange rs (Vect.index (assertFin i) v)
|
||||||
_ | Right is = believe_me $ map (\i => indexRange rs (Vect.index (believe_me i) v)) is
|
_ | Right is = assert_total $
|
||||||
|
case toVect _ (map (\i => indexRange rs (Vect.index (assertFin i) v)) is) of
|
||||||
|
Just v => v
|
||||||
|
|
||||||
export
|
export
|
||||||
indexSetRange : {s : _} -> (rs : CoordsRange s) -> Vects (newShape rs) a -> Vects s a -> Vects s a
|
indexSetRange : {s : _} -> (rs : CoordsRange s) -> Vects (newShape rs) a -> Vects s a -> Vects s a
|
||||||
indexSetRange {s=[]} [] rv _ = rv
|
indexSetRange {s=[]} [] rv _ = rv
|
||||||
indexSetRange {s=_::_} (r :: rs) rv v with (cRangeToList r)
|
indexSetRange {s=_::_} (r :: rs) rv v with (cRangeToList r)
|
||||||
_ | Left i = updateAt (believe_me i) (indexSetRange rs rv) v
|
_ | Left i = updateAt (assertFin i) (indexSetRange rs rv) v
|
||||||
_ | Right is = foldl (\v,i => updateAt (believe_me i) (indexSetRange rs (Vect.index (believe_me i) rv)) v) v is
|
_ | Right is = foldl (\v,i => updateAt (assertFin i) (indexSetRange rs (Vect.index (assertFin i) rv)) v) v is
|
||||||
|
|
||||||
|
|
||||||
export
|
export
|
||||||
|
|
|
@ -40,7 +40,8 @@ vector v = rewrite sym (lengthCorrect v)
|
||||||
||| Convert a vector into a `Vect`.
|
||| Convert a vector into a `Vect`.
|
||||||
export
|
export
|
||||||
toVect : Vector n a -> Vect n a
|
toVect : Vector n a -> Vect n a
|
||||||
toVect v = believe_me $ Vect.fromList $ Prelude.toList v
|
toVect v = replace {p = flip Vect a} (believe_me $ Refl {x=()}) $
|
||||||
|
Vect.fromList $ Prelude.toList v
|
||||||
|
|
||||||
||| Return the `i`-th basis vector.
|
||| Return the `i`-th basis vector.
|
||||||
export
|
export
|
||||||
|
|
Loading…
Reference in a new issue