func (s *subcycleState) setupWorkspace(X, weights []float64) {
	var xxx [][][]float64
	var err error
	if xxx, err = native.Tensor3F64(s.data); err != nil {
		panic(errors.Wrap(err, "setup workspace"))
	}
	for p := 0; p < s.periods; p++ {
		l := s.periodicity
		if p < s.rem {
			l = s.periodicity + 1
		}
		for i := 0; i < l && i*s.periodicity+p < len(X); i++ {
			xxx[0][p][i] = X[i*s.periodicity+p]
			if len(weights) > 0 {
				xxx[1][p][i] = weights[i*s.periodicity+p]
			}
		}
	}
}
setupWorkspace sets up the workspace by copying the data to the tensor.
Due to the periodicity in question, a direct copy wouldn't really work
package stl
import (
	"math"
	"github.com/chewxy/stl/loess"
	"github.com/pkg/errors"
	"gorgonia.org/tensor"
	"gorgonia.org/tensor/native"
)
type subcycleState struct {
	data     *tensor.Dense
	smoothed *tensor.Dense  
	periodicity, periods, rem, fwd, bwd int
	Config  
}
func newSubcycleState(conf Config, size, periodicity, fwd, bwd int) *subcycleState {
	periods := size / periodicity
	rem := size % periodicity
	cycleLength := periodicity + 1
	if rem == 0 {
		cycleLength = periodicity
	}
	smoothedLength := cycleLength + fwd + bwd
	retVal := &subcycleState{
		data:     tensor.New(tensor.WithShape(2, periods, cycleLength), tensor.Of(tensor.Float64), tensor.WithEngine(tensor.Float64Engine{})),
		smoothed: tensor.New(tensor.WithShape(periods, smoothedLength), tensor.Of(tensor.Float64), tensor.WithEngine(tensor.Float64Engine{})),
		periodicity: periodicity,
		periods:     periods,
		rem:         rem,
		fwd:         fwd,
		bwd:         bwd,
		Config: conf,
	}
	return retVal
}
func (s *subcycleState) smoothSeasonal(X []float64, weights []float64, retVal []float64) error {
	s.setupWorkspace(X, weights)
	if err := s.computeSmoothedSubSeries(); err != nil {
		return err
	}
	copy(retVal, s.smoothed.Data().([]float64))
	return nil
}