Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions src/ca_field/build_ideal_elliptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,32 @@ ca_field_build_elliptic_relation(ca_field_t K, slong i, slong j, slong k, slong
fmpz_mpoly_init(poly, CA_FIELD_MCTX(K, ctx));

slong len = CA_FIELD_LENGTH(K);
ulong exp[len];
for (slong v = 0; v < len; v++){
exp[v] = 0;
ulong* exp = (ulong*) flint_malloc(len * sizeof(ulong));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use (1) alloca or (2) GR_TMP_ALLOC joined with GR_TMP_FREE (see gr.h). No need to use malloc for something small.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now changed it to GR_TMP_ALLOC.

if (exp != NULL){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can always assume that exp != NULL.

for (slong v = 0; v < len; v++){
exp[v] = 0;
}

exp[i] = 1;
exp[l] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, 2, exp, CA_FIELD_MCTX(K, ctx));
exp[i] = 0;
exp[l] = 0;
exp[j] = 1;
exp[k] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, 2, exp, CA_FIELD_MCTX(K, ctx));
exp[k] = 0;
exp[i] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, -2, exp, CA_FIELD_MCTX(K, ctx));
exp[i] = 0;
exp[j] = 0;
exp[pi_index] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, -1, exp, CA_FIELD_MCTX(K, ctx));

_ca_field_ideal_insert_clear_mpoly(K, poly, CA_FIELD_MCTX(K, ctx), ctx);

flint_free(exp);
}

exp[i] = 1;
exp[l] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, 2, exp, CA_FIELD_MCTX(K, ctx));
exp[i] = 0;
exp[l] = 0;
exp[j] = 1;
exp[k] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, 2, exp, CA_FIELD_MCTX(K, ctx));
exp[k] = 0;
exp[i] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, -2, exp, CA_FIELD_MCTX(K, ctx));
exp[i] = 0;
exp[j] = 0;
exp[pi_index] = 1;
fmpz_mpoly_set_coeff_si_ui(poly, -1, exp, CA_FIELD_MCTX(K, ctx));

_ca_field_ideal_insert_clear_mpoly(K, poly, CA_FIELD_MCTX(K, ctx), ctx);
}

ca_clear(t, ctx);
Expand Down