Ask Your Question
1

TypeError : Object not iterable

asked 2018-06-28 23:18:27 +0100

mathjain gravatar image

updated 2018-06-29 10:19:35 +0100

slelievre gravatar image

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 flag offensive close merge delete

Comments

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-06-29 19:56:57 +0100

rburing gravatar image

updated 2018-06-30 18:16:38 +0100

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-06-28 23:18:27 +0100

Seen: 1,027 times

Last updated: Jun 30 '18