Skip to content
Open
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: 5 additions & 1 deletion M2/Macaulay2/e/ringmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "matrix-con.hpp"
#include "polyring.hpp"
#include "relem.hpp"
#include "exceptions.hpp"

#include <iostream>
RingMap::RingMap(const Matrix *m) : R(m->get_ring())
Expand Down Expand Up @@ -147,7 +148,10 @@ ring_elem RingMap::eval_term(const Ring *sourceK, // source coeff ring
{
int v = first_var + i.var();
if (v >= nvars || _elem[v].is_zero)
return R->from_long(0); // The result is zero.
{
if (i.exponent() < 0) throw exc::division_by_zero_error();
return R->from_long(0); // The result is zero.
}
}

// If K is a coeff ring of R, AND map is an identity on K,
Expand Down
7 changes: 7 additions & 0 deletions M2/Macaulay2/tests/normal/subst.m2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ I = matrix{{x^2,y^2}}
P=matrix({{2,3,4}})
substitute(f,P)
substitute(I,P)

S = QQ[t,Inverses=>true,MonomialOrder=>Lex]
g = matrix{{t^-1,1/2}}
assert(try (sub(g,t=>0); false) else true)
assert(sub(matrix{{t,1/2}}, t=>0) == matrix{{0_QQ,1/2}})
assert(sub(t^-1, t=>2) == 1/2)

end
-- Local Variables:
-- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/test subst.out"
Expand Down
Loading