trac 16358: Wrong answers of IncidenceStructure.automorphism_group()
Implement "first_lexicographic" option for irreducible polys over ffs.

This is Magma's default.
Leftover degree restriction.
Trac 10955: doctest for Maxima radexpand flag
Correct rounding in ZZ -> float conversion
Draft fix of multigraph adjacency
Added doctest verifying adjacency_matrix works for large multigraphs.
Changed to test if self.has_multiple_edges instead of try / except self.density()
Combine two if statements.
Fix typo in finite field poly code.
trac #16358: cleaner doctests for automorphism_group
Trac #10955: Get Maxima to easily accept flag values

Maxima relatively recently decided that 1/sqrt(x) is not sqrt(1/x), for
good reasons (1/sqrt(-1)=-i but sqrt(1/-1)=i in usual discussion).  So
for the following integral, they note that it depends on how you input
it:
{{{
sage: integrate(sqrt(1/x^2+x),x)
integrate(sqrt(x + 1/x^2), x)
sage: integrate(1/sqrt(x^2+x),x)
log(2*x + 2*sqrt(x^2 + x) + 1)
}}}
Fine.  Then they suggest using the flag `radexpand:all` to make the
first one behave.  But I can't figure out how to get it to evaluate.
{{{
sage: sage.calculus.calculus.maxima('radexpand:all')
all
sage: integrate(sqrt(1/x^2+x),x)
integrate(sqrt(x + 1/x^2), x)
}}}
Trying maxima.eval only changes that I get 'all' instead of all.  We
should make this work, since this is the *calculus* instance of Sage!

URL: http://trac.sagemath.org/10955
Reported by: kcrisman
Ticket author(s): Peter Bruin
Reviewer(s): Nils Bruin, Karl-Dieter Crisman
Trac #16385: Fix rounding ZZ -> Python float

Consider the following conversions:
A. Sage `Integer` -> Python `float` (or Sage `RDF`)
B. Python `int`/`long` -> Python `float`
C. Sage `Integer` -> Sage `RR`
D. C `unsigned long` -> C `double`

Conversion A rounds to zero, while the others round to nearest (by
default). We should make A consistent with the rest:

{{{
sage: int(float(ZZ(10^17-1)))
99999999999999984
sage: int(float(int(10^17-1)))
100000000000000000
sage: int(RR(10^17-1))
100000000000000000
sage: cython("""print <unsigned long>(<double> (%sUL))""" % (10^17-1))
100000000000000000
}}}

Currently, `Integer` -> `float` uses `mpz_get_d()` which rounds to zero.
We should fix this, similar to #14416.

URL: http://trac.sagemath.org/16385
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Christoph Lauter, Marc Mezzarobba
Trac #16395: adjacency_matrix raises error for large multigraphs

For G a graph, G.adjacency_matrix() calls G.density() to decide whether
to use a dense or sparse matrix. G.density() raises a TypeError if G is
a
multigraph. This is silly.

To witness the problem, try:
sage: G = Graph([(i,i+1) for i in range(500)]+[(0,1),], multiedges=True)
sage: G.adjacency_matrix()

The revised code tries density and, if that raises a TypeError, defaults
to a dense matrix. (So, if someone extends density, this code
automatically improves.)

URL: http://trac.sagemath.org/16395
Reported by: lipshitz
Ticket author(s): Robert Lipshitz
Reviewer(s): Nathann Cohen
Trac #16359: Implement "first_lexicographic" option for irreducible polynomials over finite fields of odd characteristic

This is the default behavior in Magma.

URL: http://trac.sagemath.org/16359
Reported by: jpflori
Ticket author(s): Jean-Pierre Flori
Reviewer(s): Peter Bruin
Trac #16358: Wrong answers of IncidenceStructure.automorphism_group()

I would say that this was broken when #16237 was fixed. The cool news is
that it did not make it inside of the stable release `:-P`

....

On the other hand all the doctests of `automorphism_group` were not
changed, so it cannot be #16237. So it may have been wrong since the
beginning ? `O_o`

Before this branch is applied :
{{{
sage: BlockDesign(4,[[0,1,2,3],[1,2,3]],test=False).automorphism_group()
Permutation Group with generators [()]
}}}

After:
{{{
sage: BlockDesign(4,[[0,1,2,3],[1,2,3]],test=False).automorphism_group()
Permutation Group with generators [(3,4), (2,3)]
}}}

Aaaaaaaand it turns out that writing this patch did not even force me to
change any doctest.. So it was just bad luck that the automorphism
groups used in the docstrings were EXACTLY the automorphism groups of
the duals (like the Fano plane... `:-P`) `:-P`

Nathann

P.S. : this also adds some potentially useful keyword in
is_block_design. That's how I found this bug.

URL: http://trac.sagemath.org/16358
Reported by: ncohen
Ticket author(s): Nathann Cohen
Reviewer(s): Vincent Delecroix