func (array sparseDiagF64Matrix) Slice(from []int, to []int) NDArray {
	return Slice(&array, from, to)
}
Get an array containing a rectangular slice of this array.
`from` and `to` should both have one index per axis. The indices
in `from` and `to` define the first and just-past-last indices you wish
to select along each axis.
package matrix
import (
	"fmt"
)
type sparseDiagF64Matrix struct {
	shape []int
	diag  []float64
}
func (array sparseDiagF64Matrix) Add(other ...NDArray) NDArray {
	return Add(&array, other...)
}
func (array sparseDiagF64Matrix) All() bool {
	return false
}
func (array sparseDiagF64Matrix) AllF(f func(v float64) bool) bool {
	return AllF(&array, f)
}
func (array sparseDiagF64Matrix) AllF2(f func(v1, v2 float64) bool, other NDArray) bool {
	return AllF2(&array, f, other)
}
func (array sparseDiagF64Matrix) Any() bool {
	for _, v := range array.diag {
		if v != 0 {
			return true
		}
	}
	return false
}
func (array sparseDiagF64Matrix) AnyF(f func(v float64) bool) bool {
	return AnyF(&array, f)
}
func (array sparseDiagF64Matrix) AnyF2(f func(v1, v2 float64) bool, other NDArray) bool {
	return AnyF2(&array, f, other)
}
func (array sparseDiagF64Matrix) Apply(f func(float64) float64) NDArray {
	return Apply(&array, f)
}
func (array sparseDiagF64Matrix) Array() []float64 {
	return array.Dense().Array()
}
func (array sparseDiagF64Matrix) ColSet(col int, values []float64) {
	if col < 0 || col >= array.shape[1] {
		panic(fmt.Sprintf("ColSet can't set col %d of a %d-col array", col, array.shape[1]))
	} else if len(values) != array.shape[0] {
		panic(fmt.Sprintf("ColSet has %d rows but got %d values", array.shape[0], len(values)))
	}
	for row := 0; row < array.shape[0]; row++ {
		if row != col {
			if values[row] != 0 {
				panic(fmt.Sprintf("ColSet can't set cell (%d, %d) of a %dx%d sparse diagonal matrix", row, col, array.shape[0], array.shape[1]))
			}
		} else {
			array.diag[row] = values[row]
		}
	}
}
func (array sparseDiagF64Matrix) Col(col int) []float64 {
	if col < 0 || col >= array.shape[1] {
		panic(fmt.Sprintf("Can't get column %d from a %dx%d array", col, array.shape[0], array.shape[1]))
	}
	result := make([]float64, array.shape[1])
	result[col] = array.diag[col]
	return result
}
func (array sparseDiagF64Matrix) Cols() int {
	return array.shape[1]
}
func (array sparseDiagF64Matrix) Concat(axis int, others ...NDArray) NDArray {
	return Concat(axis, &array, others...)
}
func (array sparseDiagF64Matrix) Copy() NDArray {
	return array.copy()
}
func (array sparseDiagF64Matrix) copy() *sparseDiagF64Matrix {
	result := &sparseDiagF64Matrix{
		shape: make([]int, len(array.shape)),
		diag:  make([]float64, len(array.diag)),
	}
	copy(result.shape[:], array.shape[:])
	copy(result.diag[:], array.diag[:])
	return result
}
func (array sparseDiagF64Matrix) CountNonzero() int {
	count := 0
	for _, v := range array.diag {
		if v != 0 {
			count++
		}
	}
	return count
}
func (array sparseDiagF64Matrix) Dense() NDArray {
	result := Dense(array.shape...)
	for pos, val := range array.diag {
		result.ItemSet(val, pos, pos)
	}
	return result
}
func (array sparseDiagF64Matrix) Diag() Matrix {
	return A([]int{len(array.diag), 1}, array.diag...).M()
}
func (array sparseDiagF64Matrix) Dist(t DistType) Matrix {
	return Dist(&array, t)
}
func (array sparseDiagF64Matrix) Div(other ...NDArray) NDArray {
	return Div(&array, other...)
}
func (array sparseDiagF64Matrix) Equal(other NDArray) bool {
	return Equal(&array, other)
}
func (array sparseDiagF64Matrix) Fill(value float64) {
	panic("Can't Fill() a sparse diagonal matrix")
}
func (array sparseDiagF64Matrix) FlatCoord(index int) []int {
	return flatToNd(array.shape, index)
}
func (array sparseDiagF64Matrix) FlatItem(index int) float64 {
	coord := flatToNd(array.shape, index)
	if coord[0] != coord[1] || coord[0] >= len(array.diag) {
		return 0
	}
	return array.diag[coord[0]]
}
func (array sparseDiagF64Matrix) FlatItemSet(value float64, index int) {
	coord := flatToNd(array.shape, index)
	if coord[0] != coord[1] || coord[0] >= len(array.diag) {
		panic(fmt.Sprintf("FlatItemSet index %v invalid for sparse diagonal array shape %v", index, array.shape))
	}
	array.diag[coord[0]] = value
}
func (array sparseDiagF64Matrix) Inverse() (Matrix, error) {
	return Inverse(&array)
}
func (array sparseDiagF64Matrix) Item(index ...int) float64 {
	if len(index) != 2 || index[0] >= array.shape[0] || index[1] >= array.shape[1] {
		panic(fmt.Sprintf("Item indices %v invalid for array shape %v", index, array.shape))
	} else if index[0] != index[1] || index[0] >= len(array.diag) {
		return 0
	}
	return array.diag[index[0]]
}
func (array *sparseDiagF64Matrix) ItemAdd(value float64) NDArray {
	result := &denseF64Array{
		shape: make([]int, 2),
		array: make([]float64, array.shape[0]*array.shape[1]),
	}
	copy(result.shape[:], array.shape[:])
	flat := 0
	for row := 0; row < array.shape[0]; row++ {
		for col := 0; col < array.shape[1]; col++ {
			if row == col {
				result.array[flat] = array.diag[row] + value
			} else {
				result.array[flat] = value
			}
			flat++
		}
	}
	return result
}
func (array *sparseDiagF64Matrix) ItemDiv(value float64) NDArray {
	result := array.copy()
	for i := 0; i < len(result.diag); i++ {
		result.diag[i] /= value
	}
	return result
}
func (array *sparseDiagF64Matrix) ItemProd(value float64) NDArray {
	result := array.copy()
	for i := 0; i < len(result.diag); i++ {
		result.diag[i] *= value
	}
	return result
}
func (array *sparseDiagF64Matrix) ItemSub(value float64) NDArray {
	result := &denseF64Array{
		shape: make([]int, 2),
		array: make([]float64, array.shape[0]*array.shape[1]),
	}
	copy(result.shape[:], array.shape[:])
	flat := 0
	for row := 0; row < array.shape[0]; row++ {
		for col := 0; col < array.shape[1]; col++ {
			if row == col {
				result.array[flat] = array.diag[row] - value
			} else {
				result.array[flat] = -value
			}
			flat++
		}
	}
	return result
}
func (array sparseDiagF64Matrix) ItemSet(value float64, index ...int) {
	if len(index) != 2 || index[0] >= array.shape[0] || index[1] >= array.shape[1] {
		panic(fmt.Sprintf("ItemSet indices %v invalid for array shape %v", index, array.shape))
	} else if index[0] != index[1] {
		panic(fmt.Sprintf("ItemSet indices %v invalid for sparse diagonal array", index))
	}
	array.diag[index[0]] = value
}
func (array sparseDiagF64Matrix) LDivide(b Matrix) Matrix {
	return LDivide(&array, b)
}
func (array sparseDiagF64Matrix) MProd(others ...Matrix) Matrix {
	return MProd(&array, others...)
}
func (array sparseDiagF64Matrix) Max() float64 {
	return Max(&array)
}
func (array sparseDiagF64Matrix) Min() float64 {
	return Min(&array)
}
func (array sparseDiagF64Matrix) NDim() int {
	return len(array.shape)
}
func (array sparseDiagF64Matrix) Norm(ord float64) float64 {
	return Norm(&array, ord)
}
func (array *sparseDiagF64Matrix) Normalize() NDArray {
	return Normalize(array)
}
func (array sparseDiagF64Matrix) Prod(other ...NDArray) NDArray {
	return Prod(&array, other...)
}
func (array sparseDiagF64Matrix) Ravel() NDArray {
	return Ravel(&array)
}
func (array sparseDiagF64Matrix) RowSet(row int, values []float64) {
	if row < 0 || row >= array.shape[0] {
		panic(fmt.Sprintf("RowSet can't set row %d of a %d-row array", row, array.shape[0]))
	} else if len(values) != array.shape[1] {
		panic(fmt.Sprintf("RowSet has %d columns but got %d values", array.shape[1], len(values)))
	}
	for col := 0; col < array.shape[1]; col++ {
		if row != col {
			if values[col] != 0 {
				panic(fmt.Sprintf("RowSet can't set cell (%d, %d) of a %dx%d sparse diagonal matrix", row, col, array.shape[0], array.shape[1]))
			}
		} else {
			array.diag[col] = values[col]
		}
	}
}
func (array sparseDiagF64Matrix) Row(row int) []float64 {
	if row < 0 || row >= array.shape[0] {
		panic(fmt.Sprintf("Can't get row %d from a %dx%d array", row, array.shape[0], array.shape[1]))
	}
	result := make([]float64, array.shape[0])
	result[row] = array.diag[row]
	return result
}
func (array sparseDiagF64Matrix) Rows() int {
	return array.shape[0]
}
func (array sparseDiagF64Matrix) Shape() []int {
	return array.shape
}
func (array sparseDiagF64Matrix) Size() int {
	return array.shape[0] * array.shape[1]
}