Introduce homogeneous coordinates

This commit is contained in:
Kiana Sheibani 2022-06-15 00:33:19 -04:00
parent acd0cb6aa5
commit 4b293d7e2a
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
5 changed files with 69 additions and 0 deletions

View file

@ -19,6 +19,10 @@ export
dimEq : (v : Vector n a) -> n = dim v
dimEq v = cong head $ shapeEq v
export
withDim : {0 n' : Nat} -> Vector n' a -> ((n : Nat) -> Vector n a -> b) -> b
withDim v f = f (dim v) (rewrite sym (dimEq v) in v)
--------------------------------------------------------------------------------
-- Vector constructors
--------------------------------------------------------------------------------
@ -31,6 +35,11 @@ vector v = rewrite sym (lengthCorrect v)
rewrite lengthCorrect v in -- there is only 1 axis
rewrite multOneLeftNeutral n in v
export
toVect : Vector n a -> Vect n a
toVect v = believe_me $ Vect.fromList $ toList v
export
basis : Num a => {n : _} -> (i : Fin n) -> Vector n a
basis i = fromFunction _ (\[j] => if i == j then 1 else 0)