// MulVec2 multiplies vec with mat.
170996
func (mat *T) MulVec2(vec *vec2.T) vec2.T {
	return vec2.T{
		mat[0][0]*vec[0] + mat[1][0]*vec[1],
		mat[0][1]*vec[1] + mat[1][1]*vec[1],
	}
}
996584
func (m Mat2) Col(col int) Vec2 {
	return Vec2{m[col*2+0], m[col*2+1]}
}
815633
func (m1 Mat4x3) Mul3x1(m2 Vec3) Vec4 {
	return Vec4{
		m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2],
		m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2],
		m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2],
		m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2],
	}
}
662974
func (v1 Vec3) Mul(c float64) Vec3 {
	return Vec3{v1[0] * c, v1[1] * c, v1[2] * c}
}
776381
func (c C) Mul(val Input) Input {
	if v, ok := val.(C); ok {
		return C(float32(v) * float32(c))
	}
	return val.Mul(c)
}
285110
func (mat *T) MulVec3W(v *vec3.T, w float32) vec3.T {
	result := *v
	mat.TransformVec3W(&result, w)
	return result
}
451174
func (e *gfP2) MulXi(a *gfP2) *gfP2 {
	// (xi+y)(i+9) = (9x+y)i+(9y-x)
	tx := &gfP{}
	gfpAdd(tx, &a.x, &a.x)
	gfpAdd(tx, tx, tx)
	gfpAdd(tx, tx, tx)
	gfpAdd(tx, tx, &a.x)

	gfpAdd(tx, tx, &a.y)

	ty := &gfP{}
	gfpAdd(ty, &a.y, &a.y)
	gfpAdd(ty, ty, ty)
	gfpAdd(ty, ty, ty)
	gfpAdd(ty, ty, &a.y)

	gfpSub(ty, ty, &a.x)

	e.x.Set(tx)
	e.y.Set(ty)
	return e
}
1281687
func (vn *VecN) Vec2() Vec2 {
	raw := vn.Raw()
	return Vec2{raw[0], raw[1]}
}
200512
func Mult(v1 Vect, s Float) Vect {
	return Vect{v1.X * s, v1.Y * s}
}
1331183
func (m1 Mat4x3) Mul3x4(m2 Mat3x4) Mat4 {
	return Mat4{
		m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2],
		m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2],
		m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2],
		m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2],
		m1[0]*m2[3] + m1[4]*m2[4] + m1[8]*m2[5],
		m1[1]*m2[3] + m1[5]*m2[4] + m1[9]*m2[5],
		m1[2]*m2[3] + m1[6]*m2[4] + m1[10]*m2[5],
		m1[3]*m2[3] + m1[7]*m2[4] + m1[11]*m2[5],
		m1[0]*m2[6] + m1[4]*m2[7] + m1[8]*m2[8],
		m1[1]*m2[6] + m1[5]*m2[7] + m1[9]*m2[8],
		m1[2]*m2[6] + m1[6]*m2[7] + m1[10]*m2[8],
		m1[3]*m2[6] + m1[7]*m2[7] + m1[11]*m2[8],
		m1[0]*m2[9] + m1[4]*m2[10] + m1[8]*m2[11],
		m1[1]*m2[9] + m1[5]*m2[10] + m1[9]*m2[11],
		m1[2]*m2[9] + m1[6]*m2[10] + m1[10]*m2[11],
		m1[3]*m2[9] + m1[7]*m2[10] + m1[11]*m2[11],
	}
}
976244
func (e *gfP2) Mul(a, b *gfP2, pool *bnPool) *gfP2 {
	tx := pool.Get().Mul(a.x, b.y)
	t := pool.Get().Mul(b.x, a.y)
	tx.Add(tx, t)
	tx.Mod(tx, P)

	ty := pool.Get().Mul(a.y, b.y)
	t.Mul(a.x, b.x)
	ty.Sub(ty, t)
	e.y.Mod(ty, P)
	e.x.Set(tx)

	pool.Put(tx)
	pool.Put(ty)
	pool.Put(t)

	return e
}
670935
func (m1 Mat3x4) Mul4x3(m2 Mat4x3) Mat3 {
	return Mat3{
		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],
		m1[0]*m2[4] + m1[3]*m2[5] + m1[6]*m2[6] + m1[9]*m2[7],
		m1[1]*m2[4] + m1[4]*m2[5] + m1[7]*m2[6] + m1[10]*m2[7],
		m1[2]*m2[4] + m1[5]*m2[5] + m1[8]*m2[6] + m1[11]*m2[7],
		m1[0]*m2[8] + m1[3]*m2[9] + m1[6]*m2[10] + m1[9]*m2[11],
		m1[1]*m2[8] + m1[4]*m2[9] + m1[7]*m2[10] + m1[10]*m2[11],
		m1[2]*m2[8] + m1[5]*m2[9] + m1[8]*m2[10] + m1[11]*m2[11],
	}
}
798677
func (m1 Mat3x2) Mul2x4(m2 Mat2x4) Mat3x4 {
	return Mat3x4{
		m1[0]*m2[0] + m1[3]*m2[1],
		m1[1]*m2[0] + m1[4]*m2[1],
		m1[2]*m2[0] + m1[5]*m2[1],
		m1[0]*m2[2] + m1[3]*m2[3],
		m1[1]*m2[2] + m1[4]*m2[3],
		m1[2]*m2[2] + m1[5]*m2[3],
		m1[0]*m2[4] + m1[3]*m2[5],
		m1[1]*m2[4] + m1[4]*m2[5],
		m1[2]*m2[4] + m1[5]*m2[5],
		m1[0]*m2[6] + m1[3]*m2[7],
		m1[1]*m2[6] + m1[4]*m2[7],
		m1[2]*m2[6] + m1[5]*m2[7],
	}
}
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}
}
279062
func (m1 Mat4) Mul(c float64) Mat4 {
	return Mat4{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, m1[12] * c, m1[13] * c, m1[14] * c, m1[15] * c}
}
1147190
func (m1 Mat3x2) Mul2x3(m2 Mat2x3) Mat3 {
	return Mat3{
		m1[0]*m2[0] + m1[3]*m2[1],
		m1[1]*m2[0] + m1[4]*m2[1],
		m1[2]*m2[0] + m1[5]*m2[1],
		m1[0]*m2[2] + m1[3]*m2[3],
		m1[1]*m2[2] + m1[4]*m2[3],
		m1[2]*m2[2] + m1[5]*m2[3],
		m1[0]*m2[4] + m1[3]*m2[5],
		m1[1]*m2[4] + m1[4]*m2[5],
		m1[2]*m2[4] + m1[5]*m2[5],
	}
}
1150511
func (mat *T) ScaleVec2(s *vec2.T) *T {
	mat[0][0] *= s[0]
	mat[1][1] *= s[1]
	return mat
}