Skip to content

Commit

Permalink
Merge pull request #1874 from flintlib/notring
Browse files Browse the repository at this point in the history
Generic structures shouldn't be rings by default
  • Loading branch information
fredrik-johansson authored Mar 22, 2024
2 parents 1d534ea + a7e7115 commit 2843ebb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/gr/cmp_coercion.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "gr.h"

/* todo: make overloadable */
/* todo: deal correctly with structures having the same kind */
/* todo: deal correctly with nested structures */

int gr_ctx_cmp_coercion(gr_ctx_t ctx1, gr_ctx_t ctx2)
Expand Down
9 changes: 8 additions & 1 deletion src/gr/mpoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ _gr_gr_mpoly_ctx_set_gen_names(gr_ctx_t ctx, const char ** s)
return GR_SUCCESS;
}

/* todo: everything is a ring when there are 0 vars? */
truth_t
_gr_gr_mpoly_ctx_is_ring(gr_ctx_t ctx)
{
return gr_ctx_is_ring(MPOLYNOMIAL_ELEM_CTX(ctx));
}

truth_t
_gr_gr_mpoly_ctx_is_commutative_ring(gr_ctx_t ctx)
{
Expand Down Expand Up @@ -308,7 +315,7 @@ gr_method_tab_input _gr__gr_gr_mpoly_methods_input[] =
{
{GR_METHOD_CTX_WRITE, (gr_funcptr) _gr_gr_mpoly_ctx_write},
{GR_METHOD_CTX_CLEAR, (gr_funcptr) _gr_gr_mpoly_ctx_clear},
{GR_METHOD_CTX_IS_RING, (gr_funcptr) gr_generic_ctx_predicate_true}, /* todo: matrices over semirings? */
{GR_METHOD_CTX_IS_RING, (gr_funcptr) _gr_gr_mpoly_ctx_is_ring},
{GR_METHOD_CTX_IS_COMMUTATIVE_RING, (gr_funcptr) _gr_gr_mpoly_ctx_is_commutative_ring},
{GR_METHOD_CTX_IS_INTEGRAL_DOMAIN, (gr_funcptr) _gr_gr_mpoly_ctx_is_integral_domain},
{GR_METHOD_CTX_IS_FIELD, (gr_funcptr) _gr_gr_mpoly_ctx_is_field},
Expand Down
1 change: 1 addition & 0 deletions src/gr/perm.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ gr_method_tab_input _perm_methods_input[] =
{
{GR_METHOD_CTX_IS_FINITE,
(gr_funcptr) gr_generic_ctx_predicate_true},
{GR_METHOD_CTX_IS_RING, (gr_funcptr) gr_generic_ctx_predicate_false},
{GR_METHOD_CTX_IS_MULTIPLICATIVE_GROUP,
(gr_funcptr) gr_generic_ctx_predicate_true},
{GR_METHOD_CTX_WRITE, (gr_funcptr) _gr_perm_ctx_write},
Expand Down
2 changes: 1 addition & 1 deletion src/gr_generic/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ const gr_method_tab_input _gr_generic_methods[] =
{
{GR_METHOD_CTX_CLEAR, (gr_funcptr) gr_generic_ctx_clear},

{GR_METHOD_CTX_IS_RING, (gr_funcptr) gr_generic_ctx_predicate_true},
{GR_METHOD_CTX_IS_RING, (gr_funcptr) gr_generic_ctx_predicate},
{GR_METHOD_CTX_IS_COMMUTATIVE_RING, (gr_funcptr) gr_generic_ctx_predicate},
{GR_METHOD_CTX_IS_INTEGRAL_DOMAIN, (gr_funcptr) gr_generic_ctx_predicate},
{GR_METHOD_CTX_IS_FIELD, (gr_funcptr) gr_generic_ctx_predicate},
Expand Down
2 changes: 2 additions & 0 deletions src/python/flint_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ def is_ring(self):
False
>>> PSL2Z.is_ring()
False
>>> SymmetricGroup(5).is_ring()
False
>>> PolynomialRing(RF).is_ring()
False
>>> PowerSeriesRing(RF).is_ring()
Expand Down

0 comments on commit 2843ebb

Please sign in to comment.