// Mul4x1 performs a "matrix product" between this matrix
// and another of the given dimension. For any two matrices of dimensionality
// MxN and NxO, the result will be MxO. For instance, Mat4 multiplied using
// Mul4x2 will result in a Mat4x2.
489346
func (m1 Mat2x4) Mul4x1(m2 Vec4) Vec2 {
	return Vec2{
		m1[0]*m2[0] + m1[2]*m2[1] + m1[4]*m2[2] + m1[6]*m2[3],
		m1[1]*m2[0] + m1[3]*m2[1] + m1[5]*m2[2] + m1[7]*m2[3],
	}
}
222280
func (m1 Mat3) Mul3x4(m2 Mat3x4) Mat3x4 {
	return Mat3x4{
		m1[0]*m2[0] + m1[3]*m2[1] + m1[6]*m2[2],
		m1[1]*m2[0] + m1[4]*m2[1] + m1[7]*m2[2],
		m1[2]*m2[0] + m1[5]*m2[1] + m1[8]*m2[2],
		m1[0]*m2[3] + m1[3]*m2[4] + m1[6]*m2[5],
		m1[1]*m2[3] + m1[4]*m2[4] + m1[7]*m2[5],
		m1[2]*m2[3] + m1[5]*m2[4] + m1[8]*m2[5],
		m1[0]*m2[6] + m1[3]*m2[7] + m1[6]*m2[8],
		m1[1]*m2[6] + m1[4]*m2[7] + m1[7]*m2[8],
		m1[2]*m2[6] + m1[5]*m2[7] + m1[8]*m2[8],
		m1[0]*m2[9] + m1[3]*m2[10] + m1[6]*m2[11],
		m1[1]*m2[9] + m1[4]*m2[10] + m1[7]*m2[11],
		m1[2]*m2[9] + m1[5]*m2[10] + m1[8]*m2[11],
	}
}
29868
func (m1 Mat2x3) Mul(c float64) Mat2x3 {
	return Mat2x3{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c}
}
143439
func (m1 Mat3x4) Mul4x1(m2 Vec4) Vec3 {
	return Vec3{
		m1[0]*m2[0] + m1[3]*m2[1] + m1[6]*m2[2] + m1[9]*m2[3],
		m1[1]*m2[0] + m1[4]*m2[1] + m1[7]*m2[2] + m1[10]*m2[3],
		m1[2]*m2[0] + m1[5]*m2[1] + m1[8]*m2[2] + m1[11]*m2[3],
	}
}
478341
func (m1 Mat3x4) Mul(c float64) Mat3x4 {
	return Mat3x4{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c, m1[6] * c, m1[7] * c, m1[8] * c, m1[9] * c, m1[10] * c, m1[11] * c}
}
1175930
func (m1 Mat4x2) Mul2x1(m2 Vec2) Vec4 {
	return Vec4{
		m1[0]*m2[0] + m1[4]*m2[1],
		m1[1]*m2[0] + m1[5]*m2[1],
		m1[2]*m2[0] + m1[6]*m2[1],
		m1[3]*m2[0] + m1[7]*m2[1],
	}
}
454873
func (m1 Mat4) Mul4x3(m2 Mat4x3) Mat4x3 {
	return Mat4x3{
		m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3],
		m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3],
		m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3],
		m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3],
		m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7],
		m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7],
		m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7],
		m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7],
		m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11],
		m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11],
		m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11],
		m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11],
	}
}
1168202
func (result *Matrix) Multiply(a, b *Matrix) {
	C.cairo_matrix_multiply((*C.cairo_matrix_t)(unsafe.Pointer(result)), (*C.cairo_matrix_t)(unsafe.Pointer(a)), (*C.cairo_matrix_t)(unsafe.Pointer(b)))
}
660065
func (m1 Mat2) Mul2(m2 Mat2) Mat2 {
	return Mat2{
		m1[0]*m2[0] + m1[2]*m2[1],
		m1[1]*m2[0] + m1[3]*m2[1],
		m1[0]*m2[2] + m1[2]*m2[3],
		m1[1]*m2[2] + m1[3]*m2[3],
	}
}
400074
func (v1 Vec4) Mul(c float64) Vec4 {
	return Vec4{v1[0] * c, v1[1] * c, v1[2] * c, v1[3] * c}
}
388824
func (mat *T) Mul(f float32) *T {
	for i, col := range mat {
		for j := range col {
			mat[i][j] *= f
		}
	}
	return mat
}
403919
func (m1 Mat2x3) Mul3x4(m2 Mat3x4) Mat2x4 {
	return Mat2x4{
		m1[0]*m2[0] + m1[2]*m2[1] + m1[4]*m2[2],
		m1[1]*m2[0] + m1[3]*m2[1] + m1[5]*m2[2],
		m1[0]*m2[3] + m1[2]*m2[4] + m1[4]*m2[5],
		m1[1]*m2[3] + m1[3]*m2[4] + m1[5]*m2[5],
		m1[0]*m2[6] + m1[2]*m2[7] + m1[4]*m2[8],
		m1[1]*m2[6] + m1[3]*m2[7] + m1[5]*m2[8],
		m1[0]*m2[9] + m1[2]*m2[10] + m1[4]*m2[11],
		m1[1]*m2[9] + m1[3]*m2[10] + m1[5]*m2[11],
	}
}
772497
func (m1 Mat4x2) Mul(c float64) Mat4x2 {
	return Mat4x2{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c, m1[4] * c, m1[5] * c, m1[6] * c, m1[7] * c}
}
569704
func (m1 Mat2) Mul2x3(m2 Mat2x3) Mat2x3 {
	return Mat2x3{
		m1[0]*m2[0] + m1[2]*m2[1],
		m1[1]*m2[0] + m1[3]*m2[1],
		m1[0]*m2[2] + m1[2]*m2[3],
		m1[1]*m2[2] + m1[3]*m2[3],
		m1[0]*m2[4] + m1[2]*m2[5],
		m1[1]*m2[4] + m1[3]*m2[5],
	}
}
686714
func MultiplyMatrixVector(m *Matrix, v []float32) []float32 {
	if len(v) == 2 {
		v = []float32{v[0], v[1], 1}
	}
	v00 := m.Val[m00]*v[m00] + m.Val[m01]*v[m10] + m.Val[m02]*v[m20]
	v10 := m.Val[m10]*v[m00] + m.Val[m11]*v[m10] + m.Val[m12]*v[m20]
	v20 := m.Val[m20]*v[m00] + m.Val[m21]*v[m10] + m.Val[m22]*v[m20]
	return []float32{v00, v10, v20}
}
702240
func (p *poly) Mul(q *poly) poly {
	// extra=2 because:
	// * some power of 2 is a K-th root of unity when n is a multiple of K/2.
	// * 2 itself is a square (see fermat.ShiftHalf)
	n := valueSize(p.k, p.m, 2)

	pv, qv := p.Transform(n), q.Transform(n)
	rv := pv.Mul(&qv)
	r := rv.InvTransform()
	r.m = p.m
	return r
}
1243444
func (m1 Mat2) Mul(c float32) Mat2 {
	return Mat2{m1[0] * c, m1[1] * c, m1[2] * c, m1[3] * c}
}