# Scalar multiplication in vecmath on Matrix4f results in strange values

So I have a matrix:

Matrix4f Mbsp = Matrix4f(Vector4f(1.0, 4.0, 1.0, 0.0)
, Vector4f(-3.0, 0.0, 3.0, 0.0)
, Vector4f(3.0, -6.0, 3.0, 0.0)
, Vector4f(-1.0, 3.0, -3.0, 1.0), true);


and I'm doing a scalar multiplication to it, e.g.:

Mbsp = (1.0/6.0)*Mbsp;


One would now expect Mbsp to be

$$\begin{array} &1/6&-1/2&1/2&-1/6\\2/3&0&-1&1/2\\1/6&1/2&1/2&-1/2\\ 0&0&0&1/6 \end{array}$$

However Mbsp now is:

$$\begin{array} &1.0&1.4901161e-008&1.4901161e-008&0\\1.0&1.4901161e-008&1.4901161e-008&0\\1.0&1.4901161e-008&1.4901161e-008&0&\\ 1.0&1.4901161e-008&1.4901161e-008&0 \end{array}$$

Similarly, doing (using the original Mbsp):

Mbsp = 2.0*Mbsp;


Gives

$$\begin{array} &12&0&0&0\\12&0&0&0\\12&0&0&0\\ 12&0&0&0 \end{array}$$

What's wrong?

• which matrix lib? – ratchet freak Feb 9 '17 at 11:03
• @ratchetfreak vecmath – mavavilj Feb 9 '17 at 11:05
• Have you printed out the original matrix to ensure its constructed OK? Can you step through code to check the scalar multiplication operator is being called and verify that a temporary matrix/vector isn't being constructed? Can you post a link to this vecmath library? – PeteUK Feb 11 '17 at 0:19