Use a UniqueFactory to cache instances of QuaternionAlgebra

Before some generic caching was used. This should be more robust, easier to
maintain, and faster.
Fixed a pickling doctest for QuaternionAlgebras
add reference to elliptic_j in j_invariant_qexp
made polynomials with unhashable coefficients unhashable

The code already took care of not returning a hash value of -1 but the `except
-1` had been missing in the declaration of `_hash_c`.
Trac 15970: reviewer patch
trac #16237: Indexing in IncidenceStructureFromMatrix method fixed. minor clean-up of Hadamard matrices; they are now normalised.
trac #16211: Implement Hadamard Three Designs.
trac #16211: Merged with 6.2.rc2
trac #16211: Reviewer's commit
trac #16237: Merged with 6.2
trac #16237: Useless ::
trac #16211: Rebase on 6.2
trac #16211: Broken doc
Merge branch 'public/16211' of trac.sagemath.org:sage into hadamard
trac 16211: Review reviewer patch.
Trac #15897: UniqueFactory for QuaternionAlgebras

Quaternion algebras use a generic dictionary to cache objects (instead
of
`UniqueRepresentation` or `UniqueFactory`). This ticket replaces this
generic
cache with a `UniqueFactory` implementation.

URL: http://trac.sagemath.org/15897
Reported by: saraedum
Ticket author(s): Julian Rueth
Reviewer(s): David Roe, Peter Bruin
Trac #15970: j_invariant_qexp won't allow substitution

{{{
jq = j_invariant_qexp(10)
jqsub = jq.substitute(q = e^(-2*pi))
}}}
This used to work (Sage 4.8).  It ought to return an approximation to
1728 (this is useful behaviour...). E.g.

{{{
n(jqsub)

1727.99999999999
}}}
But now it raises...

{{{
ValueError: Can only substitute elements of positive valuation
}}}

URL: http://trac.sagemath.org/15970
Reported by: katestange
Ticket author(s): Alex Ghitza
Reviewer(s): Peter Bruin
Trac #16237: IncidenceStructureFromMatrix bug

The method IncidenceStructureFromMatrix has a serious bug, and it leads
to serious errors in computations. We should fix it ASAP. For example,
one may test with HadamardDesign (which uses the buggy implementation of
IncidenceStructureFromMatrix). Consider the following output:

{{{
sage: D = designs.HadamardDesign(11); N = D.incidence_matrix()
sage: J = matrix(ZZ, 11, 11, [1]*11*11); N*J
[6 6 6 6 6 6 6 6 6 6 6]
[6 6 6 6 6 6 6 6 6 6 6]
[6 6 6 6 6 6 6 6 6 6 6]
[6 6 6 6 6 6 6 6 6 6 6]
[6 6 6 6 6 6 6 6 6 6 6]
[5 5 5 5 5 5 5 5 5 5 5]
[4 4 4 4 4 4 4 4 4 4 4]
[4 4 4 4 4 4 4 4 4 4 4]
[4 4 4 4 4 4 4 4 4 4 4]
[4 4 4 4 4 4 4 4 4 4 4]
[4 4 4 4 4 4 4 4 4 4 4]
}}}

The bug is the indexing used in the if-testing in the method.

URL: http://trac.sagemath.org/16237
Reported by: knsam
Ticket author(s): Kannappan Sampath
Reviewer(s): Nathann Cohen
Trac #16211: Implement Hadamard 3-Designs

At the moment in sage-6.2.beta7, in designs.HadamardDesign, we have
implemented the Hadamard 2-design with paramters 2-(4n-1, 2n-1, n-1) one
gets from a Hadamard matrix of order 4n.

But, of course, this design extends uniquely to a (necessarily) 2-(4n,
2n, n-1) design: the blocks of this design are blocks of the old design
union a new point infinity and complements (in the old point set) of the
blocks of old design. And, any contraction is isomorphic to a Hadamard
2-design we started off with. So, unsurprisingly, this family is called
Hadamard 3-designs.

We could very easily implement these too.

URL: http://trac.sagemath.org/16211
Reported by: knsam
Ticket author(s): Kannappan Sampath
Reviewer(s): Nathann Cohen
Trac #16251: Polynomials with unhashable coefficients should be unhashable

Currently, polynomials with unhashable coefficients ignore the
`TypeError` their coefficients raise:
{{{
sage: K.<a> = Qq(9)
sage: R.<t> = K[]
sage: hash(t)
Exception TypeError: "unhashable type:
'sage.rings.padics.padic_ZZ_pX_CR_element.pAdicZZpXCRElement'" in
'sage.rings.polynomial.polynomial_element.Polynomial._hash_c' ignored
0
}}}

URL: http://trac.sagemath.org/16251
Reported by: saraedum
Ticket author(s): Julian Rueth
Reviewer(s): Peter Bruin