glm::mat4 * glm::mat4 yielding incorrect results?
<p>For context, I've been learning OpenGL, and got to perspective projections. Spent a solid hour trying to figure out why my triangular pyramid wasn't showing up right, until I noticed one of my matrix multiplications (performed using operator* for glm::mat4) was giving me incorrect results. Tried multiplying two matrices with the same values, outside of that context, and sure enough, the result was still incorrect.</p>

<p>The two matrices I tried to multiply were:</p>

<pre><code>glm::mat4 left, right;
left[0][0] = 2.09928f; left[0][1] = 0.0f; left[0][2] = 0.0f; left[0][3] = 0.0f; 
left[1][0] = 0.0f; left[1][1] = 3.73205f; left[1][2] = 0.0f; left[1][3] = 0.0f; 
left[2][0] = 0.0f; left[2][1] = 0.0f; left[2][2] = 1.0202f; left[2][3] = -2.0202f;
left[3][0] = 0.0f; left[3][1] = 0.0f; left[3][2] = 1.0f; left[3][3] = 0.0f;

right[0][0] = 0.999998f; right[0][1] = 0.0f; right[0][2] = -0.00174533f; right[0][3] = 0.0f; 
right[1][0] = 0.0f; right[1][1] = 1.0f; right[1][2] = 0.0f; right[1][3] = 0.0f; 
right[2][0] = 0.00174533f; right[2][1] = 0.0f; right[2][2] = 0.999998f; right[2][3] = 5.0f; 
right[3][0] = 0.0f; right[3][1] = 0.0f; right[3][2] = 0.0f; right[3][3] = 1.0f;
</code></pre>

<p>Using <code>left * right</code>, I get:</p>

<pre><code>       2.09928,       0, -0.00178059, 0.00352592 
             0, 3.73205,           0,          0 
    0.00366393,       0,      6.0202,    -2.0202 
             0,       0,           1,          0 
</code></pre>

<p>which is incorrect. On the other hand, with this multiplication algorithm:</p>

<pre><code>inline glm::mat4 Multiply(const glm::mat4&amp; left, const glm::mat4 right)
{
    glm::mat4 ret;

    for (unsigned int i = 0; i &lt; 4; i++) {
        for (unsigned int j = 0; j &lt; 4; j++) {
            ret[i][j] = left[i][0] * right[0][j] +
                left[i][1] * right[1][j] +
                left[i][2] * right[2][j] +
                left[i][3] * right[3][j];
        }
    }

    return ret;
}
</code></pre>

<p>I get: </p>

<pre><code>       2.09928,       0, -0.00366393,      0 
             0, 3.73205,           0,      0 
    0.00178059,       0,      1.0202,3.08081 
    0.00174533,       0,    0.999998,      5  
</code></pre>

<p>which is correct.</p>

<p>So, what am I doing wrong here?</p>

<p>Thanks in advance!</p>