summaryrefslogtreecommitdiff
path: root/src/pkg/math/rand
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-05-14 18:39:35 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-05-14 18:39:35 +0200
commitefcc50dfdc94c82ee0292bf71992ecb7c0123061 (patch)
tree17dca99d1dc7fc4e9fe49c2cf6a99d337d4c039f /src/pkg/math/rand
parent04b08da9af0c450d645ab7389d1467308cfc2db8 (diff)
downloadgolang-efcc50dfdc94c82ee0292bf71992ecb7c0123061.tar.gz
Imported Upstream version 1.1upstream/1.1
Diffstat (limited to 'src/pkg/math/rand')
-rw-r--r--src/pkg/math/rand/exp.go1
-rw-r--r--src/pkg/math/rand/normal.go1
-rw-r--r--src/pkg/math/rand/zipf.go6
3 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/math/rand/exp.go b/src/pkg/math/rand/exp.go
index 85da49521..4bc110f91 100644
--- a/src/pkg/math/rand/exp.go
+++ b/src/pkg/math/rand/exp.go
@@ -43,7 +43,6 @@ func (r *Rand) ExpFloat64() float64 {
return x
}
}
- panic("unreachable")
}
var ke = [256]uint32{
diff --git a/src/pkg/math/rand/normal.go b/src/pkg/math/rand/normal.go
index 9ab46db9f..ba4ea54ca 100644
--- a/src/pkg/math/rand/normal.go
+++ b/src/pkg/math/rand/normal.go
@@ -63,7 +63,6 @@ func (r *Rand) NormFloat64() float64 {
return x
}
}
- panic("unreachable")
}
var kn = [128]uint32{
diff --git a/src/pkg/math/rand/zipf.go b/src/pkg/math/rand/zipf.go
index 38e8ec516..8db2c6f5b 100644
--- a/src/pkg/math/rand/zipf.go
+++ b/src/pkg/math/rand/zipf.go
@@ -34,7 +34,6 @@ func (z *Zipf) hinv(x float64) float64 {
// NewZipf returns a Zipf generating variates p(k) on [0, imax]
// proportional to (v+k)**(-s) where s>1 and k>=0, and v>=1.
-//
func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf {
z := new(Zipf)
if s <= 1.0 || v < 1 {
@@ -52,9 +51,12 @@ func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf {
return z
}
-// Uint64 returns a value drawn from the Zipf distributed described
+// Uint64 returns a value drawn from the Zipf distribution described
// by the Zipf object.
func (z *Zipf) Uint64() uint64 {
+ if z == nil {
+ panic("rand: nil Zipf")
+ }
k := 0.0
for {