func (b *magnetization) SetArray(src *data.Slice) { if src.Size() != b.Mesh().Size() { src = data.Resample(src, b.Mesh().Size()) } data.Copy(b.Buffer(), src) M.normalize() }
func (m *magnetization) resize() { backup := m.Buffer().HostCopy() s2 := Mesh().Size() resized := data.Resample(backup, s2) m.buffer_.Free() m.buffer_ = cuda.NewSlice(VECTOR, s2) data.Copy(m.buffer_, resized) }
// An Add(mask, f) equivalent for Go use func (e *excitation) AddGo(mask *data.Slice, mul func() float64) { if mask != nil { checkNaN(mask, e.Name()+".add()") // TODO: in more places mask = data.Resample(mask, e.Mesh().Size()) mask = assureGPU(mask) } e.extraTerms = append(e.extraTerms, mulmask{mul, mask}) }
// Load regions from ovf file, use first component. // Regions should be between 0 and 256 func (r *Regions) LoadFile(fname string) { inSlice := LoadFile(fname) n := r.Mesh().Size() inSlice = data.Resample(inSlice, n) inArr := inSlice.Tensors()[0] l := r.HostList() arr := reshapeBytes(l, n) for iz := 0; iz < n[Z]; iz++ { for iy := 0; iy < n[Y]; iy++ { for ix := 0; ix < n[X]; ix++ { val := inArr[iz][iy][ix] if val < 0 || val > 256 { util.Fatal("regions.LoadFile(", fname, "): all values should be between 0 & 256, have: ", val) } arr[iz][iy][ix] = byte(val) } } } r.gpuCache.Upload(l) }
func resize(f *data.Slice, arg string) { s := parseSize(arg) resized := data.Resample(f, s) *f = *resized }