| 1 | // Copyright ©2011-2012 The bíogo 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 utilscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/ |
| 6 | |
| 7 | import ( |
| 8 | "mathscip-go gomod github.com/golang/go/src go1.14 math/" |
| 9 | ) |
| 10 | |
| 11 | const ( |
| 12 | MaxUintscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MaxUint. = ^uint(0) // The maximum uint value. |
| 13 | MinUintscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MinUint. = uint(0) // The minimum uint value. |
| 14 | MaxIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MaxInt. = int(^uint(0) >> 1) // The maximum int value. |
| 15 | MinIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MinInt. = -MaxIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MaxInt. - 1 // The minimum int value. |
| 16 | Ln4scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Ln4. = 1.3862943611198906188344642429163531361510002687205105082413 // The natural log of 4. |
| 17 | ) |
| 18 | |
| 19 | // Returns the minimum int of a... |
| 20 | func Minscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Min().(a ...int) (min int) { |
| 21 | min = MaxIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MaxInt. |
| 22 | for _, i := range a { |
| 23 | if i < min { |
| 24 | min = i |
| 25 | } |
| 26 | } |
| 27 | return |
| 28 | } |
| 29 | |
| 30 | // Returns the minimum uint of a... |
| 31 | func UMinscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/UMin().(a ...uint) (min uint) { |
| 32 | min = MaxUintscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MaxUint. |
| 33 | for _, i := range a { |
| 34 | if i < min { |
| 35 | min = i |
| 36 | } |
| 37 | } |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | // Returns the maximum int of a... |
| 42 | func Maxscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Max().(a ...int) (max int) { |
| 43 | max = MinIntscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MinInt. |
| 44 | for _, i := range a { |
| 45 | if i > max { |
| 46 | max = i |
| 47 | } |
| 48 | } |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | // Returns the maximum uint of a... |
| 53 | func UMaxscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/UMax().(a ...uint) (max uint) { |
| 54 | max = MinUintscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/MinUint. |
| 55 | for _, i := range a { |
| 56 | if i > max { |
| 57 | max = i |
| 58 | } |
| 59 | } |
| 60 | return |
| 61 | } |
| 62 | |
| 63 | // Return the exp'th power of base. |
| 64 | func Powscip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Pow().(base int, exp byte) (r int) { |
| 65 | r = 1 |
| 66 | for exp > 0 { |
| 67 | if exp&1 != 0 { |
| 68 | r *= base |
| 69 | } |
| 70 | exp >>= 1 |
| 71 | base *= base |
| 72 | } |
| 73 | |
| 74 | return |
| 75 | } |
| 76 | |
| 77 | // Returns the nth power of 4. |
| 78 | func Pow4scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Pow4().(n int) uint { |
| 79 | return uint(1) << (2 * uint(n)) |
| 80 | } |
| 81 | |
| 82 | // Returns the log base 4 of x. |
| 83 | func Log4scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Log4().(x float64) float64 { |
| 84 | return mathscip-go gomod github.com/golang/go/src go1.14 math/.Logscip-go gomod github.com/golang/go/src go1.14 math/Log().(x) / Ln4scip-go gomod github.com/biogo/biogo . `github.com/biogo/biogo/util`/Ln4. |
| 85 | } |