Factorization of $16 \times 512$ matrix I have a lot of matrices whose size is 16 x 512 (let´s called them $A_{k}$) and a matrix $B$ of size 16 x 512. I would like to write the matrices $A_{k}$ like $A_{k}=C_{k}*B$ where $C_{k}$ has size 16 x 16. I don't know how to get the matrices $C_{k}$ or if it is always possible for any matrix $B$.
If it is not possible for any matrix $B$, how can I choose a matrix $B$ so this factorization is posible?
Thank you very much
 A: Depending on the matrices $A_k$ and on $B$, this can very well be impossible; for example it is impossible if $B=0$ and $A_j\neq 0$ for some $j$.
More generally, this will be possible if and only if all the rows of the matrices $A_k$ are in the subspace of $\mathbb{R}^{512}$ spanned by the $16$ rows of $B$; thus if the subspace $W$ spanned by the rows of the $A_k$'s has dimension bigger than $16$, it won't be possible, no matter the matrix $B$. If it has dimension $16$ or lower, you can just take $16$ rows in your $A_k$'s that span $W$ and define $B$ as the matrix formed by these rows.
A: Given fat matrices $\mathrm A, \mathrm B \in \mathbb R^{16 \times 512}$, we have the following linear matrix equation in $\mathrm X \in \mathbb R^{16 \times 16}$
$$\mathrm X \mathrm A = \mathrm B$$
We have $16 \cdot 512$ equations in $16^2$ unknowns. Thus, we have a severely overdetermined system with $32$ times more equations than unknowns. Hence, let us look for a least-squares solution
$$\hat{\mathrm X} := \arg\min \| \mathrm X \mathrm A - \mathrm B \|_{\text{F}}^2$$
Minimizing $\| \mathrm X \mathrm A - \mathrm B \|_{\text{F}}^2$, we obtain the normal equations
$$\mathrm X \mathrm A \mathrm A^{\top} = \mathrm B \mathrm A^{\top}$$
If $\mathrm A$ has full row rank, then $\mathrm A \mathrm A^{\top}$ is invertible and, thus, the unique least-squares solution is
$$\boxed{\hat{\mathrm X} = \mathrm B \mathrm A^{\top} \left( \mathrm A \mathrm A^{\top} \right)^{-1}}$$
Plugging this least-squares solution into the original linear matrix equation, we obtain
$$\hat{\mathrm X} \mathrm A = \mathrm B \, \underbrace{\mathrm A^{\top} \left( \mathrm A \mathrm A^{\top} \right)^{-1} \mathrm A}_{=: \mathrm P_{\mathrm A^{\top}}} = \mathrm B \mathrm P_{\mathrm A^{\top}}$$
where $\mathrm P_{\mathrm A^{\top}}$ is the projection matrix that projects onto the column space of $\mathrm A^{\top}$, i.e., onto the row space of $\mathrm A$. The least-squares solution is a solution to the original matrix equation if and only if
$$\mathrm B \mathrm P_{\mathrm A^{\top}} = \mathrm B$$
or, alternatively, if and only if
$$\mathrm P_{\mathrm A^{\top}} \mathrm B^{\top} = \mathrm B^{\top}$$
We conclude that the least-squares solution is a solution to the original matrix equation if and only if the columns of $\mathrm B^{\top}$, i.e, the rows of $\mathrm B$, are in the row space of $\mathrm A$. If that is the case, then the $16$ entries of the $k$-th row of $\hat{\mathrm X}$ tell us how to weight the $16$ rows of $\mathrm A$ in order to build the $k$-th row of $\mathrm B$.
A: You have a hard problem of linear algebra. What you want to have is the solution of the matrix equation
$$\begin{bmatrix} a_{ij} \end{bmatrix}_{1\le i\le16\\1\le j\le 512}=\begin{bmatrix} x_{ij} \end{bmatrix}_{1\le i\le16\\1\le j\le 16}
*\begin{bmatrix} b_{ij} \end{bmatrix}_{1\le i\le16\\1\le j\le 512}=\begin{bmatrix} \Sigma\space x_{ik}b_{kj} \end{bmatrix}_{1\le i\le16\\1\le j\le 512}$$ For this you need to verify the compatibility of the $16\cdot512$ equations in $216$ (=$16^2$) unknowns $x_{ij}$
$$a_{ij}=\Sigma_{1\le k\le 16} (x_{ik}b_{kj})$$
Except, perhaps, some particularity of your matrices that allow easy calculations, this is the general way of solving your problem.
