|
1 | 1 | ################################################################################ |
2 | 2 | # Common union types |
3 | 3 |
|
4 | | -const RingMatElemUnion = Union{NCRingElem, MatElem, SMat} |
5 | | -const RingMatSpaceUnion = Union{NCRing, MatSpace, SMatSpace} |
6 | 4 | const ModRingUnion = Union{zzModRing, ZZModRing} |
7 | 5 | const ModRingElemUnion = Union{zzModRingElem, ZZModRingElem} |
8 | 6 |
|
@@ -31,14 +29,18 @@ const LaurentUnionType = Union{Generic.LaurentSeriesRing, |
31 | 29 | ################################################################################ |
32 | 30 | # type_params functions |
33 | 31 |
|
34 | | -type_params(x::T) where T <: RingMatElemUnion = TypeParams(T, parent(x)) |
35 | | -type_params(R::T) where T <: RingMatSpaceUnion = TypeParams(T, base_ring(R)) |
| 32 | +# element types by default use their parent as reference object |
| 33 | +type_params(x::T) where T <: SetElem = TypeParams(T, parent(x)) |
| 34 | +type_params(x::T) where T <: SMat = TypeParams(T, parent(x)) |
| 35 | + |
| 36 | +# rings, groups etc. default have no reference object |
| 37 | +type_params(R::T) where T <: AbstractAlgebra.Set = TypeParams(T, nothing) |
| 38 | + |
| 39 | +# ideals and matrix spaces have their base ring as reference object |
36 | 40 | type_params(x::T) where T <: Ideal = TypeParams(T, base_ring(x)) |
37 | | -# exclude from ring union |
38 | | -type_params(::ZZRing) = TypeParams(ZZRing, nothing) |
39 | | -type_params(::ZZRingElem) = TypeParams(ZZRingElem, nothing) |
40 | | -type_params(R::T) where T <: PolyRingUnionType = TypeParams(T, coefficient_ring(R)) |
41 | | -type_params(R::T) where T <: ModRingUnion = TypeParams(T, nothing) |
| 41 | +type_params(x::T) where T <: MatSpace = TypeParams(T, base_ring(x)) |
| 42 | +type_params(x::T) where T <: SMatSpace = TypeParams(T, base_ring(x)) |
| 43 | + |
42 | 44 |
|
43 | 45 | ################################################################################ |
44 | 46 | # ring of integers (singleton type) |
|
85 | 87 | @register_serialization_type MPolyDecRing uses_id |
86 | 88 | @register_serialization_type AbstractAlgebra.Generic.LaurentMPolyWrapRing uses_id |
87 | 89 |
|
| 90 | +# polynomial-like rings use their coefficient ring as reference object |
| 91 | +type_params(R::T) where T <: PolyRingUnionType = TypeParams(T, coefficient_ring(R)) |
| 92 | + |
88 | 93 | function save_object(s::SerializerState, R::PolyRingUnionType) |
89 | 94 | save_data_dict(s) do |
90 | 95 | save_object(s, symbols(R), :symbols) |
|
378 | 383 | # Power Series |
379 | 384 | @register_serialization_type SeriesRing uses_id |
380 | 385 |
|
| 386 | +type_params(R::T) where T <: SeriesRing = TypeParams(T, base_ring(R)) |
381 | 387 |
|
382 | 388 | function save_object(s::SerializerState, R::RelPowerSeriesUnionType) |
383 | 389 | save_data_dict(s) do |
|
497 | 503 | @register_serialization_type Generic.LaurentSeriesField "LaurentSeriesField" uses_id |
498 | 504 | @register_serialization_type ZZLaurentSeriesRing uses_id |
499 | 505 |
|
| 506 | +type_params(R::T) where T <: LaurentUnionType = TypeParams(T, base_ring(R)) |
| 507 | + |
500 | 508 | function save_object(s::SerializerState, R::LaurentUnionType) |
501 | 509 | save_data_dict(s) do |
502 | 510 | save_object(s, var(R), :var) |
|
702 | 710 |
|
703 | 711 | @register_serialization_type MPolyLocRingElem |
704 | 712 |
|
705 | | -type_params(a::MPolyLocRingElem) = TypeParams(MPolyLocRingElem, parent(a)) |
706 | | - |
707 | 713 | function save_object(s::SerializerState, a::MPolyLocRingElem) |
708 | 714 | # `save_type_params` will store the output of type_params |
709 | 715 | # in this case the parent ring |
|
742 | 748 |
|
743 | 749 | @register_serialization_type MPolyQuoLocRingElem |
744 | 750 |
|
745 | | -type_params(a::T) where {T<:MPolyQuoLocRingElem} = TypeParams(T, parent(a)) |
746 | | - |
747 | 751 | function save_object(s::SerializerState, a::MPolyQuoLocRingElem) |
748 | 752 | save_object(s, [lifted_numerator(a), lifted_denominator(a)]) |
749 | 753 | end |
|
0 commit comments