func Multiplex(channels [][]float64) []float64 {
	numChans := len(channels)
	chanLen := len(channels[0])
	buf := make([]float64, numChans*chanLen)
	for i := 0; i < chanLen; i++ {
		k := i * numChans
		for j := 0; j < numChans; j++ {
			buf[k+j] = channels[j][i]
		}
	}
	return buf
}
/*
Multiplex returns on vector with the element of vs interleaved
package godsp
import (
	"bufio"
	"bytes"
	"fmt"
	"io/ioutil"
	"math"
	"strconv"
	"strings"
	myioutil "github.com/goccmack/goutil/ioutil"
)
func Abs(x []float64) []float64 {
	x1 := make([]float64, len(x))
	for i, f := range x {
		x1[i] = math.Abs(f)
	}
	return x1
}
func AbsInt(x []int) []int {
	x1 := make([]int, len(x))
	for i, e := range x {
		if e < 0 {
			x1[i] = -e
		} else {
			x1[i] = e
		}
	}
	return x1
}
func AbsAll(X [][]float64) [][]float64 {
	x1 := make([][]float64, len(X))
	for i, x := range X {
		x1[i] = Abs(x)
	}
	return x1
}
func Average(x []float64) float64 {
	return Sum(x) / float64(len(x))
}
func DivS(x []float64, s float64) []float64 {
	y := make([]float64, len(x))
	for i := range x {
		y[i] = x[i] / s
	}
	return y
}
func DownSampleAll(xs [][]float64) [][]float64 {
	N := len(xs[0])
	for _, x := range xs {
		if len(x) < N {
			N = len(x)
		}
	}
	ys := make([][]float64, len(xs))
	for i, x := range xs {
		ys[i] = DownSample(x, len(x)/N)
	}
	return ys
}
func DownSample(x []float64, n int) []float64 {
	if len(x)%n != 0 {
		panic(fmt.Sprintf("len(x) (%d) is not an integer multiple of n (%d)", len(x), n))
	}
	x1 := make([]float64, len(x)/n)
	for i, j := 0, 0; j < len(x1); i, j = i+n, j+1 {
		x1[j] = x[i]
	}
	return x1
}
func FindMax(x []float64) (value float64, index int) {
	value, index = x[0], 0
	for i := 1; i < len(x)-1; i++ {
		if x[i] > value {
			value, index = x[i], i
		}
	}
	return
}
func FindMaxI(x []int) (value int, index int) {
	value, index = x[0], 0
	for i := 1; i < len(x)-1; i++ {
		if x[i] > value {
			value, index = x[i], i
		}
	}
	return
}
func FindMin(x []float64) (value float64, index int) {
	value, index = x[0], 0
	for i := 1; i < len(x)-1; i++ {
		if x[i] < value {
			value, index = x[i], i
		}
	}
	return
}
func Float32ToFloat64(x []float32) []float64 {
	y := make([]float64, len(x))
	for i, f := range x {
		y[i] = float64(f)
	}
	return y
}
func IsPowerOf2(x int) bool {
	return (x != 0) && ((x & (x - 1)) == 0)
}
func LoadFloats(fname string) []float64 {
	data, err := ioutil.ReadFile(fname)
	if err != nil {
		panic(err)
	}
	rdr := bufio.NewReader(bytes.NewBuffer(data))
	x := make([]float64, 0, 1024)
	for s, err := rdr.ReadString('\n'); err == nil; s, err = rdr.ReadString('\n') {
		f, err := strconv.ParseFloat(strings.TrimSuffix(s, "\n"), 64)
		if err != nil {
			panic(err)
		}
		x = append(x, f)
	}
	return x
}
func Log2(n int) int {
	return int(math.Log2(float64(n)))
}
func LowpassFilterAll(xs [][]float64, alpha float64) [][]float64 {
	ys := make([][]float64, len(xs))
	for i, x := range xs {
		ys[i] = LowpassFilter(x, alpha)
	}
	return ys
}
func LowpassFilter(x []float64, alpha float64) []float64 {
	y := make([]float64, len(x))
	y[0] = alpha * x[0]
	for i := 1; i < len(x); i++ {
		y[i] = y[i-1] + alpha*(x[i]-y[i-1])
	}
	return y
}
func Max(x []float64) float64 {
	max := x[0]
	for _, f := range x {
		if f > max {
			max = f
		}
	}
	return max
}
func MaxInt(x []int) int {
	max := x[0]
	for _, f := range x {
		if f > max {
			max = f
		}
	}
	return max
}
func MovAvg(x []float64, w int) []float64 {
	y := make([]float64, len(x))
	for i := w; i < len(x)-w; i++ {
		y[i] = Sum(x[i-w:i+w]) / float64(2*w)
	}
	return y
}