// Converts a mat.Vector to an array of ints
433150
func vecToInts(v mat.Vector) []int {
	n_obs, _ := v.Dims()
	var ints = make([]int, n_obs)
	for i := 0; i < n_obs; i++ {
		ints[i] = int(v.At(i, 0))
	}
	return ints
}
1130813
func (p *Point) MultiplyMatrixVector(m *Matrix) *Point {
	x := m.Val[m00]*p.X + m.Val[m01]*p.Y + m.Val[m02]
	y := m.Val[m10]*p.X + m.Val[m11]*p.Y + m.Val[m12]
	p.X, p.Y = x, y
	return p
}
688849
func (m Mat4x3) Rows() (row0, row1, row2, row3 Vec3) {
	return m.Row(0), m.Row(1), m.Row(2), m.Row(3)
}
336910
func Mat2x4FromRows(row0, row1 Vec4) Mat2x4 {
	return Mat2x4{row0[0], row1[0], row0[1], row1[1], row0[2], row1[2], row0[3], row1[3]}
}
1115849
func Mat2FromRows(row0, row1 Vec2) Mat2 {
	return Mat2{row0[0], row1[0], row0[1], row1[1]}
}
1331548
func NewFromArrays(a [][]float64) *Matrix {
	rows := len(a)
	if rows == 0 {
		return nil
	}
	cols := len(a[0])
	m := New(rows, cols)
	for row := 0; row < rows; row++ {
		for col := 0; col < cols; col++ {
			m.Set(row, col, a[row][col])
		}
	}
	return m
}
494670
func (mat *T) Array() *[9]float32 {
	return &[...]float32{
		mat[0][0], mat[0][1], mat[0][2],
		mat[1][0], mat[1][1], mat[1][2],
		mat[2][0], mat[2][1], mat[2][2],
	}
}
1080769
func (mat *T) Invert() *T {
	initialDet := mat.Determinant()
	mat.Adjugate()
	mat.Mul(1 / initialDet)
	return mat
}
763546
func vectorMax(v mat.Vector) float64 {
	n_obs, _ := v.Dims()
	max := v.At(0, 0)
	for i := 0; i < n_obs; i++ {
		if v.At(i, 0) > max {
			max = v.At(i, 0)
		}
	}
	return max
}
781383
func Ints(reply interface{}, err error) ([]int, error) {
    values, err := Values(reply, err)
    if err != nil {
	return nil, err
    }

    ints := make([]int, len(values))
    slice := make([]interface{}, len(values))
    for i, _ := range ints {
	slice[i] = &ints[i]
    }

    if _, err = Scan(values, slice...); err != nil {
	return nil, err
    }

    return ints, nil
}
729665
func (m Mat2x3) Abs() Mat2x3 {
	return Mat2x3{Abs(m[0]), Abs(m[1]), Abs(m[2]), Abs(m[3]), Abs(m[4]), Abs(m[5])}
}
1069872
func (mat *T) AssignMat2x2(m *mat2.T) *T {
	*mat = T{
		vec3.T{m[0][0], m[1][0], 0},
		vec3.T{m[0][1], m[1][1], 0},
		vec3.T{0, 0, 1},
	}
	return mat
}
248419
func (m Mat2x4) Abs() Mat2x4 {
	return Mat2x4{Abs(m[0]), Abs(m[1]), Abs(m[2]), Abs(m[3]), Abs(m[4]), Abs(m[5]), Abs(m[6]), Abs(m[7])}
}
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}
}
83740
func Int32s(input []int32) []int32 {
	u := make([]int32, 0, len(input))
	m := make(map[int32]bool)

	for _, val := range input {
		if _, ok := m[val]; !ok {
			m[val] = true
			u = append(u, val)
		}
	}

	return u
}
295796
func (m *Matrix) Arrays() [][]float64 {
	rows, cols := m.Size()
	a := make([][]float64, rows)

	for row := 0; row < rows; row++ {
		a[row] = make([]float64, cols)

		for col := 0; col < cols; col++ {
			a[row][col] = m.Get(row, col)
		}
	}
	return a
}
463166
func (m Mat3) Rows() (row0, row1, row2 Vec3) {
	return m.Row(0), m.Row(1), m.Row(2)
}