Commit 03200890 authored by Peter Bruin's avatar Peter Bruin

new function curve_random_section

parent b57f2441
......@@ -437,6 +437,13 @@ curve_divide_subspaces (GEN X, GEN Z, unsigned long i_Z,
return gerepileupto(av, matsmall_mul(V, matsmall_ker(R, p, T), p, T));
}
GEN
curve_random_section(GEN X, GEN W_D) {
unsigned long p = curve_base_field_characteristic(X);
GEN T = curve_base_field_polynomial(X);
return gel(matsmall_random_subspace(W_D, 1, 1, p, T), 1);
}
/*** Morphisms ***/
......
......@@ -64,6 +64,7 @@ GEN curve_multiply_subspaces (GEN X, GEN V, GEN W);
GEN curve_multiply_subspaces_dim(GEN X, GEN V, GEN W, unsigned long dim);
GEN curve_divide_subspaces (GEN X, GEN Z, unsigned long i_Z,
GEN W, unsigned long i_W);
GEN curve_random_section(GEN X, GEN W_D);
GEN numzeta_base_change (GEN z, int n);
GEN curve_base_change (GEN X, GEN ext);
......
......@@ -187,13 +187,13 @@ curve_divisor_algebra (GEN X, GEN W_D, GEN W_2_D,
long deg_D = lg(V) - lg(W_D), i;
int done = 0;
while (1) {
s = gel(matsmall_random_subspace(V, 1, 1, p, T), 1);
s = curve_random_section(X, V);
M = curve_divisor_section_as_matrix(X, s, V, V_2, Q, Q_2);
if (matsmall_rank(M, p, T) == deg_D)
break;
}
while (!done) {
t = gel(matsmall_random_subspace(V, 1, 1, p, T), 1);
t = curve_random_section(X, V);
N = curve_divisor_section_as_matrix(X, t, V, V_2, Q, Q_2);
A = matsmall_solve(M, N, p, T);
algebra = matsmall_charpoly(A, 0, p, T);
......@@ -334,8 +334,6 @@ curve_decompose_divisor (GEN X, GEN W_D, GEN W_2_D,
*/
GEN
curve_random_prime_divisor (GEN X, unsigned long n, unsigned long d) {
unsigned long p = curve_base_field_characteristic (X);
GEN T = curve_base_field_polynomial (X);
pari_sp av = avma;
GEN P = NULL;
......@@ -359,7 +357,7 @@ curve_random_prime_divisor (GEN X, unsigned long n, unsigned long d) {
avma = av;
/* Generate a random hypersurface section D of degree i. */
s = gel(matsmall_random_subspace(curve_V(X, i), 1, 1, p, T), 1);
s = curve_random_section(X, curve_V(X, i));
/*
Compute the subspaces W_D and W_2_D of
V_{i + 1} and V_{2i + 2}, respectively.
......@@ -567,8 +565,6 @@ curve_random_smooth_divisor (GEN X, unsigned long n,
*/
GEN
curve_random_divisor_fast (GEN X, unsigned long n, unsigned long d) {
unsigned long p = curve_base_field_characteristic (X);
GEN T = curve_base_field_polynomial (X);
GEN V = curve_V (X, d);
GEN IGS_V = (d <= curve_max_IGS_V (X)) ? curve_IGS_V (X, d) : V;
pari_sp av = avma;
......@@ -595,7 +591,7 @@ curve_random_divisor_fast (GEN X, unsigned long n, unsigned long d) {
while (1) {
/* Generate a random hypersurface section H of degree i. */
GEN s = gel(matsmall_random_subspace(curve_V(X, i), 1, 1, p, T), 1);
GEN s = curve_random_section(X, curve_V(X, i));
/*
Compute the subspaces W_H and W_2_H of
V_{d + 1} and V_{2d + 2}, respectively.
......
......@@ -169,13 +169,11 @@ jacobian_flip (GEN X, GEN W_D, GEN s) {
*/
GEN
jacobian_random_presentation(GEN X, GEN W_D) {
unsigned long p = curve_base_field_characteristic (X);
GEN T = curve_base_field_polynomial (X);
GEN s;
int i;
pari_sp av = avma;
for(i = 0; i < 2; i++) {
s = gel(matsmall_random_subspace(W_D, 1, 1, p, T), 1);
s = curve_random_section(X, W_D);
W_D = jacobian_flip(X, W_D, s);
}
return gerepileupto(av, W_D);
......
......@@ -46,7 +46,7 @@ norm_functor_linearity(GEN X, long i, long j,
Q_i_j_4_D1_D2 = matsmall_quotient(W_i_j_4_D1_D2, W_i_j_4_D1_D2_E, p, T);
do {
beta0 = gel(matsmall_random_subspace(V_2, 1, 1, p, T), 1);
beta0 = curve_random_section(X, V_2);
delta0 = norm_of_section(X, beta0, W_j_2_D2, W_j_4_D2,
Q_j_2_D2, Q_j_4_D2);
} while (gequal0(delta0));
......@@ -54,7 +54,7 @@ norm_functor_linearity(GEN X, long i, long j,
Q_i_j_2_D1_D2, Q_i_j_4_D1_D2);
do {
beta2 = gel(matsmall_random_subspace(W_j_2_D2, 1, 1, p, T), 1);
beta2 = curve_random_section(X, W_j_2_D2);
delta2 = norm_of_section(X, beta2, V_2, W_j_4_D2,
Q_2, Q_j_4_D2);
} while (gequal0(delta2));
......@@ -293,8 +293,6 @@ divisors_disjoint(GEN J, GEN W_D, GEN W_E) {
GEN
jacobian_weil_pairing(GEN J, GEN W_D, GEN W_E, long n) {
unsigned long p = curve_base_field_characteristic(J);
GEN T = curve_base_field_polynomial(J);
GEN c, W, Z, u_D, u_E, f_E, g_D;
pari_sp av = avma;
......@@ -307,11 +305,11 @@ jacobian_weil_pairing(GEN J, GEN W_D, GEN W_E, long n) {
W_E = jacobian_random_presentation(J, W_E);
do {
u_D = gel(matsmall_random_subspace(curve_V(J, 1), 1, 1, p, T), 1);
u_D = curve_random_section(J, curve_V(J, 1));
W = curve_multiply_section_subspace(J, u_D, curve_V(J, 1));
} while (!divisors_disjoint(J, W, W_E));
do {
u_E = gel(matsmall_random_subspace(curve_V(J, 1), 1, 1, p, T), 1);
u_E = curve_random_section(J, curve_V(J, 1));
Z = curve_multiply_section_subspace(J, u_E, curve_V(J, 1));
} while (!divisors_disjoint(J, Z, W_D)
|| !divisors_disjoint(J, W, Z));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment