Documentation
¶
Overview ¶
Package exec implements addition chain algorithm execution.
Example ¶
package main
import (
"fmt"
"log"
"math/big"
"github.com/mmcloughlin/addchain/alg/ensemble"
"github.com/mmcloughlin/addchain/alg/exec"
)
func main() {
// Target number: 2²⁵⁵ - 21.
n := new(big.Int)
n.SetString("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeb", 16)
// Default ensemble of algorithms.
algorithms := ensemble.Ensemble()
// Use parallel executor.
ex := exec.NewParallel()
results := ex.Execute(n, algorithms)
// Output best result.
best := 0
for i, r := range results {
if r.Err != nil {
log.Fatal(r.Err)
}
if len(results[i].Program) < len(results[best].Program) {
best = i
}
}
r := results[best]
fmt.Printf("best: %d\n", len(r.Program))
fmt.Printf("algorithm: %s\n", r.Algorithm)
}
Output: best: 266 algorithm: opt(runs(continued_fractions(dichotomic)))
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parallel ¶
type Parallel struct {
// contains filtered or unexported fields
}
Parallel executes multiple algorithms in parallel.
func (*Parallel) SetConcurrency ¶
SetConcurrency sets the number of algorithms that may be run in parallel.
Click to show internal directories.
Click to hide internal directories.