This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sage.modules.vector_numpy_integer_dense: New
- Loading branch information
Matthias Koeppe
committed
Oct 12, 2021
1 parent
2ffb118
commit 5b288c3
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |