public static Matrix3f operator +(Matrix3f x, Matrix3f y) { Matrix3f product = new Matrix3f(); // zeroes for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { product.m_elements[product.GetIndex(i, j)] = (x.getElement(i, j) + y.getElement(i, j)); //product.setElement(i, k, product.getElement(i, k) + x.getElement(i, j) * y.getElement(j, k)); } } return(product); }
public static Matrix3f operator *(Matrix3f x, float y) { Matrix3f product = new Matrix3f(); // zeroes for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < 3; ++k) { product.m_elements[product.GetIndex(i, k)] *= y; //product.setElement(i, k, product.getElement(i, k) + x.getElement(i, j) * y.getElement(j, k)); } } } return(product); }