Skip to content

Commit

Permalink
Add ring and promote methods for Constant objects
Browse files Browse the repository at this point in the history
Add support for creating matrices with Constant entries.  Also add a
unit test.
  • Loading branch information
d-torrance committed Sep 5, 2024
1 parent 207cf44 commit 8d5df65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions M2/Macaulay2/m2/reals.m2
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ EulerConstant = new Constant from { symbol EulerConstant, mpfrConstantEuler, eRR
CatalanConstant = new Constant from { symbol CatalanConstant, mpfrConstantCatalan, cRRi0}
ii = new Constant from { symbol ii, ConstantII}

ring Constant := ring @@ numeric
promote(Constant, InexactNumber') := (x, kk) -> (
promote(numeric(precision kk, x), kk))

isFinite Constant := x -> true

lngamma = method()
Expand Down
3 changes: 3 additions & 0 deletions M2/Macaulay2/tests/normal/matrix.m2
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ scan({matrix {}, matrix(ZZ, {}), map(ZZ^0, ZZ^0, {}), map(ZZ^0,, {})}, A -> (
assert Equation(source A, ZZ^0);
assert Equation(target A, ZZ^0)))

-- issue #3456
assert Equation(matrix {{ii}}, matrix {{numeric ii}})

-- Local Variables:
-- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/test matrix.out"
-- End:

0 comments on commit 8d5df65

Please sign in to comment.