Debian Codegraph @

scan.go

raw symbols SCIP
1 package bigfftscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/
2
3 import (
4 "math/bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/"
5 )
6
7 // FromDecimalString converts the base 10 string
8 // representation of a natural (non-negative) number
9 // into a *big.Int.
10 // Its asymptotic complexity is less than quadratic.
11 func FromDecimalStringscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/FromDecimalString().(s string) *bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int# {
12 var sc scannerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#
13 z := new(bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#)
14 sc.scanscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#scan().(z, s)
15 return z
16 }
17
18 type scannerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner# struct {
19 // powers[i] is 10^(2^i * quadraticScanThreshold).
20 powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers. []*bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#
21 }
22
23 func (s *scannerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#) chunkSizescip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#chunkSize().(size int) (int, *bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#) {
24 if size <= quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold. {
25 panic("size < quadraticScanThreshold")
26 }
27 pow := uint(0)
28 for n := size; n > quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold.; n /= 2 {
29 pow++
30 }
31 // threshold * 2^(pow-1) <= size < threshold * 2^pow
32 return quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold. << (pow - 1), s.powerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#power().(pow - 1)
33 }
34
35 func (s *scannerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#) powerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#power().(k uint) *bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int# {
36 for i := len(s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers.); i <= int(k); i++ {
37 z := new(bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#)
38 if i == 0 {
39 if quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold.%14 != 0 {
40 panic("quadraticScanThreshold % 14 != 0")
41 }
42 z.Expscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#Exp().(bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.NewIntscip-go gomod github.com/golang/go/src go1.12 `math/big`/NewInt().(1e14), bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.NewIntscip-go gomod github.com/golang/go/src go1.12 `math/big`/NewInt().(quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold./14), nil)
43 } else {
44 z.Mulscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#Mul().(s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers.[i-1], s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers.[i-1])
45 }
46 s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers. = append(s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers., z)
47 }
48 return s.powersscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#powers.[k]
49 }
50
51 func (s *scannerscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#) scanscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#scan().(z *bigscip-go gomod github.com/golang/go/src go1.12 `math/big`/.Intscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#, str string) {
52 if len(str) <= quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold. {
53 z.SetStringscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#SetString().(str, 10)
54 return
55 }
56 sz, pow := s.chunkSizescip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#chunkSize().(len(str))
57 // Scan the left half.
58 s.scanscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#scan().(z, str[:len(str)-sz])
59 // FIXME: reuse temporaries.
60 left := Mulscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/Mul().(z, pow)
61 // Scan the right half
62 s.scanscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/scanner#scan().(z, str[len(str)-sz:])
63 z.Addscip-go gomod github.com/golang/go/src go1.12 `math/big`/Int#Add().(z, left)
64 }
65
66 // quadraticScanThreshold is the number of digits
67 // below which big.Int.SetString is more efficient
68 // than subquadratic algorithms.
69 // 1232 digits fit in 4096 bits.
70 const quadraticScanThresholdscip-go gomod github.com/remyoudompheng/bigfft . `github.com/remyoudompheng/bigfft`/quadraticScanThreshold. = 1232