Closed form solution to take a ratio and adjust an entire matrix by it? Given the following example matrix starting with both positive and negative values centered around 0:
$$Z = \begin{bmatrix}-0.4286 & 0.2000 \\ -0.2100 & 0.4286\end{bmatrix}$$
I want to be able to specify a ratio $r$ such that
$$
r = \left|{\max(Z)}\over{\min(Z)}\right|
$$
Is there a formula that will take a given $r$ and adjust $Z$ accordingly? I can do this indirectly. For example, I can generate target $r$ values of $2, \sqrt{2}, 1,$ ${1}\over{\sqrt{2}}$, $1\over{2}$ by doing the following where $i$ goes from 0 to 4:
\begin{align}
x =& {(4+i)}\over{6} \\
Z =& Z + (x - 1) \cdot \min(Z)
\end{align}
What I want is a function that takes $r$ and adjusts the matrix $Z$ as follows:
\begin{align}
r &=  2 \\
Z &= \text{adjustUsingRatio}(r) \\
Z &=  \begin{bmatrix}-0.2857 & 0.3429 \\ -0.0671 & 0.5715\end{bmatrix} 
\end{align}
Since there is a pattern to what I'm doing indirectly, I feel like there must be a more elegant and direct way to do this. It would be nice to target any value of $r$, which is harder to do with my indirect method.
Visualizing the Problem
Here is an example of the initial matrix (with many more than two elements):

It has a proportional distribution of negative (blue) and positive (red) values. The $\max$ and $\left|\min\right|$ values are approximately the same. 
Now compare to the resulting matrix after apply a ratio of 2:

The positive values have been amplified and the negative ones attenuated in a ratio of 2:1 relative to max and min from their starting ratio of 1:1.
These plots are normalized to have the midpoint color (green) in a rainbow color schemed anchored at 0.
 A: There is nothing special that necessitates to work on a matrix (two dimensional array). 
A one-dimensional array with entries $A_i$ will be enough for the formula.
A preliminary identity (valid for all $A_i$, check it !) :
$$A_i=\underbrace{\dfrac{(A_i-m)}{\color{red}{M}-m}}_{w_1}\color{red}{M}+\underbrace{\dfrac{(M-A_i)}{\color{red}{M}-m}}_{w_2}m=\dfrac{(A_i-m).\color{red}{M}+(M-A_i)m}{\color{red}{M}-m}$$
(it is a barycentric identity with $w_1$ and $w_2$ being interpretable as weights one places on $M$ and $m$ to have the center of gravity in $A_i$).
Once you have fixed the ratio $r$, here is a formula for defining the new element $B_i$ replacing $A_i$,  directly derived from (1) (we keep the same weights, but applied this time to $m$ and $rM$.)
$$B_i:=\underbrace{\dfrac{(A_i-m)}{\color{red}{M}-m}}_{w_1}\color{red}{rM}+\underbrace{\dfrac{(M-A_i)}{\color{red}{M}-m}}_{w_2}m=\dfrac{(A_i-m).\color{red}{rM}+(M-A_i)m}{\color{red}{M}-m}\tag{2}$$
There are other means to arrive at the same result, but I will stay with formula (2).
