Exotic isomorphism of matrix rings

Let R and S be commutative rings with a 1 different from zero. Let m and n be positive integers. Assume the ring of m-by-m matrices over R is isomorphic to the ring of n-by-n matrices over S. Does it follow that R is isomorphic to S? Does it follow that m = n? Does either of those follow from the other? I'm interested in both where R,S are finite and where R,S are infinite. (although the second question is trivial in the former case)

-
3x3 matrices of 2x2 matrices are the same as 2x2 matrices of 3x3 matrices, but 2 does not divide 3. Maybe revise the question? –  Tom Goodwillie Sep 11 '10 at 4:29
Excellent points, I'll have to figure out how to make the question more what I was trying to get. –  Ricky Demer Sep 11 '10 at 4:32
That should do it. (R and S must be commutative now) –  Ricky Demer Sep 11 '10 at 4:38
For the more general version of the question, the keyword is "Morita equivalence". In the more restrictive setting of commutative rings, Morita equivalence coincides with isomorphism. –  Victor Protsak Sep 11 '10 at 5:48

Yes and yes. Let $T=M_m(R)=M_n(S)$.
The center of $T$ is isomorphic to both $R$ and $S$.
The $1\times m$ matrices over $R$ form an $(R,T)$-bimodule and the $n\times 1$ matrices over $S$ form a $(T,S)$-bimodule. Tensor these over $T$ to get an $(R,S)$-bimodule. As an $S$-module the direct sum of $m$ copies of this is free of rank $n$. For a nonzero commutative ring this implies that $m$ divides $n$. (Tensor with a residue field to get a vector space of dimension $\frac{n}{m}$.) Likewise, looking at it as an $R$-module, $n$ divides $m$.
I immediately, though wrongly, thought “invariant basis number”, but I guess it's not a completely irrelevant concept; it seems that you're using it when you argue that $m$ divides $n$, and vice versa. –  L Spice Sep 11 '10 at 6:32
Even quicker: $M_m(R)$ is free of rank $m^2$ over its centre (and rank of free modules is an invariant for commutative rings). –  Robin Chapman Sep 11 '10 at 6:37
Going back to the noncommutative case, there are examples (with a classical, not pathological, flavor) where $M_2(R)=M_4(S)$ with $S$ commutative but $R$ is not $M_2(S)$ and indeed $R$ is not any $M_p(T)$ at all except $M_1(R)$. You can let $R$ be the endomorphism ring of an $S$-module $M$. Choose $M$ such that $M\oplus M$ is free of rank $4$ but $M$ has no nontrivial splitting. For example, let $S$ be the continuous (or real polynomial) functions on the $2$-sphere and take $M$ to be the corresponding sections of the tangent bundle. –  Tom Goodwillie Sep 11 '10 at 13:13