goSE      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDnat n yields the Int! value of the type-level natural n. ,  !"#$%&'()*+,  !"#$%&'()*+,/Make a uniform vector. The length is inferred. -sum of vector elements .product of vector elements /maximum vector element 0minimum vector element 2$convert a matrix to a list-of-lists 3.convert a matrix to a list in row-major order 4&convert a list-of-lists into a matrix 50convert a list into a matrix. (row-major order) Esnoc v a) appends the element a to the end of v. GHGet the last element, usually significant for some reason (quaternions, # homogenous coordinates, whatever) Idrop 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. Ktake 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. MAppend two vectors Q Fold a function over a vector. UICombine 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. W;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. YAll but the first element. [The 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. `The 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. a)Make a uniform vector of a given length. n is a type-level natural.  Use ," when the length can be inferred. b-turn a list into a vector of inferred length c9get a vector element, which one is determined at runtime d9set a vector element, which one is determined at runtime w,Helper to keep parentheses at bay. Just use show as usual. yThe 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.) P,E-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyFN,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyzpack a matrix {unpack a matrix |HPackedVec class : relates a packed vector type to its unpacked type For M now, the fundep is not bijective -- It may be advantageous to have multiple M packed representations for a canonical vector type. This may change. In the 2 meantime, you may have to annotate return types. &z{|}~GHIJKLMNOz{|}~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) 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. 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. GDeterminant by minor expansion. Unfolds into a closed form expression. 9 This should be the fastest way for 4x4 and smaller, but snd . gaussElim  works too. 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 %Ѯ      !"#$%&'()*+,-./0123456789:;<=>?@ABCD  !"#$%&'()*+,E-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyFz{|}~GHIJKLMNOP      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789: Vec-0.9.0 Data.Vec.Nat Data.Vec.BaseData.Vec.PackedData.Vec.LinAlgData.Vec.InstancesData.Vecn0n1n2n3n4n5n6n7n8n9n10n11n12n13n14n15n16n17n18n19PredNatnatN19N18N17N16N15N14N13N12N11N10N9N8N7N6N5N4N3N2N1SuccN0vecsumproductmaximumminimumtoList matToLists matToList matFromLists matFromListMat48Mat47Mat46Mat45Mat44Mat43Mat42Mat36Mat35Mat34Mat33Mat32Mat24Mat23Mat22SnocsnocLastlastDropdropTaketakeAppendappendReverse'reverse'FoldfoldfoldlfoldrZipWithzipWithMapmapTailtailHeadheadAccessgetsetVecmkVecfromListgetElemsetElemVec19Vec18Vec17Vec16Vec15Vec14Vec13Vec12Vec11Vec10Vec9Vec8Vec7Vec6Vec5Vec4Vec3Vec2ShowVecshowVec:.packMat unpackMat PackedVecpackunpackMat44DMat34DMat33DMat23DMat22DMat44FMat34FMat33FMat23FMat22FMat44IMat34IMat33IMat23IMat22IVec4DVec3DVec2DVec4FVec3FVec2FVec4IVec3IVec2IdotnormSqnorm normalizecrosshomPointhomVecprojectmultvmmultmvmultmm translatecolumnrowscalediagonalidentity cramer'sRuleinvert invertAndDetsolveBackSubstitute'backSubstitute'BackSubstitutebackSubstitute GaussElim gaussElimPivotpivotPivot1pivot1NearZeronearZero ReplConsec' replConsec' ReplConsec replConsecDetdetDet'det' Alternating alternating DropConsec' dropConsec' DropConsec dropConsec GetDiagonal' getDiagonal' GetDiagonal getDiagonal SetDiagonal' setDiagonal' SetDiagonal setDiagonal Transpose' transpose' Transpose transpose:DBackSubstitute':TBackSubstitute':DBackSubstitute:TBackSubstitute :DGaussElim :TGaussElim:DPivot:TPivot:DPivot1:TPivot1 :DNearZero :DReplConsec' :TReplConsec' :DReplConsec :TReplConsec:DDet:TDet:DDet':TDet' :DAlternating :TAlternating :DDropConsec' :TDropConsec' :DDropConsec :TDropConsec:DGetDiagonal':TGetDiagonal' :DGetDiagonal :TGetDiagonal:DSetDiagonal':TSetDiagonal' :DSetDiagonal :TSetDiagonal :DTranspose' :TTranspose' :DTranspose :TTranspose $p1NearZero:Co:TBackSubstitute':Co:TBackSubstitute:Co:TGaussElim :Co:TPivot :Co:TPivot1 :TNearZero:Co:TReplConsec':Co:TReplConsec:Co:TDet :Co:TDet':Co:TAlternating:Co:TDropConsec':Co:TDropConsec:Co:TGetDiagonal':Co:TGetDiagonal:Co:TSetDiagonal':Co:TSetDiagonal:Co:TTranspose':Co:TTranspose$f1$f2$f3$f4$f5$f6$f7$f8$f9$f10$f11$f12$f13$f14$f15$f16$f17$f18$f19$f20$f21$f22$f23$f24$f25$f26$f27$f28$f29$f30$f31$f32$f33$f34$f35$f36$f37$f38 $dmnearZeroreverse