# Revision history [back]

### How to calculate the intersection of a lattice with an affine subspace?

One can easily calculate the intersection of a lattice with a linear subspace of QQ^n:

sage: V = VectorSpace(QQ,3)
sage: L = ZZ^3
sage: U = V.subspace([(1,1,0), (0,1,1)])
sage: L.intersection(U)
Free module of degree 3 and rank 2 over Integer Ring
Echelon basis matrix:
[ 1  0 -1]
[ 0  1  1]


If I try to calculate the intersection of an affine subspace and a lattice in the same way, I get an error message:

sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: A = AffineSubspace((1,0,0), U)
sage: L.intersection(A)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-6458203faea4> in <module>()
----> 1 L.intersection(A)
[...]
TypeError: other must be a free module


Is there another way to do this? 2 retagged FrédéricC 4131 ●3 ●37 ●85

### How to calculate the intersection of a lattice with an affine subspace?

One can easily calculate the intersection of a lattice with a linear subspace of QQ^n:

sage: V = VectorSpace(QQ,3)
sage: L = ZZ^3
sage: U = V.subspace([(1,1,0), (0,1,1)])
sage: L.intersection(U)
Free module of degree 3 and rank 2 over Integer Ring
Echelon basis matrix:
[ 1  0 -1]
[ 0  1  1]


If I try to calculate the intersection of an affine subspace and a lattice in the same way, I get an error message:

sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: A = AffineSubspace((1,0,0), U)
sage: L.intersection(A)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-6458203faea4> in <module>()
----> 1 L.intersection(A)
[...]
TypeError: other must be a free module


Is there another way to do this?