Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/ci-meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
export CC="ccache $CC"
export CXX="ccache $CXX"
export CFLAGS+=" -Werror=discarded-qualifiers" # discarded-qualifiers is not valid for C++
echo "CFLAGS=$CFLAGS"
echo "CXXFLAGS=$CXXFLAGS"
else
export LIB="$LIB;$CONDA_PREFIX\\Library\\lib"
export INCLUDE="$INCLUDE;$CONDA_PREFIX\\Library\\include"
Expand Down
4 changes: 2 additions & 2 deletions src/sage/arith/rational_reconstruction.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from sage.libs.gmp.types cimport mpz_t, mpq_t
from sage.libs.gmp.types cimport mpz_srcptr, mpq_t

cdef int mpq_rational_reconstruction(mpq_t answer, mpz_t a, mpz_t m) except -1
cdef int mpq_rational_reconstruction(mpq_t answer, mpz_srcptr a, mpz_srcptr m) except -1
2 changes: 1 addition & 1 deletion src/sage/arith/rational_reconstruction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ from sage.libs.gmp.mpz cimport *
from sage.libs.gmp.mpq cimport *


cdef int mpq_rational_reconstruction(mpq_t answer, mpz_t a, mpz_t m) except -1:
cdef int mpq_rational_reconstruction(mpq_t answer, mpz_srcptr a, mpz_srcptr m) except -1:
"""
Set ``answer`` to a rational number which is `a` modulo `m` and
such that the numerator and denominator of the result is bounded by
Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/integration.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def monte_carlo_integral(func, xl, xu, size_t calls, algorithm='plain',
cdef gsl_monte_plain_state* state_plain = NULL
cdef gsl_monte_miser_state* state_miser = NULL
cdef gsl_monte_vegas_state* state_vegas = NULL
cdef gsl_rng_type *type_rng
cdef const gsl_rng_type *type_rng
cdef gsl_rng *_rng
cdef size_t dim
cdef double *_xl
Expand Down
4 changes: 2 additions & 2 deletions src/sage/calculus/ode.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cdef class ode_system:
cdef int c_j(self, double , double *, double *, double *) noexcept
cdef int c_j(self, double , const double *, double *, double *) noexcept

cdef int c_f(self, double t, double* , double*) noexcept
cdef int c_f(self, double t, const double* , double*) noexcept
55 changes: 26 additions & 29 deletions src/sage/calculus/ode.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
self.y_n = x

cdef class ode_system:
cdef int c_j(self, double t, double *y, double *dfdy, double *dfdt) noexcept:
cdef int c_j(self, double t, const double *y, double *dfdy, double *dfdt) noexcept:
return 0

cdef int c_f(self, double t, double* y, double* dydt) noexcept:
cdef int c_f(self, double t, const double* y, double* dydt) noexcept:
return 0

cdef int c_jac_compiled(double t, const double *y, double *dfdy, double *dfdt, void *params) noexcept:
Expand Down Expand Up @@ -303,35 +303,32 @@
is slow on systems that require many function evaluations. It
is possible to pass a compiled function by deriving from the
class :class:`ode_system` and overloading ``c_f`` and ``c_j`` with C
functions that specify the system. The following will work in the
notebook:

.. code-block:: cython

%cython
cimport sage.calculus.ode
import sage.calculus.ode
from sage.libs.gsl.all cimport *

cdef class van_der_pol(sage.calculus.ode.ode_system):
cdef int c_f(self, double t, double *y, double *dydt):
dydt[0]=y[1]
dydt[1]=-y[0]-1000*y[1]*(y[0]*y[0]-1)
return GSL_SUCCESS
cdef int c_j(self, double t, double *y, double *dfdy, double *dfdt):
dfdy[0]=0
dfdy[1]=1.0
dfdy[2]=-2.0*1000*y[0]*y[1]-1.0
dfdy[3]=-1000*(y[0]*y[0]-1.0)
dfdt[0]=0
dfdt[1]=0
return GSL_SUCCESS
functions that specify the system. (You can also use the ``%%cython``
cell magic, see :meth:`~sage.repl.ipython_extension.SageMagics.cython`.) ::

sage: cython('''

Check warning on line 309 in src/sage/calculus/ode.pyx

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.13, all)

Warning: slow doctest:

slow doctest:: Test ran for 6.60s cpu, 10.82s wall Check ran for 0.00s cpu, 0.00s wall
....: cimport sage.calculus.ode
....: import sage.calculus.ode
....: from sage.libs.gsl.all cimport *
....:
....: cdef class van_der_pol(sage.calculus.ode.ode_system):
....: cdef int c_f(self, double t, const double *y, double *dydt) noexcept:
....: dydt[0]=y[1]
....: dydt[1]=-y[0]-1000*y[1]*(y[0]*y[0]-1)
....: return GSL_SUCCESS
....: cdef int c_j(self, double t, const double *y, double *dfdy, double *dfdt) noexcept:
....: dfdy[0]=0
....: dfdy[1]=1.0
....: dfdy[2]=-2.0*1000*y[0]*y[1]-1.0
....: dfdy[3]=-1000*(y[0]*y[0]-1.0)
....: dfdt[0]=0
....: dfdt[1]=0
....: return GSL_SUCCESS
....: ''')

After executing the above block of code you can do the
following (WARNING: the following is *not* automatically
doctested)::
following::

sage: # not tested
sage: T = ode_solver()
sage: T.algorithm = "bsimp"
sage: vander = van_der_pol()
Expand Down Expand Up @@ -455,7 +452,7 @@
raise MemoryError("error allocating memory")
result = []
v = [0] * dim
cdef gsl_odeiv_step_type * T
cdef const gsl_odeiv_step_type * T

for i in range(dim): # copy initial conditions into C array
y[i] = self.y_0[i]
Expand Down
128 changes: 64 additions & 64 deletions src/sage/libs/gsl/rng.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,73 @@
from sage.libs.gsl.types cimport *

cdef extern from "gsl/gsl_rng.h":
cdef gsl_rng_type *gsl_rng_borosh13
cdef gsl_rng_type *gsl_rng_coveyou
cdef gsl_rng_type *gsl_rng_cmrg
cdef gsl_rng_type *gsl_rng_fishman18
cdef gsl_rng_type *gsl_rng_fishman20
cdef gsl_rng_type *gsl_rng_fishman2x
cdef gsl_rng_type *gsl_rng_gfsr4
cdef gsl_rng_type *gsl_rng_knuthran
cdef gsl_rng_type *gsl_rng_knuthran2
cdef gsl_rng_type *gsl_rng_lecuyer21
cdef gsl_rng_type *gsl_rng_minstd
cdef gsl_rng_type *gsl_rng_mrg
cdef gsl_rng_type *gsl_rng_mt19937
cdef gsl_rng_type *gsl_rng_mt19937_1999
cdef gsl_rng_type *gsl_rng_mt19937_1998
cdef gsl_rng_type *gsl_rng_r250
cdef gsl_rng_type *gsl_rng_ran0
cdef gsl_rng_type *gsl_rng_ran1
cdef gsl_rng_type *gsl_rng_ran2
cdef gsl_rng_type *gsl_rng_ran3
cdef gsl_rng_type *gsl_rng_rand
cdef gsl_rng_type *gsl_rng_rand48
cdef gsl_rng_type *gsl_rng_random128_bsd
cdef gsl_rng_type *gsl_rng_random128_glibc2
cdef gsl_rng_type *gsl_rng_random128_libc5
cdef gsl_rng_type *gsl_rng_random256_bsd
cdef gsl_rng_type *gsl_rng_random256_glibc2
cdef gsl_rng_type *gsl_rng_random256_libc5
cdef gsl_rng_type *gsl_rng_random32_bsd
cdef gsl_rng_type *gsl_rng_random32_glibc2
cdef gsl_rng_type *gsl_rng_random32_libc5
cdef gsl_rng_type *gsl_rng_random64_bsd
cdef gsl_rng_type *gsl_rng_random64_glibc2
cdef gsl_rng_type *gsl_rng_random64_libc5
cdef gsl_rng_type *gsl_rng_random8_bsd
cdef gsl_rng_type *gsl_rng_random8_glibc2
cdef gsl_rng_type *gsl_rng_random8_libc5
cdef gsl_rng_type *gsl_rng_random_bsd
cdef gsl_rng_type *gsl_rng_random_glibc2
cdef gsl_rng_type *gsl_rng_random_libc5
cdef gsl_rng_type *gsl_rng_randu
cdef gsl_rng_type *gsl_rng_ranf
cdef gsl_rng_type *gsl_rng_ranlux
cdef gsl_rng_type *gsl_rng_ranlux389
cdef gsl_rng_type *gsl_rng_ranlxd1
cdef gsl_rng_type *gsl_rng_ranlxd2
cdef gsl_rng_type *gsl_rng_ranlxs0
cdef gsl_rng_type *gsl_rng_ranlxs1
cdef gsl_rng_type *gsl_rng_ranlxs2
cdef gsl_rng_type *gsl_rng_ranmar
cdef gsl_rng_type *gsl_rng_slatec
cdef gsl_rng_type *gsl_rng_taus
cdef gsl_rng_type *gsl_rng_taus2
cdef gsl_rng_type *gsl_rng_taus113
cdef gsl_rng_type *gsl_rng_transputer
cdef gsl_rng_type *gsl_rng_tt800
cdef gsl_rng_type *gsl_rng_uni
cdef gsl_rng_type *gsl_rng_uni32
cdef gsl_rng_type *gsl_rng_vax
cdef gsl_rng_type *gsl_rng_waterman14
cdef gsl_rng_type *gsl_rng_zuf
cdef const gsl_rng_type *gsl_rng_borosh13
cdef const gsl_rng_type *gsl_rng_coveyou
cdef const gsl_rng_type *gsl_rng_cmrg
cdef const gsl_rng_type *gsl_rng_fishman18
cdef const gsl_rng_type *gsl_rng_fishman20
cdef const gsl_rng_type *gsl_rng_fishman2x
cdef const gsl_rng_type *gsl_rng_gfsr4
cdef const gsl_rng_type *gsl_rng_knuthran
cdef const gsl_rng_type *gsl_rng_knuthran2
cdef const gsl_rng_type *gsl_rng_lecuyer21
cdef const gsl_rng_type *gsl_rng_minstd
cdef const gsl_rng_type *gsl_rng_mrg
cdef const gsl_rng_type *gsl_rng_mt19937
cdef const gsl_rng_type *gsl_rng_mt19937_1999
cdef const gsl_rng_type *gsl_rng_mt19937_1998
cdef const gsl_rng_type *gsl_rng_r250
cdef const gsl_rng_type *gsl_rng_ran0
cdef const gsl_rng_type *gsl_rng_ran1
cdef const gsl_rng_type *gsl_rng_ran2
cdef const gsl_rng_type *gsl_rng_ran3
cdef const gsl_rng_type *gsl_rng_rand
cdef const gsl_rng_type *gsl_rng_rand48
cdef const gsl_rng_type *gsl_rng_random128_bsd
cdef const gsl_rng_type *gsl_rng_random128_glibc2
cdef const gsl_rng_type *gsl_rng_random128_libc5
cdef const gsl_rng_type *gsl_rng_random256_bsd
cdef const gsl_rng_type *gsl_rng_random256_glibc2
cdef const gsl_rng_type *gsl_rng_random256_libc5
cdef const gsl_rng_type *gsl_rng_random32_bsd
cdef const gsl_rng_type *gsl_rng_random32_glibc2
cdef const gsl_rng_type *gsl_rng_random32_libc5
cdef const gsl_rng_type *gsl_rng_random64_bsd
cdef const gsl_rng_type *gsl_rng_random64_glibc2
cdef const gsl_rng_type *gsl_rng_random64_libc5
cdef const gsl_rng_type *gsl_rng_random8_bsd
cdef const gsl_rng_type *gsl_rng_random8_glibc2
cdef const gsl_rng_type *gsl_rng_random8_libc5
cdef const gsl_rng_type *gsl_rng_random_bsd
cdef const gsl_rng_type *gsl_rng_random_glibc2
cdef const gsl_rng_type *gsl_rng_random_libc5
cdef const gsl_rng_type *gsl_rng_randu
cdef const gsl_rng_type *gsl_rng_ranf
cdef const gsl_rng_type *gsl_rng_ranlux
cdef const gsl_rng_type *gsl_rng_ranlux389
cdef const gsl_rng_type *gsl_rng_ranlxd1
cdef const gsl_rng_type *gsl_rng_ranlxd2
cdef const gsl_rng_type *gsl_rng_ranlxs0
cdef const gsl_rng_type *gsl_rng_ranlxs1
cdef const gsl_rng_type *gsl_rng_ranlxs2
cdef const gsl_rng_type *gsl_rng_ranmar
cdef const gsl_rng_type *gsl_rng_slatec
cdef const gsl_rng_type *gsl_rng_taus
cdef const gsl_rng_type *gsl_rng_taus2
cdef const gsl_rng_type *gsl_rng_taus113
cdef const gsl_rng_type *gsl_rng_transputer
cdef const gsl_rng_type *gsl_rng_tt800
cdef const gsl_rng_type *gsl_rng_uni
cdef const gsl_rng_type *gsl_rng_uni32
cdef const gsl_rng_type *gsl_rng_vax
cdef const gsl_rng_type *gsl_rng_waterman14
cdef const gsl_rng_type *gsl_rng_zuf


cdef gsl_rng_type *gsl_rng_default
cdef const gsl_rng_type *gsl_rng_default
unsigned long int gsl_rng_default_seed

gsl_rng *gsl_rng_alloc ( gsl_rng_type * T)
gsl_rng *gsl_rng_alloc ( const gsl_rng_type * T)
int gsl_rng_memcpy (gsl_rng * dest, gsl_rng * src)
gsl_rng *gsl_rng_clone ( gsl_rng * r)

Expand All @@ -89,7 +89,7 @@ cdef extern from "gsl/gsl_rng.h":

void gsl_rng_print_state ( gsl_rng * r)

gsl_rng_type * gsl_rng_env_setup ()
const gsl_rng_type * gsl_rng_env_setup ()

unsigned long int gsl_rng_get ( gsl_rng * r)
double gsl_rng_uniform ( gsl_rng * r)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/pari/convert_gmp.pxd
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from cypari2.types cimport GEN
from cypari2.gen cimport Gen
from sage.libs.gmp.types cimport mpz_t, mpq_t, mpz_ptr, mpq_ptr
from sage.libs.gmp.types cimport mpz_srcptr, mpq_t, mpz_ptr, mpq_ptr

cdef Gen new_gen_from_mpz_t(mpz_t value)
cdef GEN _new_GEN_from_mpz_t(mpz_t value) noexcept
cdef Gen new_gen_from_mpz_t(mpz_srcptr value)
cdef GEN _new_GEN_from_mpz_t(mpz_srcptr value) noexcept
cdef Gen new_gen_from_mpq_t(mpq_t value)
cdef GEN _new_GEN_from_mpq_t(mpq_t value) noexcept
cdef Gen new_gen_from_padic(long ordp, long relprec, mpz_t prime, mpz_t p_pow, mpz_t unit)
cdef Gen new_gen_from_padic(long ordp, long relprec, mpz_srcptr prime, mpz_srcptr p_pow, mpz_srcptr unit)
cdef GEN _new_GEN_from_mpq_t_matrix(mpq_t** B, long nr, long nc) noexcept
cdef Gen rational_matrix(mpq_t** B, long nr, long nc)
cdef void INT_to_mpz(mpz_ptr value, GEN g) noexcept
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/pari/convert_gmp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from sage.libs.gmp.all cimport *
from cypari2.paridecl cimport *
from cypari2.stack cimport new_gen

cdef Gen new_gen_from_mpz_t(mpz_t value):
cdef Gen new_gen_from_mpz_t(mpz_srcptr value):
"""
Create a new PARI Gen of type ``t_INT`` from a given
GMP integer ``value``.
Expand All @@ -53,9 +53,9 @@ cdef Gen new_gen_from_mpz_t(mpz_t value):
return new_gen(_new_GEN_from_mpz_t(value))


cdef inline GEN _new_GEN_from_mpz_t(mpz_t value) noexcept:
cdef inline GEN _new_GEN_from_mpz_t(mpz_srcptr value) noexcept:
r"""
Create a new PARI ``t_INT`` from a ``mpz_t``.
Create a new PARI ``t_INT`` from a ``mpz_srcptr``.

For internal use only; this directly uses the PARI stack.
One should call ``sig_on()`` before and ``sig_off()`` after.
Expand Down Expand Up @@ -121,7 +121,7 @@ cdef inline GEN _new_GEN_from_mpq_t(mpq_t value) noexcept:


cdef Gen new_gen_from_padic(long ordp, long relprec,
mpz_t prime, mpz_t p_pow, mpz_t unit):
mpz_srcptr prime, mpz_srcptr p_pow, mpz_srcptr unit):
"""
Create a new PARI Gen of type ``t_PADIC`` from the given input data
as GMP integers.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ def compile_and_load(code, **kwds):
r"""
INPUT:
- ``code`` -- string containing code that could be in a .pyx file
that is attached or put in a %cython block in the notebook
- ``code`` -- string containing code that could be in a ``.pyx`` file
that is attached or put in a ``%%cython`` block
See the function :func:`sage.misc.cython.cython` for documentation
for the other inputs.
Expand Down
6 changes: 3 additions & 3 deletions src/sage/probability/probability_distribution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ cdef class SphericalDistribution(ProbabilityDistribution):
"""

cdef gsl_rng *r
cdef gsl_rng_type *T
cdef const gsl_rng_type *T
cdef long int seed
cdef Py_ssize_t dimension
cdef double* vec
Expand Down Expand Up @@ -571,7 +571,7 @@ cdef class RealDistribution(ProbabilityDistribution):
sage: len(set(Xs)) > 2^^32
True
"""
cdef gsl_rng_type *T
cdef const gsl_rng_type *T
cdef gsl_rng *r
cdef int distribution_type
cdef double* parameters
Expand Down Expand Up @@ -1097,7 +1097,7 @@ cdef class GeneralDiscreteDistribution(ProbabilityDistribution):
...
ValueError: The distribution probabilities must be nonnegative
"""
cdef gsl_rng_type * T
cdef const gsl_rng_type * T
cdef gsl_rng * r
cdef gsl_ran_discrete_t *dist
cdef long seed
Expand Down
Loading