summaryrefslogtreecommitdiff
path: root/factor_info.go
diff options
context:
space:
mode:
Diffstat (limited to 'factor_info.go')
-rw-r--r--factor_info.go26
1 files changed, 8 insertions, 18 deletions
diff --git a/factor_info.go b/factor_info.go
index 522112a..03c81f3 100644
--- a/factor_info.go
+++ b/factor_info.go
@@ -32,7 +32,7 @@ type factorInfo struct {
// Whether or not this radix is part of any special factor-related classes.
// This is not calculated if the radix is too large - in this case
// this field will be nil.
- Type *factors.NumberType
+ Type factors.NumberType
// An estimate of the complexity of the radix's multiplication table.
// This is not calculated if the radix is too large - in this case
// this field will be nil.
@@ -58,20 +58,14 @@ const (
maxExtended = 1 << 32
)
-func getFactorInfo(radix uint, fullMap bool, largeCalc bool) *factorInfo {
+func getFactorInfo(radix uint, fullMap bool, exactMTCLarge bool) *factorInfo {
r_factors := factors.Factors(radix)
slices.Sort(r_factors)
- var r_type_ptr *factors.NumberType
- var mtc_ptr *uint64
- if radix < maxNormal || (largeCalc && radix < maxExtended) {
- r_type := factors.Type(uint32(radix))
- r_type_ptr = &r_type
- mtc := factors.MTC(uint64(radix))
+ var mtc_ptr *uint64 = nil
+ if radix < maxNormal || (exactMTCLarge && radix < maxExtended) {
+ mtc := factors.MTC(uint32(radix))
mtc_ptr = &mtc
- } else {
- r_type_ptr = nil
- mtc_ptr = nil
}
var digitMap []factors.DigitType
@@ -91,7 +85,7 @@ func getFactorInfo(radix uint, fullMap bool, largeCalc bool) *factorInfo {
return &factorInfo{radix, factors.PrimeFactorize(radix),
r_factors, factors.Score(radix), totativeCount, totativeRatio,
- factors.BasicRank(radix), r_type_ptr, mtc_ptr,
+ factors.BasicRank(radix), factors.Type(radix), mtc_ptr,
math.Log(float64(radix)), digitMap}
}
@@ -101,9 +95,7 @@ func (fi *factorInfo) writeTo(w io.Writer) {
fmt.Fprintln(w, "2345 Rank:", fi.BasicRank)
fmt.Fprintf(w, "Totative Digit Count: %d (%.3f%%)\n",
fi.Totient, fi.TotativeRatio*100.0)
- if fi.Type != nil {
- writeTypeMessage(w, *fi.Type)
- }
+ writeTypeMessage(w, fi.Type)
if fi.MTC != nil {
fmt.Fprintln(w, "Multiplication Table Complexity:", *fi.MTC)
} else {
@@ -122,9 +114,7 @@ func (fi *factorInfo) writeTo(w io.Writer) {
func (fi *factorInfo) writeToCompact(w io.Writer) {
fmt.Fprintf(w, "%d = %s | σ(r)/r: %.2f | φ(r)/r: %.3f\n",
fi.Radix, fi.PrimeFactorization, fi.Score, fi.TotativeRatio)
- if fi.Type != nil {
- fmt.Fprintf(w, "%s | ", typeAbbrev(*fi.Type))
- }
+ fmt.Fprintf(w, "%s | ", typeAbbrev(fi.Type))
if fi.MTC != nil {
fmt.Fprintf(w, "MTC: %d | ", *fi.MTC)
} else {