Skip to content

Commit 39a31ca

Browse files
committed
Fix SafeLeftDivide for rank-0 module inputs
Singular.lift misbehaves when A has 0 rows or B has 0 columns, returning matrices with wrong shapes. Add early returns: - nrows(A)==0: system has 0 equations, trivial solution X = 0_{c×s} - ncols(B)==0: RHS is empty, solution must also be empty X = 0_{c×0} In both cases X = zero_matrix(R, ncols(A), ncols(B)). Bump version to v0.1.11
1 parent 7077a58 commit 39a31ca

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MatricesForHomalg"
22
uuid = "29b9b1b6-efa6-450e-8188-a5a2c25df071"
3-
version = "0.1.10"
3+
version = "0.1.11"
44
authors = ["Mohamed Barakat <mohamed.barakat@uni-siegen.de>", "Johanna Knecht <johanna.knecht@student.uni-siegen.de>"]
55

66
[deps]

ext/MatricesForHomalgSingularExt.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,14 @@ julia> SafeLeftDivide(A, B)
10471047
```
10481048
"""
10491049
function MatricesForHomalg.SafeLeftDivide(A::Singular.smatrix, B::Singular.smatrix)
1050+
R = Singular.base_ring(A)
1051+
# Singular.lift misbehaves for rank-0 modules (0-row A or 0-column B).
1052+
# If A has 0 rows: system A*X=B has 0 equations → trivial solution X=0
1053+
# If B has 0 cols: system A*X=B with B empty → solution X must also be empty
1054+
# In both cases X has shape ncols(A) × ncols(B).
1055+
if Singular.nrows(A) == 0 || Singular.ncols(B) == 0
1056+
return Singular.zero_matrix(R, Singular.ncols(A), Singular.ncols(B))
1057+
end
10501058
M_A = Singular.Module(A)
10511059
M_B = Singular.Module(B)
10521060
T, rest = Singular.lift(M_A, M_B)

0 commit comments

Comments
 (0)