Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.modules.vector_numpy_integer_dense: New
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Oct 12, 2021
1 parent 2ffb118 commit 5b288c3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/sage/modules/vector_numpy_integer_dense.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .vector_numpy_dense cimport Vector_numpy_dense

cdef class Vector_numpy_integer_dense(Vector_numpy_dense):

pass
44 changes: 44 additions & 0 deletions src/sage/modules/vector_numpy_integer_dense.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
r"""
Dense integer vectors using a NumPy backend.
EXAMPLES::
sage: from sage.modules.vector_numpy_integer_dense import Vector_numpy_integer_dense
sage: v = Vector_numpy_integer_dense(FreeModule(ZZ, 3), [0, 0, 0]); v
(0, 0, 0)
sage: v[1] = 42
sage: v
(0, 42, 0)
sage: v.numpy()
array([ 0, 42, 0])
"""

# ****************************************************************************
# Copyright (C) 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

cimport numpy
import numpy

from sage.structure.element cimport Element, Vector

from sage.rings.integer_ring import ZZ

# This is for the NumPy C API (the PyArray... functions) to work
numpy.import_array()


cdef class Vector_numpy_integer_dense(Vector_numpy_dense):

def __cinit__(self, parent, entries, coerce=True, copy=True):
self._numpy_dtype = numpy.dtype('int64')
self._numpy_dtypeint = numpy.NPY_INT64
self._python_dtype = int
self._sage_dtype = ZZ
self.__create_vector__()
return

0 comments on commit 5b288c3

Please sign in to comment.