Structure of the set of solutions of a problem of the form A′A=D with some extra conditions. Given two square ($n \times n$) real diagonal positive definite matrices $D_1$ and $D_2$, I want to solve the system
$$\left\{\begin{array}{}
A_1 A_1' = D_1^2,\\
A_2 A_2' = D_2^2,\\
\boldsymbol{1}_n' A_1=\boldsymbol{1}_n' A_2,
\end{array}\right.$$
where 'prime' denotes transpose, $\boldsymbol{1}_n'$ is the row vector of length $n$ with all entries equal to $1$, and $A_1$, $A_2$ are ($n\times(2n-1)$) matrices.
A necessary condition for the existence of a solution is that $\|D_1\|^2=\|D_2\|^2$, where $\|A\|^2=\mathrm{tr}(A'A)$, and we assume that this is the case.
This system is in general underdetermined, and I want to find all the solutions. In particular I am interested in the structure of the set of solutions under the action of $\mathrm{O}(n)$ given by right multiplication, i.e. $Q\cdot(A_1,A_2)=(A_1Q',A_2Q')$, which maps solutions into solutions.
Question 1: in which cases are the minimal solutions a single orbit of $\mathrm{O}(2n-1)$?
Question 2: if there is more than one orbit of $\mathrm{O}(2n-1)$, how do I find a representative member of each orbit?
Edit: I made some progress on a solution, but I am not done yet.
Up to action of $\mathrm{O}(2n-1)$, by Cholesky decomposition we can assume that $A_1$ is of the form $(L\ \boldsymbol0_{n,n-1})$, with $L$ lower triangular and with positive diagonal entries. Then it follows that $A_1=(D_1\ \boldsymbol0_{n,n-1})$.
Let $B=\|D_2\|^{-2}(D_2^2\boldsymbol1_n)\cdot(\boldsymbol1_n'D_1)$. Then we obtain a solution of the form $A_2=(B\ C)$, where $C$ is an ($n\times (n-1)$) matrix that solves:
$$ C C' = D_2^2 - B B',\quad \text{and}\quad\boldsymbol1_n'C=0$$
This solution exists because $D_2^2 - B B'$ has rank $n-1$ (in fact its null space is generated by the vector $\boldsymbol1_n$). Up to $\mathrm{O}(2n-1)$ (in fact of the subgroup $\mathrm{O}(n-1)$ acting on the last $(n-1)$ coordinates), the solution $C$ is unique.
This shows an explicit solution, when it exists, but is not enough to find all possible solutions.
 A: The condition $A_iA_i^T=D_i^2$ means that $D_i^{-1}A_i$ has orthonormal rows. That is,
$$
A_i=D_iW_i\tag{1}
$$
for some $W_i\in\mathbb R^{n\times(2n-1)}$ with orthonormal rows. The condition $\mathbf 1^TA_1=\mathbf 1^TA_2$ thus means that
$$
\mathbf d_1^TW_1=\mathbf d_2^TW_2,\tag{2}
$$
where $D_i=\operatorname{diag}(\mathbf d_i)$. It is solvable if and only if $\mathbf d_1$ and $\mathbf d_2$ have the same Euclidean norm. When the latter condition is satisfied, the general solution is given by $(1)$ where the $W_i$s are any matrices with orthonormal rows that satisfy $(2)$.
Now let $(D_1W_1, D_2W_2)$ be a solution. By definition, its orbit is given by
$$
\left\{(A_1,A_2)=(D_1W_1Q^T,D_2W_2Q^T):Q\in O(2n-1)\right\}.
$$
Since there exists an orthogonal matrix $Q$ whose submatrix in the first $n$ rows is $W_1$, we see that the orbit always contains a member $(A_1,A_2)$ in the form of
$$
A_1=D_1\pmatrix{I_n&0}\text{ and }A_2=D_2W
$$
where $W$ has orthonormal rows. In view of $(2)$, if $U$ is an $n\times n$ orthogonal matrix such that $\mathbf d_2^TU=(1,0,\ldots,0)$, $W$ must be in the form of
$$
W=\pmatrix{X&U\pmatrix{0\\ Y}}\tag{3}
$$
where $X$ is $n\times n$, $Y$ is $(n-1)\times(n-1),\,\mathbf d_1^TX=\mathbf d_1^T$ and $W$ has orthonormal rows.
Now consider two solutions
$$
\left(D_1\pmatrix{I_n&0},D_2W\right)
\text{ and }
\left(D_1\pmatrix{I_n&0},D_2\overline W\right).
$$
If they lie on the same orbit, then $\left(D_1\pmatrix{I_n&0}I_{2n-1},\,D_2W\right)=\left(D_1\pmatrix{I_n&0}Q,\,D_2\overline W_2Q\right)$ for some orthogonal matrix $Q$. Hence the first $n$ rows of $I_{2n-1}$ are identical to those of $Q$ and the first $n$ rows of $W$ are identical to those of $\overline W_2Q$. Thus $Q=I_n\oplus V$ for some $V\in O(n-1)$. So, if $W$ is the form of $(3)$, then
$$
\overline W
=\pmatrix{X&U\pmatrix{0\\ YV}}.\tag{4}
$$
Hence the $X$ in $(3)$ is uniquely determined but $Y$ is not. It follows that when $n\ge2$, there are more than one orbits (because different $X$s give different orbits), and when $n\ge3$, there is no canonical way to pick a representative from each orbit (because given $Y$, there is no canonical way to pick a representative from $\{YV:V\in O(n-1)\}$ in general).
