# TypeError : Object not iterable

I am trying to build the multiplicative group of a finite field.

I define a finite field, its multiplicative group, and a conversion map from the finite field to its multiplicative group as follows:

sage: F.<a> = GF(7^2)
sage: G = AbelianGroupWithValues([a], n=1,
....:     gens_orders=[48], values_group=F)
sage: phi = G.convert_map_from(F)


Up to here, everything is fine.

Now there is an error when trying to use phi:

sage: phi(a)
Traceback (most recent call last)
...
TypeError: 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement' object is not iterable


What does this mean?

edit retag close merge delete

( 2018-06-29 03:23:28 -0600 )edit

Sort by » oldest newest most voted

If you expand the traceback you see that it is trying to construct an AbelianGroupElement from the input a (of type FiniteField_givaroElement), which does not work because the constructor expects exponents (of type tuple) as the second argument (over which it tries to iterate) instead.

I'm not sure phi = G.convert_map_from(F) should be expected to work in this case, because to calculate phi(x) for arbitrary x in F it would have to solve for $k$ in the equation $x = a^k$ (discrete logarithm problem).

However, you can still define the desired map yourself, e.g. as follows:

1. Name the generator of G, either by g = G.gen() or naming it in the definition:

G.<g> = AbelianGroupWithValues([a], [48])

2. Define the map conversion_map = lambda x: g^x.log(a).

For example, conversion_map(a^50) yields g^2 in G, and conversion_map(a^50).value() == a^50 is True.

Remark: The documentation warns that x.log(a) is currently implemented inefficiently.

more