Documentation
¶
Overview ¶
Package factor defines basic factors: rationals and symbols.
Index ¶
- Variables
- func Order(a []Value) int
- func Prod(vs ...Value) string
- func ValidSymbol(token string) bool
- type ByAlpha
- type Value
- func D(num, den int64) Value
- func Den(vs []Value) []Value
- func GCF(a, b []Value) []Value
- func I(n *big.Int) Value
- func Inv(a []Value) []Value
- func LCP(a, b []Value) []Value
- func Parse(s string) ([]Value, int, error)
- func R(n *big.Rat) Value
- func Replace(a, b, c []Value, max int) (int, []Value)
- func S(sym string) Value
- func Segment(vs ...Value) (*big.Rat, []Value, string)
- func Simplify(vs ...Value) []Value
- func Sp(sym string, pow int) Value
Constants ¶
This section is empty.
Variables ¶
var ErrDone = errors.New("factor parsing done")
var ErrSyntax = errors.New("syntax problem")
Functions ¶
func Prod ¶
Prod returns a string representing a product of values. This function does not attempt to simplify the array first.
func ValidSymbol ¶ added in v0.7.0
ValidSymbol confirms that a symbol can be considered externally meaningful. Various packages may use other forms for book keeping purposes (factoring etc), but for "external" purposes this is the only valid form.
Types ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value captures a single factor. It is either a number or a symbol.
func Inv ¶
Inv generates the inverse of a set of symbolic factors. It ignores Values with no symbol.
func Parse ¶
Parse parses a simple list of string arguments into an product of factors. Supported combinations are:
-33*y*x -> -33*x*y +33*x^4*y^-3*z/x/3 -> 11*x^3*y^-3*z
func Replace ¶
Replace replaces copies of b found in a with c. The number of times b appeared in a is returned as well as the replaced array of factors.
func Segment ¶
Segment simplifies a set of factors and returns the numerical coefficient, the non-numeric array of factors and a string representation of this array of non-numeric factors.