# [Numpy-discussion] Matrix: potential usage case?

Jon Wright wright@esrf...
Tue Apr 29 14:19:48 CDT 2008

```Hi everyone,

Despite being a bit lost in the matrix debate, today I was working on
something which might want to use what is being described. You can see
an array only version at:

http://fable.svn.sourceforge.net/viewvc/fable/ImageD11/trunk/test/demo/latred.py?revision=2741&view=markup

The problem is in diffraction from crystals. We measure "scattering
vectors" which are in "reciprocal space" and use these to find crystal
structures in "real space". These spaces are a covariant/contravariat
pair*. The purpose of the code in the script is to construct a lattice
class which can work with vectors that are directly measured, or come
from an FFT of those vectors, which averages lots of peaks into fewer
peaks. [nb, for a single lattice this is a solved problem in many
software packages].

I used a keyword argument space="real" or space="reciprocal" to indicate
which space a vector is in. It might be a good case to think about
putting in RowVector and ColumnVector and trying to deal with the
consequences. It is not in this code yet, but the lattice symmetry
should show up soon. I have not understood how to distinguish a metric
tensor (flips RowVector to ColumnVector) from a reciprocal metric tensor
(flips back) from a simple rotation matrix (applies a symmetry operator,
like 2-fold rotation, so doesn't flip at all). I fear the limitation is
in my maths?

Best,

Jon

* Some heretics have been known to scale reciprocal space by 2pi. See
"Vectors and Tensors in Crystallography" by Donald Sands for an overview.

```