Skip to content

Commit

Permalink
Merge pull request #1707 from albinahlback/fmpz_lll_codecov
Browse files Browse the repository at this point in the history
Fmpz lll codecov
  • Loading branch information
albinahlback authored Jan 9, 2024
2 parents 5c61d46 + 5415b4f commit 74b0bc9
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 315 deletions.
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -911,3 +911,4 @@ print-%:
@echo "$*=$($*)"

.PHONY: all library shared static examples checkexamples profile tests check tune valgrind clean distclean install uninstall dist %_TEST_RUN %_VALGRIND_RUN print-% coverage coverage_html
.SILENT: $(mpn_extras_S_SOURCES)
4 changes: 4 additions & 0 deletions doc/source/fmpz_lll.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ Modified ULLL

Performs ULLL using :func:`fmpz_mat_lll_storjohann` as the LLL function.

.. note::

This function is currently not tested. Use at your own risk.


Main LLL functions
--------------------------------------------------------------------------------
Expand Down
87 changes: 21 additions & 66 deletions src/fmpz_lll/is_reduced_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ int
fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
{
#if HAVE_FENV_H
d_mat_t A, R, V, Wu, Wd, bound;
double * du, * dd;
int rounding_direction = fegetround();

if (fl->rt == Z_BASIS)
{
/* NOTE: this algorithm should *not* be changed */
slong i, j, k, m, n;
d_mat_t A, Q, R, V, Wu, Wd, bound, bound2, bound3, boundt, mm, rm, mn,
rn, absR;
double *du, *dd;
d_mat_t Q, bound2, bound3, boundt, mm, rm, mn, rn, absR;
double s, norm = 0, ti, tj;
int rounding_direction = fegetround();

if (B->r == 0 || B->r == 1)
return 1;
Expand All @@ -53,11 +54,8 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)

if (fmpz_mat_get_d_mat_transpose(A, B) == -1)
{
d_mat_clear(A);
d_mat_clear(Q);
d_mat_clear(R);
d_mat_clear(V);
return 0;
goto fail_clear_A_R_V;
}

for (k = 0; k < n; k++)
Expand Down Expand Up @@ -141,17 +139,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
norm = FLINT_MAX(norm, s);
}
if (!(norm < 1))
{
d_mat_clear(A);
d_mat_clear(R);
d_mat_clear(V);
d_mat_clear(Wu);
d_mat_clear(Wd);
_d_vec_clear(du);
_d_vec_clear(dd);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_all;

d_mat_init(bound, n, n);

Expand Down Expand Up @@ -391,12 +379,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
norm = FLINT_MAX(norm, s);
}
if (!(norm < 1))
{
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_R_bound_rounding_direction;

d_mat_init(absR, n, n);
for (i = 0; i < n; i++)
Expand Down Expand Up @@ -427,12 +410,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
{
tj = fabs(d_mat_entry(R, i, j)) + d_mat_entry(bound, i, j);
if (!(tj <= ti))
{
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_R_bound_rounding_direction;
}
ti = d_mat_entry(R, i, i) + d_mat_entry(bound, i, i);
fesetround(FE_DOWNWARD);
Expand All @@ -449,12 +427,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
fesetround(FE_UPWARD);
s = sqrt(s) * ti;
if (!(s <= tj))
{
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_R_bound_rounding_direction;
}

d_mat_clear(R);
Expand All @@ -465,11 +438,8 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
{
/* NOTE: this algorithm should *not* be changed */
slong i, j, k, m, n;
d_mat_t A, R, V, Wu, Wd, bound, bound2, bound3, boundt, mm, rm, mn,
rn, absR;
double *du, *dd;
d_mat_t bound2, bound3, boundt, mm, rm, mn, rn, absR;
double s, norm = 0, ti, tj;
int rounding_direction = fegetround();

if (B->r == 0 || B->r == 1)
return 1;
Expand All @@ -484,12 +454,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
d_mat_zero(V);

if (fmpz_mat_get_d_mat_transpose(A, B) == -1)
{
d_mat_clear(A);
d_mat_clear(R);
d_mat_clear(V);
return 0;
}
goto fail_clear_A_R_V;

for (j = 0; j < n; j++)
{
Expand All @@ -513,10 +478,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
if (!(d_mat_entry(R, j, j) > 0))
{
/* going to take sqrt and then divide by it */
d_mat_clear(A);
d_mat_clear(R);
d_mat_clear(V);
return 0;
goto fail_clear_A_R_V;
}

d_mat_entry(R, j, j) = sqrt(d_mat_entry(R, j, j));
Expand Down Expand Up @@ -568,14 +530,16 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
}
if (!(norm < 1))
{
d_mat_clear(A);
d_mat_clear(R);
d_mat_clear(V);
fail_clear_all:
d_mat_clear(Wu);
d_mat_clear(Wd);
_d_vec_clear(du);
_d_vec_clear(dd);
fesetround(rounding_direction);
fail_clear_A_R_V:
d_mat_clear(A);
d_mat_clear(R);
d_mat_clear(V);
return 0;
}

Expand Down Expand Up @@ -789,12 +753,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
norm = FLINT_MAX(norm, s);
}
if (!(norm < 1))
{
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_R_bound_rounding_direction;

d_mat_init(absR, n, n);
for (i = 0; i < n; i++)
Expand Down Expand Up @@ -825,12 +784,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
{
tj = fabs(d_mat_entry(R, i, j)) + d_mat_entry(bound, i, j);
if (!(tj <= ti))
{
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
return 0;
}
goto fail_clear_R_bound_rounding_direction;
}
ti = d_mat_entry(R, i, i) + d_mat_entry(bound, i, i);
fesetround(FE_DOWNWARD);
Expand All @@ -848,6 +802,7 @@ fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl)
s = sqrt(s) * ti;
if (!(s <= tj))
{
fail_clear_R_bound_rounding_direction:
d_mat_clear(R);
d_mat_clear(bound);
fesetround(rounding_direction);
Expand Down
Loading

0 comments on commit 74b0bc9

Please sign in to comment.