Utility functions for numpy. - Modules

Skip to content
Back to top
View this page
Edit this page

# Utility functions for numpy.

sage.modules.numpy_util.set_matrix_mod2_from_numpy(a, b)

  Try to set the entries of a matrix from a numpy array.

  INPUT:

  - `a` – the destination matrix

  - `b` – a numpy array, must have dimension 2 and the same shape as `a`

  OUTPUT: `True` (when used as bool) if successful, `False` otherwise. May throw `ValueError`.

  The exact type of the return value is not guaranteed, in the actual current implementation it is `1` for success and `0` for failure.

sage.modules.numpy_util.set_mzd_from_numpy(entries_addr, degree, x)

  Set the entries in `<mzd_t*>entries_addr` from numpy array `x`.

  INPUT:

  - `entries_addr` – must be a `mzd_t*` casted to `uintptr_t`; the casting is necessary to pass it through Python boundary because of lazy import. Do not pass arbitrary integer value here, will crash the program.

  - `degree` – the length of the array

  - `x` – a numpy array of integers or booleans, or any other object (in which case this function will return `False`)

  OUTPUT: `True` if successful, `False` otherwise. May throw `ValueError`.