I have a project where I need to use quadratic fields   Specifically numbers of the form $a + b \sqrt{-3}$ with $a,b \in \mathbb{Q}$.For example here are the prime numbers in Eisenstein integers:I do not want to use sage.  I would like to write my own data type to incorporate numpy.  PARI would be useful - but it's not compatible with Python.Addition for these objects is pretty clear $$(a_1 + b_1 \sqrt{-3}) + (a_2 + b_2 \sqrt{-3})  = (a_1 + a_2) + (b_1+b_2) \sqrt{-3}$$Multiplication is a little more delicate but we can hard code it as well$$(a_1 + b_1 \sqrt{-3}) \times  (a_2 + b_2 \sqrt{-3}) = (a_1 a_2 - 3 b_1 b_2) + (a_1 b_2 + a_2 b_1)\sqrt{-3}$$My datatype also needs to accommodate division.  For simplicity let's take the reciprocal:$$ \frac{1}{a + b \sqrt{-3}} = \frac{a - b \sqrt{-3}}{a^2 + 3b^2}$$Is there a natural matrix-based way to encode these operations, similar to how $\mathbb{C}$ can be written in terms of $2 \times 2 $ matrices? $$ \left( \begin{array}{cc} a & b \\ -b & a \end{array}\right)$$Maybe I will just hard-code the operations as triples with the three operations outlined above.  Any ideas?
Representing Eisenstein numbers without floats
linear algebra;precision