Optimized Cython code needed by quaternion algebras¶
This is a collection of miscellaneous routines that are in Cython for speed purposes and are used by the quaternion algebra code. For example, there are functions for quickly constructing an n x 4 matrix from a list of n rational quaternions.
AUTHORS:
William Stein
- sage.algebras.quatalg.quaternion_algebra_cython.integral_matrix_and_denom_from_rational_quaternions(v, reverse=False)[source]¶
Given a list of rational quaternions, return matrix \(A\) over \(\ZZ\) and denominator \(d\), such that the rows of \((1/d)A\) are the entries of the quaternions.
INPUT:
v– list of quaternions in a rational quaternion algebrareverse– whether order of the coordinates as well as the order of the listvshould be reversed
OUTPUT:
a matrix over \(\ZZ\)
an integer (the common denominator)
EXAMPLES:
sage: A.<i,j,k>=QuaternionAlgebra(-4,-5) sage: sage.algebras.quatalg.quaternion_algebra_cython.integral_matrix_and_denom_from_rational_quaternions([i/2,1/3+j+k]) ( [0 3 0 0] [2 0 6 6], 6 ) sage: sage.algebras.quatalg.quaternion_algebra_cython.integral_matrix_and_denom_from_rational_quaternions([i/2,1/3+j+k], reverse=True) ( [6 6 0 2] [0 0 3 0], 6 )
- sage.algebras.quatalg.quaternion_algebra_cython.rational_matrix_from_rational_quaternions(v, reverse=False)[source]¶
Return matrix over the rationals whose rows have entries the coefficients of the rational quaternions in
v.INPUT:
v– list of quaternions in a rational quaternion algebrareverse– whether order of the coordinates as well as the order of the listvshould be reversed
OUTPUT: a matrix over \(\QQ\)
EXAMPLES:
sage: A.<i,j,k>=QuaternionAlgebra(-4,-5) sage: sage.algebras.quatalg.quaternion_algebra_cython.rational_matrix_from_rational_quaternions([i/2,1/3+j+k]) [ 0 1/2 0 0] [1/3 0 1 1] sage: sage.algebras.quatalg.quaternion_algebra_cython.rational_matrix_from_rational_quaternions([i/2,1/3+j+k], reverse=True) [ 1 1 0 1/3] [ 0 0 1/2 0]
- sage.algebras.quatalg.quaternion_algebra_cython.rational_quaternions_from_integral_matrix_and_denom(A, H, d, reverse=False)[source]¶
Given an integral matrix and denominator, returns a list of rational quaternions.
INPUT:
A– rational quaternion algebraH– matrix over the integersd– integerreverse– whether order of the coordinates as well as the order of the listvshould be reversed
OUTPUT:
list of
H.nrows()elements ofA
EXAMPLES:
sage: A.<i,j,k>=QuaternionAlgebra(-1,-2) sage: f = sage.algebras.quatalg.quaternion_algebra_cython.rational_quaternions_from_integral_matrix_and_denom sage: f(A, matrix([[1,2,3,4],[-1,2,-4,3]]), 3) [1/3 + 2/3*i + j + 4/3*k, -1/3 + 2/3*i - 4/3*j + k] sage: f(A, matrix([[3,-4,2,-1],[4,3,2,1]]), 3, reverse=True) [1/3 + 2/3*i + j + 4/3*k, -1/3 + 2/3*i - 4/3*j + k]