Ξυ³h$8Y5S•      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”(c) Johannes Kropp BSD 3-Clause#Johannes Kropp Noneznuha%cartesian product for a list of listsnuhaΪunsafe function for convert an 1d index (of the holor values) to a multiindex of the holornuhaΪunsafe function for convert multiindex of the holor to a an 1d index (of the holor values)nuha1calculates the holor strides from the holor shapenuha?calculates all possible multiindices for a holor from its shapenuhatests if an index is validnuhatests if a multiindex is validnuhatests if multiindices are validnuhastridesnuha multiindexnuhaindexnuhalengthnuhaidxnuhashapenuha multiindexnuhashapenuha multiindices(c) Johannes Kropp BSD 3-Clause#Johannes Kropp None Ϋnuha 4,4-tuple nuha 3,4-tuple nuha 2,4-tuple nuha 4,3-tuple nuha 3,3-tuple nuha 2,3-tuplenuha 4,2-tuplenuha 3,2-tuplenuha 2,2-tuplenuha4-tuplenuha3-tuplenuha2-tuplenuhaΗSum type of various errors that can be thrown in non trivial algorithmsnuha™Datatype for a holor which is basically a multidimensional array. Sometimes in literature the word tensor is used instead, but this is not correct because a tensor has additional properties that do not apply for multidimensional arrays in general. For an explanation of holors see /https://en.wikipedia.org/wiki/Parry_Moon#Holors…Most often a holor is used as the type for a vector or matrix. Holors as row vectors have shape [1,n] and column vectors [m,1]. Matrices are of shape [m,n]. A holor with a single element has shape [1,1]. Note that the length of the shape is always at least two.ΒThe indexing of the holor entries starts with 0 in each dimension.nuhaNoneΩ Ο;&nuha#Basic function for creating a holorholor [2,2] [1,2,3,4] 1.0 2.0 3.0 4.0"holor [2,2] [1,2,3,4] :: Holor Int 1 2 3 4holor [2,2,4] [1 .. 16] [0,:,:] = 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 [1,:,:] = 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0'nuha3Creates a column-vector (2d-holor with shape [m,1])vector [1,2,3,4] 1.0 2.0 3.0 4.0(nuhaCreates a matrix (2d-holor)matrix [[1,2],[3,4]] 1.0 2.0 3.0 4.0)nuha Creates a 2x1 holor from a tuple*nuha Creates a 3x1 holor from a tuple+nuha Creates a 4x1 holor from a tuple,nuha&Creates a 2x2 holor from nested tuples-nuha&Creates a 3x2 holor from nested tuples.nuha&Creates a 4x2 holor from nested tuples/nuha&Creates a 2x3 holor from nested tuples0nuha&Creates a 3x3 holor from nested tuples1nuha&Creates a 4x3 holor from nested tuples2nuha&Creates a 2x4 holor from nested tuples3nuha&Creates a 3x4 holor from nested tuples4nuha&Creates a 4x4 holor from nested tuples5nuha;Creates a holor for a given shape with all entries the samereplicate [1,3] 0 0.0 0.0 0.06nuhaShape of a holor7nuhaNumber of holor entrys8nuhaΟSize of all holor elements in bytes (not equal to consumed memory of the holor)9nuha'Size of a single holor element in bytes:nuha&Dimension of a holor (length of shape)dim $ holor [2,2,2] [0..7]3;nuhaΗIndexing a holor with shape (n,1) (column-vector) or (1,n) (row-vector)v = vector [5,6,7]v!16.0<nuhaΧUnsafe version of (!) without checking for row or column vector and not checking bounds=nuha"Indexing a single entry of a holor$m = matrix [[2,3,4],[5,6,3],[9,0,2]]m|![0,2]4.0>nuha.Unsafe version of (|!) without checking bounds?nuhaγExtract a subholor by indices in the first dimension. Applied to a vector the result is a vector with the elements at the given element-indices. Applied to a matrix the result is a matrix with the rows at the given row-indices.h = holor [4,4] [1..16]h 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 h||![1,3] 5.0 6.0 7.0 8.0 13.0 14.0 15.0 16.0@nuha0Unsafe version of (||!) without checking indicesAnuha˜Multidimensional indexing. For each dimension a list of indices define the axes to extract. This means multiindexing is done by a nested list of indices which has the same length as the shape. The dimension of the extracted subholor remains the same as that of the original holor.h = holor [4,4] [1..16]h 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0h|||![[1,2,3],[0,1,1,2,3]] 5.0 6.0 6.0 7.0 8.0 9.0 10.0 10.0 11.0 12.0 13.0 14.0 14.0 15.0 16.0Bnuha6Unsafe version of (|||!) without checking multiindicesCnuha*Map a function over all entries of a holorDnuhaΫFilter the values of a holor by a condition. The remaining elements are returned in a list.(h = holor [3,3,3] [1 .. 27] :: Holor Intfilter (\e -> mod e 3 == 0) h[3,6,9,12,15,18,21,24,27]EnuhaΤSelect all multiindices of a holor whose corresponding elements fulfill a condition.m = matrix [[-1,1],[-2,3]]selectBy (>0) m [[0,1],[1,1]]Fnuha2Count elements of a holor that fulfill a conditionGnuha/Accumulate the values of a holor by a function.!v = vector [2,3,4,1] :: Holor Intaccumulate (+) v [2,5,9,10]accumulate max v [2,3,4,4]Hnuha"Flatten a holor to a column vectorInuhaTranspose a holorJnuhaΓReshape a holor without changing the order of the underlying valuesh = holor [2,2,2] [1 .. 8]reshape [2,4] h 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0KnuhaΒGet diagonal of a quadratical matrix (2d-holor) as a column vectorLnuha"Returns the holor values in a listMnuha4Returns the values of an 2d-holor in a list of listsNnuha=nτ, all elements on the first diagonal must be unequal to zero and all elements below the first diagonal must be zero.&nuhashapenuhavalues;&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`;&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`;9 <9 =9 >9 ?9 @9 A9 B9 (c) Johannes Kropp BSD 3-Clause#Johannes Kropp None+/anuha0diagonalizes a list of values as a square matrixbnuhaholor with all entries zerocnuhaholor with all entries onednuhaidentity matrixenuha6creates a column vector with points in linear sequencelinSpace 1 3 5 1.0 1.5 2.0 2.5 3.0fnuha6Add a scalar from the right to each element of a holorgnuha5Add a scalar from the left to each element of a holorhnuha;Subtract a scalar from the right to each element of a holorinuha8A single scalar is subtracted by each element of a holorjnuha'Holor multiplied by a scalar from rightknuha&Holor multiplied by a scalar from leftlnuhaHolor divided by a scalarmnuha5A single scalar is divided by each element of a holornnuhaelementwise holor additiononuhaelementwise holor subtractionpnuha elementwise holor multiplicationqnuhaήHolor multiplication, last dimension of left holor has to match first dimension of right holorrnuhaHolor to a power elementwisesnuha0Holor multiplied with itself elementwise n-timestnuhaadditive inverse of a holorunuha#absolute values ‹@‹@by holor elementsvnuhasignum by holor elementswnuhamaximum of all holor elementsxnuhaminimum of all holor elementsynuhasum all element of a holorznuhatrace of a matrix{nuhap-norm of a holor|nuha!manhattan norm of a holor (p = 1)}nuhaΨfrobenius norm of a holor. If the holor has vector form it's equal to the euclidian norm~nuha!maximum norm of a holor (p = inf)nuha*normalize a holor to unit-length in p-norm€nuha*normalize a holor to unit-length in 1-normnuha*normalize a holor to unit-length in 2-norm‚nuha0normalize a holor to unit-length in maximum-normƒnuha"dot product for holors with shape  column-vectorn,1 or row-vector1,n„nuha$cross product for holors with shape  column-vector3,1 or row-vector1,3…nuhaadjugate of 2x2 matrix†nuhaadjugate of 3x3 matrix‡nuhaadjugate of 4x4 matrixˆnuhadeterminant of 2x2 matrix‰nuhadeterminant of 3x3 matrixŠnuhadeterminant of 4x4 matrix‹nuhainverse of 2x2 matrixŒnuhainverse of 3x3 matrixnuhainverse of 4x4 matrixŽnuha3select all indices of a holor with nonzero elementsnuhanumber of nonzero elements/abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ/abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽf6g6h6i6j7k7l7m7n6o6p7q7r8s8(c) Johannes Kropp BSD 3-Clause#Johannes Kropp None4nuhaβSolves the linear system A*x=b with A as a square matrix. The possible errors that can happen are ,  and  —_A = matrix [[1,1,2],[2,-3,0],[2,4,-4]] b = vector [2,5,3] x = case solveLin _A b of Left err -> error $ "solveLin : " ++ show err Right x -> x‘nuha—Solves the linear least squares problem, i.e. finds the least squares solution of the overdetermined linear equation system A*x=b. Possible errors are  and  ¨_A = matrix [[1,1,2],[2,-3,0],[2,4,-4],[2,4,-4.3]] b = vector [2,3,4,5] x = case solveLinLS _A b of Left err -> error $ "solveLinLS : " ++ show err Right x -> x’nuhaίBackward substitution for solving R*x=b with an upper triangular matrix R. Possible errors are  and “nuha?Factorization of a rectangular matrix A with shape [m,n] where m>=nΎ into the matrices (Q,R) with A=Q*R where Q is orthogonal and R is of shape [m,n] with the first n rows in upper triangular form and the last m-n rows filled with zeros. Possible errors are  and  —_A = matrix [[1,1,2],[2,-3,0],[2,4,-4],[2,4,-5]] (_Q,_R) = case facQR _A of Left err -> error $ "facQR : " ++ show err Right (_Q,_R) -> (_Q,_R)”nuha₯Pre step of the QR factorization of a rectangular matrix A. The outputs of this function are a the list of the householder reflection vectors and the matrix R which is the same as in the full QR factorization. The matrix Q is implicitly stored in the householder reflection vectors by the rule: transpose(Q) = S_m * ... * S_1. For the matrices S_i applies: S_i = I - 2*(dot v_i v_i) where I is the Identity matrix and v_i the i-th householder vector. This function is sometimes useful where the Q Matrix isn't explicitly needed. Possible errors are  and  Κ_A = matrix [[1,1,2],[2,-3,0],[2,4,-4],[2,4,-5]] (reflectionVectors,_R) = case facPreQR _A of Left err -> error $ "facPreQR : " ++ show err Right (reflectionVectors,_R) -> (reflectionVectors,_R)‘’“”‘’“”(c) Johannes Kropp 2020 BSD 3-Clause#Johannes Kropp  experimental non-portableNone4±ˆ  &'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•      !"##$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›#nuha-0.3.0.0-Ai4eu82JF254KXCtnWicpqMath.Nuha.InternalMath.Nuha.TypesMath.Nuha.BaseMath.Nuha.NumericMath.Nuha.Algorithms Math.NuhacartProdfromIndexToMultiIndexfromMultiIndexToIndexfromShapeToStridesfromShapeToMultiIndices isValidIdx isValidMIdx isValidMIdcsT44T34T24T43T33T23T42T32T22T4T3T2ErrorNoUpperTriErrorDimensionMismatchError NoMatrixErrorNoSquareMatrixErrorTooFewRowsErrorRankDeficiencyErrorUnderdeterminedSystemErrorHolorhShapehStrideshValues $fOrdHolor $fEqHolor $fShowHolor $fEqError $fShowErrorholorvectormatrixvector2vector3vector4matrix22matrix32matrix42matrix23matrix33matrix43matrix24matrix34matrix44 replicateshapenumElems sizeOfElems sizeOfElemdim!!!|!|!!||!||!!|||!|||!!mapfilterselectBycountBy accumulateflatten transposereshapediagonaltoListtoList2toScalartoT2toT3toT4toT22toT32toT42toT23toT33toT43toT24toT34toT44setElemsetElems isValidHolorisVectorisSquare isUpperTridiagzerosoneseyelinSpace|++||--||**||//||+||-||*||.||**|^negateabssignummaximumminimumsumtracenormnorm1norm2normM normalize normalize1 normalize2 normalizeMdotcross adjugate22 adjugate33 adjugate44det22det33det44inv22inv33inv44 selectNonzero countNonzerosolveLin solveLinLS solveLinBackfacQRfacPreQR