I have a matrix $B$ which it's dimension is $nm$ (with $n>m$). During an iterative process I'll change it to get a desired state of matrix $B$, but in each step, I should check a constraint that $\text{Trace}(B^TB)$ must be equal to an integer number $M$. Here $B^T$ is the transpose of $B$.
To meet the constraint, in each step, after getting new state of $B$, I do blow semi code to keep the trace of $B^TB$ equal to the given constant $M$.
$$x = B^TB$$
$$\hat{x} = \frac{M}{\text{Trace}(x)}x$$
actually $\hat{x}$ meets the constraint and now the Trace$(B^TB)$ is equal to $M$. But how can I find the matrix $B$ from $\hat{x}$ or how can I calculate $B$ from multiply of this matrix and it's transpose.
You calculate $x$ as above, call $a = \sqrt{\frac{M}{\text{Trace}(x)}}$. The new $B$ is $aB$.