func (tsr *Float64) CopyCellsFrom(frm Tensor, to, start, n int) {
	if fsm, ok := frm.(*Float64); ok {
		for i := 0; i < n; i++ {
			tsr.Values[to+i] = fsm.Values[start+i]
			if fsm.IsNull1D(start + i) {
				tsr.SetNull1D(to+i, true)
			}
		}
		return
	}
	for i := 0; i < n; i++ {
		tsr.Values[to+i] = float64(frm.FloatVal1D(start + i))
		if frm.IsNull1D(start + i) {
			tsr.SetNull1D(to+i, true)
		}
	}
}
CopyCellsFrom copies given range of values from other tensor into this tensor,
using flat 1D indexes: to = starting index in this Tensor to start copying into,
start = starting index on from Tensor to start copying from, and n = number of
values to copy.  Uses an optimized implementation if the other tensor is
of the same type, and otherwise it goes through appropriate standard type.
package etensor
import (
	"errors"
	"fmt"
	"log"
	"math"
	"strconv"
	"strings"
	"github.com/apache/arrow/go/arrow/array"
	"github.com/apache/arrow/go/arrow/memory"
	"github.com/apache/arrow/go/arrow/tensor"
	"github.com/emer/etable/bitslice"
	"github.com/goki/ki/ints"
	"github.com/goki/ki/kit"
	"gonum.org/v1/gonum/mat"
)
type Float64 struct {
	Shape
	Values []float64
	Nulls  bitslice.Slice
	Meta   map[string]string
}
func NewFloat64(shape, strides []int, names []string) *Float64 {
	tsr := &Float64{}
	tsr.SetShape(shape, strides, names)
	tsr.Values = make([]float64, tsr.Len())
	return tsr
}
func NewFloat64Shape(shape *Shape, vals []float64) *Float64 {
	tsr := &Float64{}
	tsr.CopyShape(shape)
	if vals != nil {
		if len(vals) != tsr.Len() {
			log.Printf("etensor.New*Shape: length of provided vals: %d not proper length: %d", len(vals), tsr.Len())
			tsr.Values = make([]float64, tsr.Len())
		} else {
			tsr.Values = vals
		}
	} else {
		tsr.Values = make([]float64, tsr.Len())
	}
	return tsr
}
func (tsr *Float64) ShapeObj() *Shape         { return &tsr.Shape }
func (tsr *Float64) DataType() Type           { return FLOAT64 }
func (tsr *Float64) Value(i []int) float64    { j := tsr.Offset(i); return tsr.Values[j] }
func (tsr *Float64) Value1D(i int) float64    { return tsr.Values[i] }
func (tsr *Float64) Set(i []int, val float64) { j := tsr.Offset(i); tsr.Values[j] = val }
func (tsr *Float64) Set1D(i int, val float64) { tsr.Values[i] = val }
func (tsr *Float64) IsNull(i []int) bool {
	if tsr.Nulls == nil {
		return false
	}
	j := tsr.Offset(i)
	return tsr.Nulls.Index(j)
}
func (tsr *Float64) IsNull1D(i int) bool {
	if tsr.Nulls == nil {
		return false
	}
	return tsr.Nulls.Index(i)
}
func (tsr *Float64) SetNull(i []int, nul bool) {
	if tsr.Nulls == nil {
		tsr.Nulls = bitslice.Make(tsr.Len(), 0)
	}
	j := tsr.Offset(i)
	tsr.Nulls.Set(j, nul)
}
func (tsr *Float64) SetNull1D(i int, nul bool) {
	if tsr.Nulls == nil {
		tsr.Nulls = bitslice.Make(tsr.Len(), 0)
	}
	tsr.Nulls.Set(i, nul)
}
func (tsr *Float64) FloatVal(i []int) float64      { j := tsr.Offset(i); return float64(tsr.Values[j]) }
func (tsr *Float64) SetFloat(i []int, val float64) { j := tsr.Offset(i); tsr.Values[j] = float64(val) }
func (tsr *Float64) StringVal(i []int) string { j := tsr.Offset(i); return kit.ToString(tsr.Values[j]) }
func (tsr *Float64) SetString(i []int, val string) {
	if fv, err := strconv.ParseFloat(val, 64); err == nil {
		j := tsr.Offset(i)
		tsr.Values[j] = float64(fv)
	}
}
func (tsr *Float64) FloatVal1D(off int) float64      { return float64(tsr.Values[off]) }
func (tsr *Float64) SetFloat1D(off int, val float64) { tsr.Values[off] = float64(val) }
func (tsr *Float64) FloatValRowCell(row, cell int) float64 {
	_, sz := tsr.RowCellSize()
	return float64(tsr.Values[row*sz+cell])
}
func (tsr *Float64) SetFloatRowCell(row, cell int, val float64) {
	_, sz := tsr.RowCellSize()
	tsr.Values[row*sz+cell] = float64(val)
}
func (tsr *Float64) Floats(flt *[]float64) {
	SetFloat64SliceLen(flt, len(tsr.Values))
	copy(*flt, tsr.Values)  
}
func (tsr *Float64) SetFloats(vals []float64) {
	copy(tsr.Values, vals)  
}
func (tsr *Float64) StringVal1D(off int) string { return kit.ToString(tsr.Values[off]) }
func (tsr *Float64) SetString1D(off int, val string) {
	if fv, err := strconv.ParseFloat(val, 64); err == nil {
		tsr.Values[off] = float64(fv)
	}
}
func (tsr *Float64) StringValRowCell(row, cell int) string {
	_, sz := tsr.RowCellSize()
	return kit.ToString(tsr.Values[row*sz+cell])
}
func (tsr *Float64) SetStringRowCell(row, cell int, val string) {
	if fv, err := strconv.ParseFloat(val, 64); err == nil {
		_, sz := tsr.RowCellSize()
		tsr.Values[row*sz+cell] = float64(fv)
	}
}
func (tsr *Float64) Range() (min, max float64, minIdx, maxIdx int) {
	minIdx = -1
	maxIdx = -1
	for j, vl := range tsr.Values {
		fv := float64(vl)
		if math.IsNaN(fv) {
			continue
		}
		if fv < min || minIdx < 0 {
			min = fv
			minIdx = j
		}
		if fv > max || maxIdx < 0 {
			max = fv
			maxIdx = j
		}
	}
	return
}
func (tsr *Float64) Agg(ini float64, fun AggFunc) float64 {
	ag := ini
	for j, vl := range tsr.Values {
		val := float64(vl)
		if !tsr.IsNull1D(j) && !math.IsNaN(val) {
			ag = fun(j, val, ag)
		}
	}
	return ag
}
func (tsr *Float64) Eval(res *[]float64, fun EvalFunc) {
	ln := tsr.Len()
	if len(*res) != ln {
		*res = make([]float64, ln)
	}
	for j, vl := range tsr.Values {
		val := float64(vl)
		if !tsr.IsNull1D(j) && !math.IsNaN(val) {
			(*res)[j] = fun(j, val)
		}
	}
}
func (tsr *Float64) SetFunc(fun EvalFunc) {
	for j, vl := range tsr.Values {
		val := float64(vl)
		if !tsr.IsNull1D(j) && !math.IsNaN(val) {
			tsr.Values[j] = float64(fun(j, val))
		}
	}
}
func (tsr *Float64) SetZeros() {
	for j := range tsr.Values {
		tsr.Values[j] = 0
	}
}
func (tsr *Float64) Clone() Tensor {
	csr := NewFloat64Shape(&tsr.Shape, nil)
	copy(csr.Values, tsr.Values)
	if tsr.Nulls != nil {
		csr.Nulls = tsr.Nulls.Clone()
	}
	return csr
}
func (tsr *Float64) CopyFrom(frm Tensor) {
	if fsm, ok := frm.(*Float64); ok {
		copy(tsr.Values, fsm.Values)
		if fsm.Nulls != nil {
			if tsr.Nulls == nil {
				tsr.Nulls = bitslice.Make(tsr.Len(), 0)
			}
			copy(tsr.Nulls, fsm.Nulls)
		}
		return
	}
	sz := ints.MinInt(len(tsr.Values), frm.Len())
	for i := 0; i < sz; i++ {
		tsr.Values[i] = float64(frm.FloatVal1D(i))
		if frm.IsNull1D(i) {
			tsr.SetNull1D(i, true)
		}
	}
}
func (tsr *Float64) CopyShapeFrom(frm Tensor) {
	tsr.SetShape(frm.Shapes(), frm.Strides(), frm.DimNames())
}