本文整理匯總了Golang中github.com/mumax/3/data.Slice.Comp方法的典型用法代碼示例。如果您正苦於以下問題:Golang Slice.Comp方法的具體用法?Golang Slice.Comp怎麽用?Golang Slice.Comp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mumax/3/data.Slice
的用法示例。
在下文中一共展示了Slice.Comp方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: mul1N
// mul1N pointwise multiplies a scalar (1-component) with an N-component vector,
// yielding an N-component vector stored in dst.
func mul1N(dst, a, b *data.Slice) {
util.Assert(a.NComp() == 1)
util.Assert(dst.NComp() == b.NComp())
for c := 0; c < dst.NComp(); c++ {
cuda.Mul(dst.Comp(c), a, b.Comp(c))
}
}
示例2: divN1
func divN1(dst, a, b *data.Slice) {
util.Assert(dst.NComp() == a.NComp())
util.Assert(b.NComp() == 1)
for c := 0; c < dst.NComp(); c++ {
cuda.Div(dst.Comp(c), a.Comp(c), b)
}
}
示例3: sAverageUniverse
// average of slice over universe
func sAverageUniverse(s *data.Slice) []float64 {
nCell := float64(prod(s.Size()))
avg := make([]float64, s.NComp())
for i := range avg {
avg[i] = float64(cuda.Sum(s.Comp(i))) / nCell
checkNaN1(avg[i])
}
return avg
}
示例4: shiftMag
func shiftMag(m *data.Slice, dx int) {
m2 := cuda.Buffer(1, m.Size())
defer cuda.Recycle(m2)
for c := 0; c < m.NComp(); c++ {
comp := m.Comp(c)
cuda.ShiftX(m2, comp, dx, float32(ShiftMagL[c]), float32(ShiftMagR[c]))
data.Copy(comp, m2) // str0 ?
}
}
示例5: sAverageMagnet
// average of slice over the magnet volume
func sAverageMagnet(s *data.Slice) []float64 {
if geometry.Gpu().IsNil() {
return sAverageUniverse(s)
} else {
avg := make([]float64, s.NComp())
for i := range avg {
avg[i] = float64(cuda.Dot(s.Comp(i), geometry.Gpu())) / magnetNCell()
checkNaN1(avg[i])
}
return avg
}
}
示例6: Exec
// store MFM image in output, based on magnetization in inp.
func (c *MFMConvolution) Exec(outp, inp, vol *data.Slice, Bsat LUTPtr, regions *Bytes) {
for i := 0; i < 3; i++ {
zero1_async(c.fftRBuf)
copyPadMul(c.fftRBuf, inp.Comp(i), vol, c.kernSize, c.size, Bsat, regions)
c.fwPlan.ExecAsync(c.fftRBuf, c.fftCBuf)
Nx, Ny := c.fftKernSize[X]/2, c.fftKernSize[Y] // ??
kernMulC_async(c.fftCBuf, c.gpuFFTKern[i], Nx, Ny)
c.bwPlan.ExecAsync(c.fftCBuf, c.fftRBuf)
copyUnPad(outp.Comp(i), c.fftRBuf, c.size, c.kernSize)
}
}
示例7: SetMFull
// Sets dst to the full (unnormalized) magnetization in A/m
func SetMFull(dst *data.Slice) {
// scale m by Msat...
msat, rM := Msat.Slice()
if rM {
defer cuda.Recycle(msat)
}
for c := 0; c < 3; c++ {
cuda.Mul(dst.Comp(c), M.Buffer().Comp(c), msat)
}
// ...and by cell volume if applicable
vol, rV := geometry.Slice()
if rV {
defer cuda.Recycle(vol)
}
if !vol.IsNil() {
for c := 0; c < 3; c++ {
cuda.Mul(dst.Comp(c), dst.Comp(c), vol)
}
}
}
示例8: fwFFT
// forward FFT component i
func (c *DemagConvolution) fwFFT(i int, inp, vol *data.Slice, Bsat LUTPtr, regions *Bytes) {
zero1_async(c.fftRBuf[i])
in := inp.Comp(i)
copyPadMul(c.fftRBuf[i], in, vol, c.realKernSize, c.inputSize, Bsat, regions)
c.fwPlan.ExecAsync(c.fftRBuf[i], c.fftCBuf[i])
}
示例9: bwFFT
// backward FFT component i
func (c *DemagConvolution) bwFFT(i int, outp *data.Slice) {
c.bwPlan.ExecAsync(c.fftCBuf[i], c.fftRBuf[i])
out := outp.Comp(i)
copyUnPad(out, c.fftRBuf[i], c.inputSize, c.realKernSize)
}
示例10: EvalTo
func (d *constValue) EvalTo(dst *data.Slice) {
for c, v := range d.value {
cuda.Memset(dst.Comp(c), float32(v))
}
}
示例11: fwFFT
// forward FFT component i
func (c *DemagConvolution) fwFFT(i int, inp, vol *data.Slice, Msat MSlice) {
zero1_async(c.fftRBuf[i])
in := inp.Comp(i)
copyPadMul(c.fftRBuf[i], in, vol, c.realKernSize, c.inputSize, Msat)
c.fwPlan.ExecAsync(c.fftRBuf[i], c.fftCBuf[i])
}