# Ticket #6762: 6762-in-qa.patch

File 6762-in-qa.patch, 1.7 KB (added by robertwb, 12 years ago)
• ## sage/algebras/quatalg/quaternion_algebra.py

```# HG changeset patch
# User Robert Bradshaw <robertwb@math.washington.edu>
# Date 1250414213 25200
# Node ID 3d818c9be3620b5a8d3ea323f204e657d4cac4c7
# Parent  55d0de322e72bafaac2ce7fbef9b526b16fe9fa4
Trac #6762, add __contains__ to quaternion algebra ideals over Q.

diff -r 55d0de322e72 -r 3d818c9be362 sage/algebras/quatalg/quaternion_algebra.py```
 a from sage.structure.sequence import Sequence from sage.structure.element import is_Element from sage.modules.free_module import VectorSpace, FreeModule from sage.modules.free_module_element import vector import quaternion_algebra_element import quaternion_algebra_cython #    that N(alpha) = N(I)*N(J) as explained by Pizer. c = IJbar.theta_series_vector(2)[1] return c != 0 def __contains__(self, x): """ Returns whether x is in self. EXAMPLES:: sage: R. = QuaternionAlgebra(-3, -13) sage: I = R.ideal([2+i, 3*i, 5*j, j+k]) sage: 2+i in I True sage: 2+i+j+k in I True sage: 1+i in I False sage: 101*j + k in I True """ try: x = self.quaternion_algebra()(x) return self.basis_matrix().transpose().solve_right(vector(x)) in ZZ**4 except (ValueError, TypeError): return False ####################################################################### # Some utility functions that are needed here and are too