add comments
This commit is contained in:
@@ -21,6 +21,9 @@ import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
/*
|
||||
SqrtRepetend returns the repetend of the continued fraction of sqrt(x). It returns an error if x is a perfect square.
|
||||
*/
|
||||
func SqrtRepetend(x *big.Int) ([]*big.Int, error) {
|
||||
m := big.NewInt(0)
|
||||
d := big.NewInt(1)
|
||||
@@ -65,6 +68,9 @@ func cycle(seq []*big.Int) <-chan *big.Int {
|
||||
return ch
|
||||
}
|
||||
|
||||
/*
|
||||
GaussianBrackets returns a channel that outputs the sequence [], [a1], [a1, a2], ... where each value comes from the input channel and [] denotes Gaussian brackets.
|
||||
*/
|
||||
func GaussianBrackets(ch <-chan *big.Int) <-chan *big.Int {
|
||||
out := make(chan *big.Int)
|
||||
|
||||
@@ -87,6 +93,9 @@ func GaussianBrackets(ch <-chan *big.Int) <-chan *big.Int {
|
||||
return out
|
||||
}
|
||||
|
||||
/*
|
||||
CFracConvergents returns a channel that outputs convergents of a periodic continued fraction with initial term a0 and repetend stored in denoms.
|
||||
*/
|
||||
func CFracConvergents(a0 *big.Int, denoms []*big.Int) <-chan *big.Rat {
|
||||
hc := cycle(denoms)
|
||||
_ = <-hc
|
||||
|
||||
Reference in New Issue
Block a user