yG      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~,nat n yields the Int! value of the type-level natural n.   !"#$%&'()*+,  !"#$%&'()*+,  !"#$%&'()*+,  !"#$%&'()*+[,-./0123456789:;<=>?@ABThe length of a vector CDsnoc v a) appends the element a to the end of v. EFHGet the last element, usually significant for some reason (quaternions, # homogenous coordinates, whatever) GHdrop n v strips the first n elements from v. n is a type-level  natural. For example  drop n2 v drops the first two elements. IJtake n v$ constructs a vector from the first n elements of v. n is a ! type-level natural. For example  take n3 v makes a 3-vector of the first  three elements of v. KLAppend two vectors MNNReverse helper function : accumulates the reversed list in its first argument OP Fold a function over a vector. QRSTICombine two vectors using a binary function. The length of the result is 9 the min of the lengths of the arguments. The constraint ZipWith a b c u v  w states that u is a vector of as, v is a vector of bs, w is a  vector of c&s, and the binary function is of type  a -> b -> c. UV;Apply a function over each element in a vector. Constraint  Map a b u v  states that u is a vector of as, v is a vector of bs with the same  length as u, and the function is of type a -> b. WXAll but the first element. YZThe first element. [\.get or set a vector element, known at compile Ctime. Use the Nat types to access vector components. For instance, get n0 gets the x component,  set n2 44 sets the z component to 44. ]^_EBuild a vector from a list, or access vector elements using run-time  indicies, numbered from 0. `HTurn a list into a vector of inferred length. The list must be at least E as long as the vector, but may be longer. Make a mental note of the  distinction between this and  , as you might accidentally use F this when you mean that. Because number literals can be converted to C vectors, and matrices are vectors of vectors, the following works  " fromList [1,2,3,4] :: Mat22 Int & > ((1):.(1):.()):.((2):.(2):.()):.()  even though we meant to do this % matFromList [1,2,3,4] :: Mat22 Int & > ((1):.(2):.()):.((3):.(4):.()):.() a7Get a vector element, which one determined at runtime. b6Set a vector element, which one determined at runtime cThe type constraint  Vec n a v infers the vector type v from the  length n6, a type-level natural, and underlying component type a.  So x :: Vec N4 a v => v declares x to be a 4-vector of as. d)Make a uniform vector of a given length. n is a type-level natural.  Use {" when the length can be inferred. efghijklmnopqrstuvwxyThe vector constructor. (:.) for vectors is like (:) for lists, and  () takes the place of []1. (The list of instances here is not meant to be  readable.) z{/Make a uniform vector. The length is inferred. |Reverse a vector }sum of vector elements ~product of vector elements maximum vector element minimum vector element $convert a matrix to a list-of-lists .convert a matrix to a list in row-major order &convert a list-of-lists into a matrix 0convert a list into a matrix. (row-major order) [,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~[yzwxvutsrqponmlkjihgfecd{_`ab\]^Z[XYVWTUPQRS|NOLMJKHIFGDEBC}~A@?>=<;:9876543,-./012[,-./012-./0123456789:;<=>?@ABCCDEEFGGHIIJKKLMMNOOPQRSQRSTUUVWWXYYZ[[\]^]^_`ab`abcddefghijklmnopqrstuvwxxyzz{|}~<backSubstitute'; takes a full rank matrix from row echelon form to reduced @ row echelon form. Returns garbage is matrix is rank deficient. IbackSubstitute takes a full rank matrix from row echelon form to reduced  row echelon form. Returns Nothing# if the matrix is rank deficient. /Gaussian elimination, adapted from Mirko Rahn:   Khttp://www.haskell.org/pipermail/glasgow-haskell-users/2007-May/012648.html HThis is more of a proof of concept. Using a foreign C function will run I slightly faster, and compile much faster. But where is the fun in that? 3 Set your unfolding threshold as high as possible.  gaussElim m returns a pair (m',d) where m' is m in row echelon  form and d is the determinant of m. The determinant of m' is 1 or 0, < i.e., the leading coefficient of each non-zero row is 1.  nearZero x5 should be true when x is close enough to 0 to cause ! significant error in division. 1get the diagonal of an n-by-n matrix as a vector 9set the diagonal of an n-by-n matrix to a given n-vector matrix transposition dot / inner / scalar product vector norm, squared vector / L2 / Euclidean norm  normalize v& is a unit vector in the direction of v. v is assumed  non-null. 3d cross product. )lift a point into homogenous coordinates ,point-at-infinity in homogenous coordinates Eproject a vector from homogenous coordinates. Last vector element is  assumed non-zero. row vector * matrix matrix * column vector matrix * matrix :apply a translation to a projective transformation matrix get the n-th column as a vector. n is a type-level natural. get the n-th row as a vector. n is a type-level natural.  scale v m# multiplies the diagonal of matrix m by the vector s, component-wise. So   scale 5 m' multiplies the diagonal by 5, whereas  scale 2:.1 m  only scales the x component.  diagonal v= is a square matrix with the vector v as the diagonal, and 0  elsewhere. identity matrix (square) ,Determinant by minor expansion, i.e. Laplace's formula. Unfolds into a N closed form expression. This should be the fastest way for 4x4 and smaller,  but snd . gaussElim works too. cramer' sRule m v computes the solution to m`multmv`x=v using the < eponymous method. For larger than 3x3 you will want to use , which  uses . Cramer',s rule, however, unfolds into a closed-form N expression, with no branches or allocations (other than the result). You may 7 need to increase the unfolding threshold to see this. invert m returns Just the inverse of m or Nothing if m is singular. Ainverse and determinant. If det = 0, inverted matrix is garbage. ;Solution of linear system by Gaussian elimination. Returns Nothing  if no solution. $<$?PackedVec class : relates a vector type to its space-optimized  representation. The packed representation of v ;Construct a semi-packed matrix, one whose rows are packed.   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Vec-0.9.7 Data.Vec.Nat Data.Vec.BaseData.Vec.LinAlgData.Vec.PackedData.VecPredNatnatN19N18N17N16N15N14N13N12N11N10N9N8N7N6N5N4N3N2N1SuccN0n0n1n2n3n4n5n6n7n8n9n10n11n12n13n14n15n16n17n18n19 VecArrayRWvaRead#vaWrite#vaIndex# vaSizeOf# vaLength#init#Mat48Mat47Mat46Mat45Mat44Mat43Mat42Mat36Mat35Mat34Mat33Mat32Mat24Mat23Mat22LengthlengthSnocsnocLastlastDropdropTaketakeAppendappendReverse'reverse'FoldfoldfoldlfoldrZipWithzipWithMapmapTailtailHeadheadAccessgetsetVecListfromListgetElemsetElemVecmkVecVec19Vec18Vec17Vec16Vec15Vec14Vec13Vec12Vec11Vec10Vec9Vec8Vec7Vec6Vec5Vec4Vec3Vec2ShowVecshowVec:.vecreversesumproductmaximumminimumtoList matToLists matToList matFromLists matFromListsizeOf#BackSubstitute'backSubstitute'BackSubstitutebackSubstitute GaussElim gaussElimPivotpivotPivot1pivot1NearZeronearZero ReplConsec' replConsec' ReplConsec replConsec NegateEvens negateEvens NegateOdds negateOdds DropConsec' dropConsec' DropConsec dropConsecDet'det' GetDiagonal' getDiagonal' GetDiagonal getDiagonal SetDiagonal' setDiagonal' SetDiagonal setDiagonal Transpose' transpose' Transpose transposedotnormSqnorm normalizecrosshomPointhomVecprojectmultvmmultmvmultmm translatecolumnrowscalediagonalidentitydet cramer'sRuleinvert invertAndDetsolveMat44DMat34DMat33DMat24DMat23DMat22DVec4DVec3DVec2DVec4FVec3FVec2FVec4IVec3IVec2I PackedVecPackedpackunpackpackMat unpackMat