Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MatrixArgs.element and Update cmr #29

Merged
merged 4 commits into from
Mar 4, 2024
Merged
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
6 changes: 3 additions & 3 deletions build/pkgs/cmr/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=cmr-0+VERSION.tar.gz
sha1=6e55e008de787217fa5b021c693100b98365b311
md5=51844915d4bcd1200a18a46e8ce764f2
cksum=3720610576
sha1=e38b305f32db415f75d6d76b30f9f40e5c116d8f
md5=99db21d9919fd357a16b4a2efa2da0ed
cksum=80832571
upstream_url=https://github.com/discopt/cmr/archive/VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/cmr/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8b0dda14be73d9afc5eeda1461191b2b062072db
33415103202d46b1bd1f4832f83494fbe583bc1b
8 changes: 3 additions & 5 deletions src/sage/libs/cmr/cmr.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,9 @@ cdef extern from "cmr/matroid.h":
int8_t CMRmatroiddecCographicness(CMR_MATROID_DEC* dec)
int8_t CMRmatroiddecRegularity(CMR_MATROID_DEC* dec)
size_t CMRmatroiddecNumRows(CMR_MATROID_DEC* dec)
CMR_ELEMENT* CMRmatroiddecRowsRootElement(CMR_MATROID_DEC* dec)
size_t* CMRmatroiddecRowsParent(CMR_MATROID_DEC* dec)
CMR_ELEMENT* CMRmatroiddecRowsParent(CMR_MATROID_DEC* dec)
size_t CMRmatroiddecNumColumns(CMR_MATROID_DEC* dec)
CMR_ELEMENT* CMRmatroiddecColumnsRootElement(CMR_MATROID_DEC* dec)
size_t* CMRmatroiddecColumnsParent(CMR_MATROID_DEC* dec)
CMR_ELEMENT* CMRmatroiddecColumnsParent(CMR_MATROID_DEC* dec)
CMR_GRAPH* CMRmatroiddecGraph(CMR_MATROID_DEC* dec)
CMR_GRAPH_EDGE* CMRmatroiddecGraphForest(CMR_MATROID_DEC* dec)
size_t CMRmatroiddecGraphSizeForest(CMR_MATROID_DEC* dec)
Expand All @@ -257,7 +255,7 @@ cdef extern from "cmr/matroid.h":
size_t CMRmatroiddecNumPivots(CMR_MATROID_DEC* dec)
size_t* CMRmatroiddecPivotRows(CMR_MATROID_DEC* dec)
size_t* CMRmatroiddecPivotColumns(CMR_MATROID_DEC* dec)
# CMR_ERROR CMRmatroiddecPrint(CMR* cmr, CMR_MATROID_DEC* dec, FILE* stream, size_t indent, bool printChildren, bool printParentRowsColumns, bool printMatrices, bool printGraphs, bool printReductions, bool printPivots)
# CMR_ERROR CMRmatroiddecPrint(CMR* cmr, CMR_MATROID_DEC* dec, FILE* stream, size_t indent, bool printChildren, bool printParentElements, bool printMatrices, bool printGraphs, bool printReductions, bool printPivots)
CMR_ERROR CMRmatroiddecFree(CMR* cmr, CMR_MATROID_DEC** pdec)
CMR_ERROR CMRmatroiddecFreeNode(CMR* cmr, CMR_MATROID_DEC** pdec)

Expand Down
1 change: 1 addition & 0 deletions src/sage/matrix/args.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cdef class MatrixArgs:
cdef bint is_finalized

cpdef Matrix matrix(self, bint convert=?) noexcept
cpdef Matrix element(self, bint immutable=?, bint convert=?) noexcept
cpdef list list(self, bint convert=?) noexcept
cpdef dict dict(self, bint convert=?) noexcept

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/args.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ cdef class MatrixArgs:
self.typ = MA_ENTRIES_MATRIX
return M

cpdef element(self, bint convert=True, bint immutable=False) noexcept:
cpdef Matrix element(self, bint immutable=False, bint convert=True) noexcept:
r"""
Return the element.
"""
Expand Down
12 changes: 10 additions & 2 deletions src/sage/matrix/matrix_cmr_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,11 @@ cdef class Matrix_cmr_chr_sparse(Matrix_cmr_sparse):
first_marker = CMRrowToElement(row)
second_marker = CMRcolumnToElement(column)

cdef int8_t characteristic = 0
cdef int8_t characteristic = first_mat.parent().characteristic()

if second_mat.parent().characteristic() != characteristic:
raise ValueError("The characteristic of two matrices are different")

CMR_CALL(CMRtwoSum(cmr, first._mat, second._mat, first_marker, second_marker, characteristic, &sum_mat))
sum = Matrix_cmr_chr_sparse._from_cmr(sum_mat, immutable=False)
if row_subdivision or column_subdivision:
Expand Down Expand Up @@ -642,7 +646,11 @@ cdef class Matrix_cmr_chr_sparse(Matrix_cmr_sparse):
second_marker1 = CMRcolumnToElement(column1)
second_marker2 = CMRcolumnToElement(column2)

cdef int8_t characteristic = 0
cdef int8_t characteristic = first_mat.parent().characteristic()

if second_mat.parent().characteristic() != characteristic:
raise ValueError("The characteristic of two matrices are different")

CMR_CALL(CMRthreeSum(cmr, first._mat, second._mat, first_marker1, second_marker1, first_marker2, second_marker2, characteristic, &sum_mat))
sum = Matrix_cmr_chr_sparse._from_cmr(sum_mat)
return sum
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/seymour_decomposition.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ cdef class DecompositionNode(SageObject):
sage: C[1].parent_rows_and_columns()
((3, 4, 5), (2, 3))
"""
cdef size_t *parent_rows = CMRmatroiddecRowsParent(self._dec)
cdef size_t *parent_columns = CMRmatroiddecColumnsParent(self._dec)
cdef CMR_ELEMENT *parent_rows = CMRmatroiddecRowsParent(self._dec)
cdef CMR_ELEMENT *parent_columns = CMRmatroiddecColumnsParent(self._dec)
if parent_rows == NULL or parent_rows[0] == SIZE_MAX:
parent_rows_tuple = None
else:
Expand Down
Loading