Skip to content

Commit

Permalink
Merge pull request #1891 from albinahlback/reenable_workflows
Browse files Browse the repository at this point in the history
Reenable workflows
  • Loading branch information
albinahlback committed Mar 25, 2024
2 parents ccd724b + 8e0780b commit 31bf7d3
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 29 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:

env:
GLOBAL_MULTIPLIER: 0.1
GLOBAL_MULTIPLIER: 1

concurrency:
# group by workflow and ref; the last slightly strange component ensures that for pull
Expand Down Expand Up @@ -262,8 +262,6 @@ jobs:
env:
FLINT_TEST_MULTIPLIER: "2"

if: false # temporary disabled

steps:
- name: "Rescale multiplier"
run: |
Expand Down Expand Up @@ -390,23 +388,21 @@ jobs:
CC: "gcc"
FLINT_TEST_MULTIPLIER: "0.5"

if: false # temporary disabled

steps:
- name: "Rescale multiplier"
run: |
FLINT_TEST_MULTIPLIER=$(echo "${FLINT_TEST_MULTIPLIER} * ${GLOBAL_MULTIPLIER}" | bc)
echo "FLINT_TEST_MULTIPLIER=${FLINT_TEST_MULTIPLIER}"
echo "FLINT_TEST_MULTIPLIER=${FLINT_TEST_MULTIPLIER}" >> $GITHUB_ENV
- uses: actions/checkout@v4

- name: "Setup MinGW"
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: true
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-autotools
install: bc mingw-w64-x86_64-gcc mingw-w64-x86_64-autotools

- name: "Rescale multiplier"
run: |
FLINT_TEST_MULTIPLIER=$(echo "${FLINT_TEST_MULTIPLIER} * ${GLOBAL_MULTIPLIER}" | bc)
echo "FLINT_TEST_MULTIPLIER=${FLINT_TEST_MULTIPLIER}"
echo "FLINT_TEST_MULTIPLIER=${FLINT_TEST_MULTIPLIER}" >> $GITHUB_ENV
- name: "Setup"
run: |
Expand Down Expand Up @@ -446,7 +442,7 @@ jobs:
runs-on: windows-latest
env:
FLINT_TEST_MULTIPLIER: 1
TIMEOUT: 450
TIMEOUT: 150

steps:
- name: "Rescale multiplier (powershell)"
Expand Down Expand Up @@ -586,8 +582,6 @@ jobs:
LOCAL: ${{ github.workspace }}/local
CC: "gcc"

if: false # temporarily disabled

steps:
- uses: actions/checkout@v4

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/push_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ jobs:
env:
FLINT_TEST_MULTIPLIER: "0.5"

if: false # temporarily disabled

steps:
- uses: actions/checkout@v4

- name: "Run tests on FreeBSD"
uses: cross-platform-actions/[email protected]
timeout-minutes: 30
timeout-minutes: 15
continue-on-error: true
with:
operating_system: freebsd
Expand Down Expand Up @@ -108,8 +106,6 @@ jobs:

runs-on: windows-latest

if: false # temporarily disabled

defaults:
run:
shell: C:\cygwin64\bin\bash.exe --login -o igncr '{0}'
Expand Down
6 changes: 6 additions & 0 deletions doc/source/ulong_extras.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,12 @@ Factorisation

Initializes factors.

.. function:: ulong n_factor_evaluate(const n_factor_t * factors)

Returns the evaluation of ``factors``,
i.e. `p_{1}^{e_{1}} \cdots p_{n}^{e_{n}}` assuming that it fits in a limb.
In case the evaluation does not fit in a limb, it returns `0`.

.. function:: int n_remove(ulong * n, ulong p)

Removes the highest possible power of `p` from `n`, replacing
Expand Down
2 changes: 1 addition & 1 deletion src/limb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {

typedef struct
{
slong num;
int num;
int exp[FLINT_MAX_FACTORS_IN_LIMB];
ulong p[FLINT_MAX_FACTORS_IN_LIMB];
}
Expand Down
2 changes: 2 additions & 0 deletions src/ulong_extras.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ ulong n_nextprime(ulong n, int FLINT_UNUSED(proved));

ULONG_EXTRAS_INLINE void n_factor_init(n_factor_t * factors) { factors->num = UWORD(0); }

ulong n_factor_evaluate(const n_factor_t * fac);

void n_factor(n_factor_t * factors, ulong n, int proved);

void n_factor_insert(n_factor_t * factors, ulong p, ulong exp);
Expand Down
29 changes: 29 additions & 0 deletions src/ulong_extras/factor_misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright (C) 2024 Albin Ahlbäck
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "ulong_extras.h"

ulong n_factor_evaluate(const n_factor_t * fac)
{
ulong ret = 1;
slong ix;

for (ix = 0; ix < fac->num; ix++)
{
ulong t0, t1;
t0 = _n_pow_check(fac->p[ix], fac->exp[ix]);
umul_ppmm(t1, ret, ret, t0);
if (t1 != 0)
return 0;
}

return ret;
}
2 changes: 2 additions & 0 deletions src/ulong_extras/test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "t-divrem2_preinv.c"
#include "t-euler_phi.c"
#include "t-factor.c"
#include "t-factor_evaluate.c"
#include "t-factor_ecm.c"
#include "t-factorial_fast_mod2_preinv.c"
#include "t-factorial_mod2_preinv.c"
Expand Down Expand Up @@ -128,6 +129,7 @@ test_struct tests[] =
TEST_FUNCTION(n_divrem2_preinv),
TEST_FUNCTION(n_euler_phi),
TEST_FUNCTION(n_factor),
TEST_FUNCTION(n_factor_evaluate),
TEST_FUNCTION(n_factor_ecm),
TEST_FUNCTION(n_factorial_fast_mod2_preinv),
TEST_FUNCTION(n_factorial_mod2_preinv),
Expand Down
11 changes: 4 additions & 7 deletions src/ulong_extras/test/t-factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

TEST_FUNCTION_START(n_factor, state)
{
int i, j, result;
int result;
slong ix;

for (i = 0; i < 1000 * flint_test_multiplier(); i++)
for (ix = 0; ix < 1000 * flint_test_multiplier(); ix++)
{
mp_limb_t n1, n2;
n_factor_t factors;
Expand All @@ -39,11 +40,7 @@ TEST_FUNCTION_START(n_factor, state)

n_factor(&factors, n1, 0);

n2 = UWORD(1);
for (j = 0; j < factors.num; j++)
{
n2 *= n_pow(factors.p[j], factors.exp[j]);
}
n2 = n_factor_evaluate(&factors);

result = (n1 == n2);
if (!result)
Expand Down
68 changes: 68 additions & 0 deletions src/ulong_extras/test/t-factor_evaluate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright (C) 2024 Albin Ahlbäck
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "test_helpers.h"
#include "ulong_extras.h"

TEST_FUNCTION_START(n_factor_evaluate, state)
{
int result;
slong iter;

for (iter = 0; iter < 10000 * flint_test_multiplier(); iter++)
{
ulong eval, fac_eval;
n_factor_t factors;
int type;

n_factor_init(&factors);

type = n_randint(state, 2);

if (type == 0)
{
/* Test random limb */
eval = n_randtest_not_zero(state);
n_factor(&factors, eval, 0);
}
else
{
/* Test factorization whose evaluation cannot fit in a limb */
ulong top;

eval = 1;

do
{
ulong prime = n_randtest_prime(state, 0);
umul_ppmm(top, eval, eval, prime);
n_factor_insert(&factors, prime, 1);
} while (top == UWORD(0));

/* And maybe add extra exponents */
if (n_randint(state, 2))
factors.exp[n_randint(state, factors.num)] += 1 + n_randint(state, 10);

eval = 0; /* n_factor_evaluate should return 0 */
}

fac_eval = n_factor_evaluate(&factors);

result = (eval == fac_eval);
if (!result)
TEST_FUNCTION_FAIL(
"eval = %wu\n"
"fac_eval = %wu\n",
eval, fac_eval);
}

TEST_FUNCTION_END(state);
}
3 changes: 2 additions & 1 deletion src/ulong_extras/test/t-factor_power235.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ TEST_FUNCTION_START(n_factor_power235, state)
for (ix = 0; ix < 3000 * flint_test_multiplier(); ix++)
{
ulong factor, exp, n1, n2, n1pow;
int bits, type;
int bits;
ulong type;

type = n_randint(state, 4);

Expand Down

0 comments on commit 31bf7d3

Please sign in to comment.