func (array denseF64Array) Visit(f func(pos []int, value float64) bool) bool {
	for flat, value := range array.array {
		var pos []int
		if array.transpose {
			pOrig := flatToNd([]int{array.shape[1], array.shape[0]}, flat)
			pos = []int{pOrig[1], pOrig[0]}
		} else {
			pos = flatToNd(array.shape, flat)
		}
		if !f(pos, value) {
			return false
		}
	}
	return true
}
Visit all matrix elements, invoking a method on each. If the method
returns false, iteration is aborted and VisitNonzero() returns false.
Otherwise, it returns true.
package matrix
import (
	"fmt"
)
type denseF64Array struct {
	shape     []int
	array     []float64
	transpose bool
}
func (array denseF64Array) Add(other ...NDArray) NDArray {
	return Add(&array, other...)
}
func (array denseF64Array) All() bool {
	return All(&array)
}
func (array denseF64Array) AllF(f func(v float64) bool) bool {
	return AllF(&array, f)
}
func (array denseF64Array) AllF2(f func(v1, v2 float64) bool, other NDArray) bool {
	return AllF2(&array, f, other)
}
func (array denseF64Array) Any() bool {
	return Any(&array)
}
func (array denseF64Array) AnyF(f func(v float64) bool) bool {
	return AnyF(&array, f)
}
func (array denseF64Array) AnyF2(f func(v1, v2 float64) bool, other NDArray) bool {
	return AnyF2(&array, f, other)
}
func (array denseF64Array) Apply(f func(float64) float64) NDArray {
	result := array.copy()
	for i, val := range result.array {
		result.array[i] = f(val)
	}
	return result
}
func (array denseF64Array) Array() []float64 {
	if array.transpose {
		return array.copy().array
	} else {
		return array.array
	}
}
func (array denseF64Array) 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++ {
		array.ItemSet(values[row], row, col)
	}
}
func (array denseF64Array) 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[0])
	for row := 0; row < array.shape[0]; row++ {
		result[row] = array.Item(row, col)
	}
	return result
}
func (array denseF64Array) Cols() int {
	return array.shape[1]
}
func (array denseF64Array) Concat(axis int, others ...NDArray) NDArray {
	return Concat(axis, &array, others...)
}
func (array denseF64Array) Copy() NDArray {
	return array.copy()
}
func (array denseF64Array) copy() *denseF64Array {
	result := &denseF64Array{
		shape: make([]int, len(array.shape)),
		array: make([]float64, len(array.array)),
	}
	copy(result.shape[:], array.shape[:])
	if array.transpose {
		for i0 := 0; i0 < array.shape[0]; i0++ {
			for i1 := 0; i1 < array.shape[1]; i1++ {
				result.ItemSet(array.Item(i0, i1), i0, i1)
			}
		}
	} else {
		copy(result.array[:], array.array[:])
	}
	return result
}
func (array denseF64Array) CountNonzero() int {
	count := 0
	for _, v := range array.array {
		if v != 0 {
			count++
		}
	}
	return count
}
func (array denseF64Array) Dense() NDArray {
	return array.copy()
}
func (array denseF64Array) Diag() Matrix {
	size := array.shape[0]
	if array.shape[1] < size {
		size = array.shape[1]
	}
	result := Dense(size, 1).M()
	for i := 0; i < size; i++ {
		result.ItemSet(array.Item(i, i), i, 0)
	}
	return result
}
func (array denseF64Array) Dist(t DistType) Matrix {
	return Dist(&array, t)
}
func (array denseF64Array) Div(other ...NDArray) NDArray {
	return Div(&array, other...)
}
func (array denseF64Array) Equal(other NDArray) bool {
	return Equal(&array, other)
}
func (array denseF64Array) Fill(value float64) {
	Fill(&array, value)
}
func (array denseF64Array) FlatCoord(index int) []int {
	return flatToNd(array.shape, index)
}
func (array denseF64Array) FlatItem(index int) float64 {
	if array.transpose {
		nd := flatToNd(array.shape, index)
		index = ndToFlat([]int{array.shape[1], array.shape[0]}, []int{nd[1], nd[0]})
	}
	return array.array[index]
}
func (array denseF64Array) FlatItemSet(value float64, index int) {
	if array.transpose {
		nd := flatToNd(array.shape, index)
		index = ndToFlat([]int{array.shape[1], array.shape[0]}, []int{nd[1], nd[0]})
	}
	array.array[index] = value
}
func (array denseF64Array) Inverse() (Matrix, error) {
	return Inverse(&array)
}
func (array denseF64Array) Item(index ...int) float64 {
	shape := array.shape
	if array.transpose {
		index[0], index[1] = index[1], index[0]
		shape = []int{array.shape[1], array.shape[0]}
	}
	return array.array[ndToFlat(shape, index)]
}
func (array *denseF64Array) ItemAdd(value float64) NDArray {
	result := array.copy()
	for idx := range result.array {
		result.array[idx] += value
	}
	return result
}
func (array *denseF64Array) ItemDiv(value float64) NDArray {
	result := array.copy()
	for idx := range result.array {
		result.array[idx] /= value
	}
	return result
}
func (array *denseF64Array) ItemProd(value float64) NDArray {
	result := array.copy()
	for idx := range result.array {
		result.array[idx] *= value
	}
	return result
}
func (array *denseF64Array) ItemSub(value float64) NDArray {
	result := array.copy()
	for idx := range result.array {
		result.array[idx] -= value
	}
	return result
}
func (array denseF64Array) ItemSet(value float64, index ...int) {
	shape := array.shape
	if array.transpose {
		index[0], index[1] = index[1], index[0]
		shape = []int{array.shape[1], array.shape[0]}
	}
	array.array[ndToFlat(shape, index)] = value
}
func (array denseF64Array) LDivide(b Matrix) Matrix {
	return LDivide(&array, b)
}
func (array denseF64Array) MProd(others ...Matrix) Matrix {
	return MProd(&array, others...)
}
func (array denseF64Array) Max() float64 {
	return Max(&array)
}
func (array denseF64Array) Min() float64 {
	return Min(&array)
}
func (array denseF64Array) NDim() int {
	return len(array.shape)
}
func (array denseF64Array) Norm(ord float64) float64 {
	return Norm(&array, ord)
}
func (array *denseF64Array) Normalize() NDArray {
	return Normalize(array)
}
func (array denseF64Array) Prod(other ...NDArray) NDArray {
	return Prod(&array, other...)
}
func (array denseF64Array) Ravel() NDArray {
	return Ravel(&array)
}
func (array denseF64Array) 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++ {
		array.ItemSet(values[col], row, col)
	}
}
func (array denseF64Array) 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]))
	}
	start := ndToFlat(array.shape, []int{row, 0})
	return array.array[start : start+array.shape[1]]
}
func (array denseF64Array) Rows() int {
	return array.shape[0]
}
func (array denseF64Array) Shape() []int {
	return array.shape
}
func (array denseF64Array) Size() int {
	return len(array.array)
}
func (array denseF64Array) Slice(from []int, to []int) NDArray {
	return Slice(&array, from, to)
}
func (array denseF64Array) SparseCoo() Matrix {
	m := SparseCoo(array.shape[0], array.shape[1])
	array.VisitNonzero(func(pos []int, value float64) bool {
		m.ItemSet(value, pos[0], pos[1])
		return true
	})
	return m
}
func (array denseF64Array) SparseDiag() Matrix {
	m := SparseDiag(array.shape[0], array.shape[1])
	array.VisitNonzero(func(pos []int, value float64) bool {
		m.ItemSet(value, pos[0], pos[1])
		return true
	})
	return m
}
func (array denseF64Array) Sparsity() ArraySparsity {
	return DenseArray
}
func (array denseF64Array) Sub(other ...NDArray) NDArray {
	return Sub(&array, other...)
}
func (array denseF64Array) Sum() float64 {
	return Sum(&array)
}
func (array denseF64Array) M() Matrix {
	switch array.NDim() {
	default:
		panic(fmt.Sprintf("Cannot convert a %d-dim array into a matrix", array.NDim()))
	case 1:
		return &denseF64Array{
			shape:     []int{array.shape[0], 1},
			array:     array.array,
			transpose: array.transpose,
		}
	case 2:
		return &array
	}
}
func (array denseF64Array) T() Matrix {
	return &denseF64Array{
		shape:     []int{array.shape[1], array.shape[0]},
		array:     array.array,
		transpose: !array.transpose,
	}
}