Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X2 Bits and Pieces[0X23This chapter contains a few very basic functions which are needed for space4group calculations and were missing in standard [5XGAP[0m.567[1X2.1 Matrices and Vectors[0X89[1X2.1-1 SignRat[0m1011[2X> SignRat( [0X[3Xx[0X[2X ) _______________________________________________________[0Xmethod12[6XReturns:[0X sign of the rational number [3Xx[0m (Standard [5XGAP[0m currently only has13[10XSignInt[0m).1415[1X2.1-2 VectorModOne[0m1617[2X> VectorModOne( [0X[3Xv[0X[2X ) __________________________________________________[0Xmethod18[6XReturns:[0X Rational vector of the same length with enties in [0,1)1920For a rational vector [3Xv[0m, this returns the vector with all entries taken "mod211".2223[4X--------------------------- Example ----------------------------[0X24[4Xgap> SignRat((-4)/(-2));[0X25[4X1[0X26[4Xgap> SignRat(9/(-2));[0X27[4X-1[0X28[4Xgap> VectorModOne([1/10,100/9,5/6,6/5]);[0X29[4X[ 1/10, 1/9, 5/6, 1/5 ][0X30[4X------------------------------------------------------------------[0X3132[1X2.1-3 IsSquareMat[0m3334[2X> IsSquareMat( [0X[3Xmatrix[0X[2X ) ______________________________________________[0Xmethod35[6XReturns:[0X [9Xtrue[0m if [3Xmatrix[0m is a square matrix and [9Xfalse[0m otherwise.3637[1X2.1-4 DimensionSquareMat[0m3839[2X> DimensionSquareMat( [0X[3Xmatrix[0X[2X ) _______________________________________[0Xmethod40[6XReturns:[0X Number of lines in the matrix [3Xmatrix[0m if it is square and [9Xfail[0m41otherwise4243[4X--------------------------- Example ----------------------------[0X44[4Xgap> m:=[[1,2,3],[4,5,6],[9,6,12]];[0X45[4X[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 9, 6, 12 ] ][0X46[4Xgap> IsSquareMat(m);[0X47[4Xtrue[0X48[4Xgap> DimensionSquareMat(m);[0X49[4X3[0X50[4Xgap> DimensionSquareMat([[1,2],[1,2,3]]);[0X51[4XError, Matrix is not square called from[0X52[4X------------------------------------------------------------------[0X5354Affine mappings of n dimensional space are often written as a pair (A,v)55where A is a linear mapping and v is a vector. [5XGAP[0m represents affine56mappings by n+1 times n+1 matrices M which satisfy M_{n+1,n+1}=1 and57M_{i,n+1}=0 for all 1<= i <= n.5859An affine matrix acts on an n dimensional space which is written as a space60of n+1 tuples with n+1st entry 1. Here we give two functions to handle these61affine matrices.626364[1X2.2 Affine Matrices OnRight[0X6566[1X2.2-1 LinearPartOfAffineMatOnRight[0m6768[2X> LinearPartOfAffineMatOnRight( [0X[3Xmat[0X[2X ) ________________________________[0Xmethod69[6XReturns:[0X the linear part of the affine matrix [3Xmat[0m. That is, everything70except for the last row and column.7172[1X2.2-2 BasisChangeAffineMatOnRight[0m7374[2X> BasisChangeAffineMatOnRight( [0X[3Xtransform, mat[0X[2X ) ______________________[0Xmethod75[6XReturns:[0X affine matrix with same dimensions as [3Xmat[0m7677A basis change [3Xtransform[0m of an n dimensional space induces a transformation78on affine mappings on this space. If [3Xmat[0m is a affine matrix (in particular,79it is (n+1)x (n+1)), this method returns the image of [3Xmat[0m under the basis80transformation induced by [3Xtransform[0m.8182[4X--------------------------- Example ----------------------------[0X83[4Xgap> c:=[[0,1],[1,0]];[0X84[4X[ [ 0, 1 ], [ 1, 0 ] ][0X85[4Xgap> m:=[[1/2,0,0],[0,2/3,0],[1,0,1]];[0X86[4X[ [ 1/2, 0, 0 ], [ 0, 2/3, 0 ], [ 1, 0, 1 ] ][0X87[4Xgap> BasisChangeAffineMatOnRight(c,m);[0X88[4X[ [ 2/3, 0, 0 ], [ 0, 1/2, 0 ], [ 0, 1, 1 ] ][0X89[4X------------------------------------------------------------------[0X9091[1X2.2-3 TranslationOnRightFromVector[0m9293[2X> TranslationOnRightFromVector( [0X[3Xv[0X[2X ) __________________________________[0Xmethod94[6XReturns:[0X Affine matrix9596Given a vector [3Xv[0m with n entries, this method returns a (n+1)x (n+1) matrix97which corresponds to the affine translation defined by [3Xv[0m.9899[4X--------------------------- Example ----------------------------[0X100[4Xgap> m:=TranslationOnRightFromVector([1,2,3]);;[0X101[4Xgap> Display(m);[0X102[4X[ [ 1, 0, 0, 0 ],[0X103[4X [ 0, 1, 0, 0 ],[0X104[4X [ 0, 0, 1, 0 ],[0X105[4X [ 1, 2, 3, 1 ] ][0X106[4Xgap> LinearPartOfAffineMatOnRight(m);[0X107[4X[ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ][0X108[4Xgap> BasisChangeAffineMatOnRight([[3,2,1],[0,1,0],[0,0,1]],m);[0X109[4X[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 3, 4, 4, 1 ] ][0X110[4X------------------------------------------------------------------[0X111112113[1X2.3 Geometry[0X114115[1X2.3-1 GramianOfAverageScalarProductFromFiniteMatrixGroup[0m116117[2X> GramianOfAverageScalarProductFromFiniteMatrixGroup( [0X[3XG[0X[2X ) ____________[0Xmethod118[6XReturns:[0X Symmetric positive definite matrix119120For a finite matrix group [3XG[0m, the gramian matrix of the average scalar121product is returned. This is the sum over all gg^t with gin G (actually it122is enough to take a generating set). The group [3XG[0m is orthogonal with respect123to the scalar product induced by the returned matrix.124125126[1X2.3-2 Inequalities[0X127128Inequalities are represented in the same way they are represented in129[5Xpolymaking[0m. The vector (v_0,...,v_n) represents the inequality 0<= v_0+v_1130x_1+... + v_n x_n.131132[1X2.3-3 BisectorInequalityFromPointPair[0m133134[2X> BisectorInequalityFromPointPair( [0X[3Xv1, v2[, gram][0X[2X ) __________________[0Xmethod135[6XReturns:[0X vector of length [10XLength(v1)+1[0m136137Calculates the inequality defining the half-space containing [3Xv1[0m such that138[10X[3Xv1[0m[10X-[3Xv2[0m[10X[0m is perpendicular on the bounding hyperplane. And [10X([3Xv1[0m[10X-[3Xv2[0m[10X)/2[0m is139contained in the bounding hyperplane.140If the matrix [3Xgram[0m is given, it is used as the gramian matrix. Otherwiese,141the standard scalar product is used. It is not checked if [3Xgram[0m is positive142definite or symmetric.143144[1X2.3-4 WhichSideOfHyperplane[0m145146[2X> WhichSideOfHyperplane( [0X[3Xv, ineq[0X[2X ) ___________________________________[0Xmethod147[2X> WhichSideOfHyperplaneNC( [0X[3Xv, ineq[0X[2X ) _________________________________[0Xmethod148[6XReturns:[0X -1 (below) 0 (in) or 1 (above).149150Let [3Xv[0m be a vector of length n and [3Xineq[0m an inequality represented by a vector151of length n+1. Then [10XWhichSideOfHyperplane([3Xv, ineq[0m[10X)[0m returns 1 if [3Xv[0m is a152solution of the inequality but not the equation given by [3Xineq[0m, it returns 0153if [3Xv[0m is a solution to the equation and -1 if it is not a solution of the154inequality [3Xineq[0m.155156The NC version does not test the input for correctness.157158[4X--------------------------- Example ----------------------------[0X159[4Xgap> BisectorInequalityFromPointPair([0,0],[1,0]);[0X160[4X[ 1, -2, 0 ][0X161[4Xgap> ineq:=BisectorInequalityFromPointPair([0,0],[1,0],[[5,4],[4,5]]);[0X162[4X[ 5, -10, -8 ][0X163[4Xgap> ineq{[2,3]}*[1/2,0];[0X164[4X-5[0X165[4Xgap> WhichSideOfHyperplane([0,0],ineq);[0X166[4X1[0X167[4Xgap> WhichSideOfHyperplane([1/2,0],ineq);[0X168[4X0[0X169[4X------------------------------------------------------------------[0X170171[1X2.3-5 RelativePositionPointAndPolygon[0m172173[2X> RelativePositionPointAndPolygon( [0X[3Xpoint, poly[0X[2X ) _____________________[0Xmethod174[6XReturns:[0X one of [10X"VERTEX", "FACET", "OUTSIDE", "INSIDE"[0m175176Let [3Xpoly[0m be a [9XPolymakeObject[0m and [3Xpoint[0m a vector. If [3Xpoint[0m is a vertex of177[3Xpoly[0m, the string [10X"VERTEX"[0m is returned. If [3Xpoint[0m lies inside [3Xpoly[0m, [10X"INSIDE"[0m178is returned and if it lies in a facet, [10X"FACET"[0m is returned and if [3Xpoint[0m does179not lie inside [3Xpoly[0m, the function returns [10X"OUTSIDE"[0m.180181182[1X2.4 Space Groups[0X183184[1X2.4-1 PointGroupRepresentatives[0m185186[2X> PointGroupRepresentatives( [0X[3Xgroup[0X[2X ) ______________________________[0Xattribute187[2X> PointGroupRepresentatives( [0X[3Xgroup[0X[2X ) _________________________________[0Xmethod188[6XReturns:[0X list of matrices189190Given an [9XAffineCrystGroupOnLeftOrRight[0m [3Xgroup[0m, this returns a list of191representatives of the point group of [3Xgroup[0m. That is, a system of192representatives for the factor group modulo translations. This is an193attribute of [9XAffineCrystGroupOnLeftOrRight[0m194195196197