1 | initial version |

It is unclear from the context of the question what is `C`

and what is `G`

.
So the solution will be given in a special case that worked first for me.

(Using `KleinFourGroup()`

instead of `C`

did not work. The group morphism in the other direction, initialized as we all would expect, did not work. In order to get it, if needed, an explicit python function can be written, which constructs the inverse map as a pedestrian.)

Code:

```
C.<c1,c2> = AbelianGroup( 2, [2,2] )
print "C is the following group:"
print C
print "\nIts multiplication table is:"
print C.multiplication_table( names='elements' )
F.<u> = QuadraticField( 2015 )
G = F.class_group()
g1, g2 = G.gens()
print "G is the following group:"
print G
phi = AbelianGroupMorphism( C, G, [c1, c2], [g1, g2] )
for c in C.list():
print "phi maps %s into %s" % ( c, phi(c) )
```

Results:

```
C is the following group:
Multiplicative Abelian group isomorphic to C2 x C2
Its multiplication table is:
* 1 c2 c1 c1*c2
+------------------------
1| 1 c2 c1 c1*c2
c2| c2 1 c1*c2 c1
c1| c1 c1*c2 1 c2
c1*c2| c1*c2 c1 c2 1
G is the following group:
Class group of order 4 with structure C2 x C2 of Number Field in u with defining polynomial x^2 - 2015
phi maps 1 into 1
phi maps c2 into Fractional ideal class (17, u + 3)
phi maps c1 into Fractional ideal class (19, u + 1)
phi maps c1*c2 into Fractional ideal class (5, u)
```

2 | No.2 Revision |

It is unclear from the context of the question what is `C`

and what is `G`

.
So the solution will be given in a special case that worked first for me.

(Using `KleinFourGroup()`

instead of `C`

did not work. The group morphism in the other direction, initialized as we all would expect, did not work. In order to get it, if needed, an explicit python function can be written, which constructs the inverse map as a pedestrian.)

Code:

```
C.<c1,c2> = AbelianGroup( 2, [2,2] )
print "C is the following group:"
print C
print "\nIts multiplication table is:"
print C.multiplication_table( names='elements' )
F.<u> = QuadraticField( 2015 )
G = F.class_group()
g1, g2 = G.gens()
print "G is the following group:"
print G
phi = AbelianGroupMorphism( C, G, [c1, c2], [g1, g2] )
for c in C.list():
print "phi maps %s into %s" % ( c, phi(c) )
```

Results:

```
C is the following group:
Multiplicative Abelian group isomorphic to C2 x C2
Its multiplication table is:
* 1 c2 c1 c1*c2
+------------------------
1| 1 c2 c1 c1*c2
c2| c2 1 c1*c2 c1
c1| c1 c1*c2 1 c2
c1*c2| c1*c2 c1 c2 1
G is the following group:
Class group of order 4 with structure C2 x C2 of Number Field in u with defining polynomial x^2 - 2015
phi maps 1 into 1
phi maps c2 into Fractional ideal class (17, u + 3)
phi maps c1 into Fractional ideal class (19, u + 1)
phi maps c1*c2 into Fractional ideal class (5, u)
```

**LATER EDIT:**

Here is an other example, it works for a abelian group model `G`

, used as an abstract model for the class group. (I could not make it at the first attempt work with `C.permutation_group()`

...)

```
R.<X> = PolynomialRing( QQ )
P = X^4 + 14*X^2 + 46
F.<u> = NumberField( P )
print "F is:\n%s" % F
print "Is F a CM field? %s" % F.is_CM()
C = F.class_group( names='c' )
inv = C.invariants()
G = AbelianGroup( len(inv), inv, names='g' )
print "C is:\n%s\nInvariants: %s\n" % ( C, inv )
print "G is:\n%s\n" % G
c0, c1 = C.gens()
g0, g1 = G.gens()
phi = AbelianGroupMorphism( G, C, [g0, g1], [c0, c1] )
psi = ( lambda c: [ g for g in G if C(phi(g)) == c ][0] )
for g in G:
print "phi(%s) = %s" % ( g, phi(g) )
print
for c in C:
print "psi(%s) = %s" % ( c, psi(c) )
```

The inverse map is also present. Results:

```
F is:
Number Field in u with defining polynomial X^4 + 14*X^2 + 46
Is F a CM field? True
C is:
Class group of order 4 with structure C2 x C2 of Number Field in u with defining polynomial X^4 + 14*X^2 + 46
Invariants: (2, 2)
G is:
Multiplicative Abelian group isomorphic to C2 x C2
phi(1) = 1
phi(g1) = Fractional ideal class (13, u - 6)
phi(g0) = Fractional ideal class (11, u - 3)
phi(g0*g1) = Fractional ideal class (2, u)
psi(Trivial principal fractional ideal class) = 1
psi(Fractional ideal class (13, u - 6)) = g1
psi(Fractional ideal class (11, u - 3)) = g0
psi(Fractional ideal class (2, u)) = g0*g1
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.