gonum.org/v1/gonum@v0.14.0/stat/distmv/general.go (about) 1 // Copyright ©2015 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package distmv 6 7 const ( 8 badQuantile = "distmv: quantile not between 0 and 1" 9 badReceiver = "distmv: input slice is not nil or the correct length" 10 badSizeMismatch = "distmv: size mismatch" 11 badZeroDimension = "distmv: zero dimensional input" 12 nonPosDimension = "distmv: non-positive dimension input" 13 ) 14 15 const logTwoPi = 1.8378770664093454835606594728112352797227949472755668 16 17 // useAs gets a slice of size n. If len(x) == n, x is returned, if len(x) == 0 18 // then a slice is returned of length n. 19 func reuseAs(x []float64, n int) []float64 { 20 if len(x) == n { 21 return x 22 } 23 if len(x) == 0 { 24 if cap(x) >= n { 25 return x[:n] 26 } 27 return make([]float64, n) 28 } 29 panic(badReceiver) 30 }