Random Quadratic Forms#
This file contains a set of routines to create a random quadratic form.
- sage.quadratic_forms.random_quadraticform.random_quadraticform(R, n, rand_arg_list=[])#
Create a random quadratic form in \(n\) variables defined over the ring \(R\).
The last (and optional) argument
rand_arg_list
is a list of at most 3 elements which is passed (as at most 3 separate variables) into the methodR.random_element()
.INPUT:
\(R\) – a ring.
\(n\) – an integer \(\ge 0\)
rand_arg_list
– a list of at most 3 arguments which can be taken byR.random_element()
.
OUTPUT:
A quadratic form over the ring \(R\).
EXAMPLES:
sage: random_quadraticform(ZZ, 3, [1,5]) # random Quadratic form in 3 variables over Integer Ring with coefficients: [ 3 2 3 ] [ * 1 4 ] [ * * 3 ] sage: random_quadraticform(ZZ, 3, [-5,5]) # random Quadratic form in 3 variables over Integer Ring with coefficients: [ 3 2 -5 ] [ * 2 -2 ] [ * * -5 ] sage: random_quadraticform(ZZ, 3, [-50,50]) # random Quadratic form in 3 variables over Integer Ring with coefficients: [ 1 8 -23 ] [ * 0 0 ] [ * * 6 ]
- sage.quadratic_forms.random_quadraticform.random_quadraticform_with_conditions(R, n, condition_list=[], rand_arg_list=[])#
Create a random quadratic form in \(n\) variables defined over the ring \(R\) satisfying a list of boolean (i.e. True/False) conditions.
The conditions \(c\) appearing in the list must be boolean functions which can be called either as
Q.c()
orc(Q)
, whereQ
is the random quadratic form.The last (and optional) argument
rand_arg_list
is a list of at most 3 elements which is passed (as at most 3 separate variables) into the methodR.random_element()
.EXAMPLES:
sage: check = QuadraticForm.is_positive_definite sage: Q = random_quadraticform_with_conditions(ZZ, 3, [check], [-5, 5]) sage: Q # random Quadratic form in 3 variables over Integer Ring with coefficients: [ 3 -2 -5 ] [ * 2 2 ] [ * * 3 ]
- sage.quadratic_forms.random_quadraticform.random_ternaryqf(rand_arg_list=[])#
Create a random ternary quadratic form.
The last (and optional) argument
rand_arg_list
is a list of at most 3 elements which is passed (as at most 3 separate variables) into the methodR.random_element()
.INPUT:
rand_arg_list
– a list of at most 3 arguments which can be taken byR.random_element()
.
OUTPUT:
A ternary quadratic form.
EXAMPLES:
sage: random_ternaryqf() # random Ternary quadratic form with integer coefficients: [1 1 4] [-1 1 -1] sage: random_ternaryqf([-1, 2]) # random Ternary quadratic form with integer coefficients: [1 0 1] [-1 -1 -1] sage: random_ternaryqf([-10, 10, "uniform"]) # random Ternary quadratic form with integer coefficients: [7 -8 2] [0 3 -6]
- sage.quadratic_forms.random_quadraticform.random_ternaryqf_with_conditions(condition_list=[], rand_arg_list=[])#
Create a random ternary quadratic form satisfying a list of boolean (i.e. True/False) conditions.
The conditions \(c\) appearing in the list must be boolean functions which can be called either as
Q.c()
orc(Q)
, whereQ
is the random ternary quadratic form.The last (and optional) argument
rand_arg_list
is a list of at most 3 elements which is passed (as at most 3 separate variables) into the methodR.random_element()
.EXAMPLES:
sage: check = TernaryQF.is_positive_definite sage: Q = random_ternaryqf_with_conditions([check], [-5, 5]) sage: Q # random Ternary quadratic form with integer coefficients: [3 4 2] [2 -2 -1]