Ring of matrices isomorphic to $O := \left\{a+b\frac{1+\sqrt{D}}{2}: a, b \in \mathbb{Z} \right\}$ 
Let $D$ be an integer such that it is not a perfect square in
  $\mathbb{Z}$. 
If $D \equiv 1$ mod $4$, the set $$T:= \left\{\left( \begin{matrix} a & b
 \\ \frac{(D-1)b}{4} & a+b \\ \end{matrix} \right) : a, b \in
 \mathbb{Z} \right\}$$ is a subring of $M_2(\mathbb{Z})$ which is isomorphic
  to the ring $$O := \left\{a+b\frac{1+\sqrt{D}}{2}: a, b \in \mathbb{Z}
\right\}.$$

My problem is to find an isomorphism. However, I find this relation : $$\det \left( \begin{matrix} a & b
 \\ \frac{(D-1)b}{4} & a+b \\ \end{matrix} \right)$$ $$= a(a+b)-\frac{b^2(D-1)}{4}$$ $$= \left(a+b\frac{1+\sqrt{D}}{2}\right)\left(a+b\frac{1-\sqrt{D}}{2}\right)$$
and $D \equiv 1$ mod $4$ $\iff$ $\left(\frac{1+\sqrt{D}}{2}\right)\left(\frac{1-\sqrt{D}}{2}\right) = -k$ for some $k \in \mathbb{Z}$
Does someone could give me a little hint to help me complete this problem?
 A: Defining a homomorphism of a ring $R$ into the ring of matrices is equivalent to defining an action of $R$ on a vector space (or free module).
In your case you want to find a homomorphism of $O$ into $M_2(\mathbb{Z})$ or equivalently find an action of $O$ on $\mathbb{Z}^2$.
What is the most natural action of $O$ that you can find on a space that is isomorphic to $\mathbb{Z}^2$?
--------------EDIT-----------------
The ring $O$ acts on itself by left (or right) multiplication, namely for $z\in O$ we have $T_z(x)=zx$ for all $x\in O$. Moreover, as an abelian group it is $\mathbb{Z}^2$ with basis $1,\frac{1-\sqrt{D}}2$, hence we have an action of $O$ on $\mathbb{Z}^2$. Now you are left to check what is the representing matrix of $T_z$ for some $z=a+b\frac{1+\sqrt{D}}{2}$ over the basis $1,\frac{1-\sqrt{D}}2$.
A: Hint: The matrix $$\pmatrix {a & b \\ \frac{(D-1)b}{4} & a+b \\ }$$ is the transpose of the matrix of $x \mapsto (a+b\theta)x$ with respect to the basis $1,\theta$, where $\theta=\frac{1+\sqrt{D}}{2}$.
Indeed, $\mu: T \to End_{\mathbb Z}(T)$ given by $\mu(\alpha)(x)=\alpha x$ is an injective ring homomorphism.
Since $T$ is a free abelian group of rank $2$ with basis $1,\theta$, we have that $End_{\mathbb Z}(T) \cong M_2(\mathbb{Z})$ as rings.
A: What about $\varphi:T\to O$ defined by $$\varphi\left( \begin{matrix} a & b
 \\ \frac{(D-1)b}{4} & a+b \\ \end{matrix} \right)=a+b\frac{1+\sqrt{D}}{2}$$
