[1X4 General Functions[0X Some of the functions provided by [5XHAPprime[0m are not specifically aimed at homological algebra or extending the [5XHAP[0m package. The functions in this chapter, which are used internally by [5XHAPprime[0m extend some of the standard [5XGAP[0m functions and datatypes. [1X4.1 Matrices[0X See [14X'Reference: Matrices'[0m in the [5XGAP[0m reference manual for the standard [5XGAP[0m matrix functions. [1X4.1-1 SumIntersectionMatDestructive[0m [2X> SumIntersectionMatDestructive( [0X[3XU, V[0X[2X ) ___________________________[0Xoperation [2X> SumIntersectionMatDestructiveSE( [0X[3XUbasis, Uheads, Vbasis, Vheads[0X[2X ) [0Xoperation Returns a list of length 2 with, at the first position, the sum of the vector spaces generated by the rows of [3XU[0m and [3XV[0m, and, at the second positionion, the intersection of the spaces. Like the [5XGAP[0m core function [2XSumIntersectionMat[0m ([14XReference: SumIntersectionMat[0m), this performs Zassenhaus' algorithm to compute bases for the sum and the intersection. However, this version operates directly on the input matrices (thus corrupting them), and is rewritten to require only approximately 1.5 times the space of the orginal input matrices, compared with the 3 times memory requirement of the original version (in addition to the original input matrices in this case). The function [9XSumIntersectionMatDestructiveSE[0m takes as arguments not a pair of generating matrices, but a pair of semi-echelon basis matrices and the corresponding head locations, such as is returned by a call to [2XSemiEchelonMatDestructive[0m ([14XReference: SemiEchelonMatDestructive[0m) (these arguments must all be mutable, so [2XSemiEchelonMat[0m ([14XReference: SemiEchelonMat[0m) cannot be used). This function is used internally by [9XSumIntersectionMatDestructive[0m, and is provided for the occasions when the user might already have the semi-echelon versions available, in which case a small amount of time will be saved. [1X4.1-2 SolutionMat[0m [2X> SolutionMat( [0X[3XM, V[0X[2X ) _____________________________________________[0Xoperation [2X> SolutionMatDestructive( [0X[3XM, V[0X[2X ) __________________________________[0Xoperation Calculates, for each row vector v_i in the matrix [3XV[0m, a solution to x_i x M = v_i, and returns these solutions in a matrix X, whose rows are the vectors x_i. If there is not a solution for a v_i, then [9Xfail[0m is returned for that row. These functions are identical to the kernel functions [2XSolutionMat[0m ([14XReference: SolutionMat[0m) and [2XSolutionMatDestructive[0m ([14XReference: SolutionMatDestructive[0m), but are provided for cases where multiple solutions using the same matrix [3XM[0m are required. In these cases, using this function is far faster, since the matrix is only decomposed once. The [10XDestructive[0m version currupts both the input matrices, while the non-[10XDestructive[0m version operates on copies of these. [1X4.1-3 IsSameSubspace[0m [2X> IsSameSubspace( [0X[3XU, V[0X[2X ) __________________________________________[0Xoperation Returns [9Xtrue[0m if the subspaces spanned by the rows of [3XU[0m and [3XV[0m are the same, [9Xfalse[0m otherwise. This function treats the rows of the two matrices as vectors from the same vector space (with the same basis), and tests whether the subspace spanned by the two sets of vectors is the same. [1X4.1-4 PrintDimensionsMat[0m [2X> PrintDimensionsMat( [0X[3XM[0X[2X ) _________________________________________[0Xoperation Returns a string containing the dimensions of the matrix [3XM[0m in the form [10X"mxn"[0m, where [9Xm[0m is the number of rows and [9Xn[0m the number of columns. If the matrix is empty, the returned string is [10X"empty"[0m. [1X4.2 Polynomials[0X See [14X'Reference: Polynomials and Rational Functions'[0m in the [5XGAP[0m reference manual for the functions provided by [5XGAP[0m for representing an manipulating polynomials. [1X4.2-1 TermsOfPolynomial[0m [2X> TermsOfPolynomial( [0X[3Xpoly[0X[2X ) _______________________________________[0Xoperation [6XReturns:[0X List of pairs Returns a list of the terms in the polynomial. This list is a list of pairs of the form [10X[mon, coeff][0m where [10Xmon[0m is a monomial and [10Xcoeff[0m is the coefficient of that monomial in the polynomial. The monomials are sorted according to the total degree/lexicograhic order (the same as the in [2XMonomialGrLexOrdering[0m ([14XReference: MonomialGrlexOrdering[0m)). [1X4.2-2 UnivariateMonomialsOfMonomial[0m [2X> UnivariateMonomialsOfMonomial( [0X[3Xmon[0X[2X ) ____________________________[0Xoperation [6XReturns:[0X List of univariate monomials Returns a list of the univariate monomials of the largest order whose product equals [3Xmon[0m. The univariate monomials are sorted according to their indeterminate number. [1X4.2-3 IndeterminateAndCoefficientOfUnivariateMonomial[0m [2X> IndeterminateAndCoefficientOfUnivariateMonomial( [0X[3Xmon[0X[2X ) __________[0Xoperation [6XReturns:[0X List Returns a list with in the first position the indeterminate of the univariate monomial [3Xmon[0m and in the second position the coefficient of that indeterminate in the monomial. If [3Xmon[0m is not a monomial, then [9Xfail[0m is returned. [1X4.2-4 ReduceIdeal[0m [2X> ReduceIdeal( [0X[3XI, O[0X[2X ) _____________________________________________[0Xoperation [6XReturns:[0X List of polynomials Returns a reduced version of the ideal [3XI[0m, i.e. one in which no monomial in a polynomial in [3XI[0m is divisible by the leading term of another polynomial in [3XI[0m. The monomial ordering to be used is specified by [3XO[0m (see [14X'Reference: Monomial Orderings'[0m). [1X4.2-5 ReducePolynomialRingPresentation[0m [2X> ReducePolynomialRingPresentation( [0X[3Xring, ideal[0X[2X ) _________________[0Xoperation [6XReturns:[0X List Reduces a polynomial ring presentation to an isomorphic presentation involving the minimal number of indeterminates. Returns a list with, in the first place, the new polynomial ring, and in the second place the new relations. [1X4.2-6 Examples[0X [4X--------------------------- Example ----------------------------[0X [4Xgap> ring := PolynomialRing(Integers, 2);;[0X [4Xgap> i := IndeterminatesOfPolynomialRing(ring);;[0X [4Xgap> poly := i[1] + i[1]*i[2]^2 + 3*i[2]^3;[0X [4Xx_1*x_2^2+3*x_2^3+x_1[0X [4Xgap> terms := TermsOfPolynomial(poly);[0X [4X[ [ x_1, 1 ], [ x_2^3, 3 ], [ x_1*x_2^2, 1 ] ][0X [4Xgap> UnivariateMonomialsOfMonomial(terms[3][1]);[0X [4X[ x_1, x_2^2 ][0X [4Xgap> IndeterminateAndCoefficientOfUnivariateMonomial(last[2]);[0X [4X[ x_2, 2 ][0X [4X [0X [4X------------------------------------------------------------------[0X [4X--------------------------- Example ----------------------------[0X [4Xgap> ring := PolynomialRing(GF(2), 2);;[0X [4Xgap> i := IndeterminatesOfPolynomialRing(ring);;[0X [4Xgap> I := [i[1]^2 + i[2], i[1]^3 + i[2]^3];[0X [4X[ x_1^2+x_2, x_1^3+x_2^3 ][0X [4Xgap> ReduceIdeal(I, MonomialLexOrdering());[0X [4X[ x_1^2+x_2, x_2^3+x_1*x_2 ][0X [4X [0X [4X------------------------------------------------------------------[0X [4X--------------------------- Example ----------------------------[0X [4Xgap> ring := PolynomialRing(GF(2), 3);;[0X [4Xgap> i := IndeterminatesOfPolynomialRing(ring);;[0X [4Xgap> ideal := [ i[3]^2 + i[1] + i[2] ];[0X [4X[ x_3^2+x_1+x_2 ][0X [4Xgap> ReducePolynomialRingPresentation(ring, ideal);[0X [4X[ GF(2)[x_1,x_3], [ ] ][0X [4X [0X [4X------------------------------------------------------------------[0X