Documentation
¶
Overview ¶
Package math provides transcendental and advanced mathematical primitives.
Transcendental Functions (R7RS 6.2.6) ¶
- sin, cos, tan, asin, acos, atan
- exp, log
- sqrt, expt
Rounding ¶
- floor, ceiling, truncate, round
Numeric Conversion ¶
- numerator, denominator
- rationalize
- exact-integer-sqrt
Use Extension or AddToRegistry to register all primitives.
Package math provides transcendental math functions.
Index ¶
- Variables
- func PrimAcos(_ context.Context, mc *machine.MachineContext) error
- func PrimAngle(_ context.Context, mc *machine.MachineContext) error
- func PrimAsin(_ context.Context, mc *machine.MachineContext) error
- func PrimAtan(_ context.Context, mc *machine.MachineContext) error
- func PrimCos(_ context.Context, mc *machine.MachineContext) error
- func PrimDenominator(_ context.Context, mc *machine.MachineContext) error
- func PrimExactIntegerSqrt(_ context.Context, mc *machine.MachineContext) error
- func PrimExp(_ context.Context, mc *machine.MachineContext) error
- func PrimExpt(_ context.Context, mc *machine.MachineContext) error
- func PrimFiniteQ(_ context.Context, mc *machine.MachineContext) error
- func PrimFloorDiv(_ context.Context, mc *machine.MachineContext) error
- func PrimFloorQuotient(_ context.Context, mc *machine.MachineContext) error
- func PrimFloorRemainder(_ context.Context, mc *machine.MachineContext) error
- func PrimImagPart(_ context.Context, mc *machine.MachineContext) error
- func PrimInfiniteQ(_ context.Context, mc *machine.MachineContext) error
- func PrimLog(_ context.Context, mc *machine.MachineContext) error
- func PrimMagnitude(_ context.Context, mc *machine.MachineContext) error
- func PrimMakePolar(_ context.Context, mc *machine.MachineContext) error
- func PrimMakeRectangular(_ context.Context, mc *machine.MachineContext) error
- func PrimNanQ(_ context.Context, mc *machine.MachineContext) error
- func PrimNumberToString(_ context.Context, mc *machine.MachineContext) error
- func PrimNumerator(_ context.Context, mc *machine.MachineContext) error
- func PrimRationalize(_ context.Context, mc *machine.MachineContext) error
- func PrimRealPart(_ context.Context, mc *machine.MachineContext) error
- func PrimSin(_ context.Context, mc *machine.MachineContext) error
- func PrimSqrt(_ context.Context, mc *machine.MachineContext) error
- func PrimSquare(_ context.Context, mc *machine.MachineContext) error
- func PrimStringToNumber(_ context.Context, mc *machine.MachineContext) error
- func PrimTan(_ context.Context, mc *machine.MachineContext) error
- func PrimTruncateDiv(_ context.Context, mc *machine.MachineContext) error
- func PrimTruncateQuotient(_ context.Context, mc *machine.MachineContext) error
- func PrimTruncateRemainder(_ context.Context, mc *machine.MachineContext) error
Constants ¶
This section is empty.
Variables ¶
var AddToRegistry = Builder.AddToRegistry
AddToRegistry registers all math primitives.
var Builder = registry.NewRegistryBuilder(addPrimitives)
Builder aggregates all math registration functions.
var Extension = registry.NewExtension("math", AddToRegistry)
Extension is the math extension.
var PrimCeiling = makeRealNumberPrimitive(realNumberOp{ name: "ceiling", integerOp: integerPassthrough, floatOp: math.Ceil, rationalOp: rationalToInteger(math.Ceil), })
var PrimFloor = makeRealNumberPrimitive(realNumberOp{ name: "floor", integerOp: integerPassthrough, floatOp: math.Floor, rationalOp: rationalToInteger(math.Floor), })
var PrimRound = makeRealNumberPrimitive(realNumberOp{ name: "round", integerOp: integerPassthrough, floatOp: math.RoundToEven, rationalOp: rationalToInteger(math.RoundToEven), })
var PrimTruncate = makeRealNumberPrimitive(realNumberOp{ name: "truncate", integerOp: integerPassthrough, floatOp: math.Trunc, rationalOp: rationalToInteger(math.Trunc), })
Functions ¶
func PrimAcos ¶
func PrimAcos(_ context.Context, mc *machine.MachineContext) error
PrimAcos implements the (acos z) primitive.
func PrimAngle ¶
func PrimAngle(_ context.Context, mc *machine.MachineContext) error
PrimAngle implements the angle primitive.
func PrimAsin ¶
func PrimAsin(_ context.Context, mc *machine.MachineContext) error
PrimAsin implements the (asin z) primitive.
func PrimAtan ¶
func PrimAtan(_ context.Context, mc *machine.MachineContext) error
PrimAtan implements the (atan z) and (atan y x) primitives.
func PrimCos ¶
func PrimCos(_ context.Context, mc *machine.MachineContext) error
PrimCos implements the (cos z) primitive.
func PrimDenominator ¶
func PrimDenominator(_ context.Context, mc *machine.MachineContext) error
PrimDenominator implements the (denominator) primitive.
func PrimExactIntegerSqrt ¶
func PrimExactIntegerSqrt(_ context.Context, mc *machine.MachineContext) error
PrimExactIntegerSqrt implements the (exact-integer-sqrt) primitive.
R7RS §6.2.6: Returns two non-negative exact integers s and r where n = s² + r and n < (s+1)².
func PrimExp ¶
func PrimExp(_ context.Context, mc *machine.MachineContext) error
PrimExp implements the (exp z) primitive.
func PrimExpt ¶
func PrimExpt(_ context.Context, mc *machine.MachineContext) error
PrimExpt implements the (expt) primitive.
func PrimFiniteQ ¶
func PrimFiniteQ(_ context.Context, mc *machine.MachineContext) error
PrimFiniteQ implements the (finite?) primitive.
func PrimFloorDiv ¶
func PrimFloorDiv(_ context.Context, mc *machine.MachineContext) error
PrimFloorDiv implements the (floor/) primitive.
R7RS §6.2.6: Returns two values: floor quotient and floor remainder. Works on any real numbers, returning exact results when both inputs are exact.
func PrimFloorQuotient ¶
func PrimFloorQuotient(_ context.Context, mc *machine.MachineContext) error
PrimFloorQuotient implements the (floor-quotient) primitive.
R7RS §6.2.6: Returns the floor quotient for any real numbers.
func PrimFloorRemainder ¶
func PrimFloorRemainder(_ context.Context, mc *machine.MachineContext) error
PrimFloorRemainder implements the (floor-remainder) primitive.
R7RS §6.2.6: Returns the floor remainder for any real numbers.
func PrimImagPart ¶
func PrimImagPart(_ context.Context, mc *machine.MachineContext) error
PrimImagPart implements the (imag-part) primitive.
func PrimInfiniteQ ¶
func PrimInfiniteQ(_ context.Context, mc *machine.MachineContext) error
PrimInfiniteQ implements the (infinite?) primitive.
func PrimLog ¶
func PrimLog(_ context.Context, mc *machine.MachineContext) error
PrimLog implements the (log z) and (log z1 z2) primitives.
func PrimMagnitude ¶
func PrimMagnitude(_ context.Context, mc *machine.MachineContext) error
PrimMagnitude implements the (magnitude) primitive.
func PrimMakePolar ¶
func PrimMakePolar(_ context.Context, mc *machine.MachineContext) error
PrimMakePolar implements the (make-polar) primitive.
func PrimMakeRectangular ¶
func PrimMakeRectangular(_ context.Context, mc *machine.MachineContext) error
PrimMakeRectangular implements make-rectangular. R7RS §6.2.6: If both arguments are exact, the result is exact.
func PrimNanQ ¶
func PrimNanQ(_ context.Context, mc *machine.MachineContext) error
PrimNanQ implements the nan? primitive.
func PrimNumberToString ¶
func PrimNumberToString(_ context.Context, mc *machine.MachineContext) error
PrimNumberToString implements the number->string primitive.
func PrimNumerator ¶
func PrimNumerator(_ context.Context, mc *machine.MachineContext) error
PrimNumerator implements the numerator primitive.
func PrimRationalize ¶
func PrimRationalize(_ context.Context, mc *machine.MachineContext) error
PrimRationalize implements the (rationalize) primitive.
func PrimRealPart ¶
func PrimRealPart(_ context.Context, mc *machine.MachineContext) error
PrimRealPart implements the (real-part) primitive.
func PrimSin ¶
func PrimSin(_ context.Context, mc *machine.MachineContext) error
PrimSin implements the (sin z) primitive.
func PrimSqrt ¶
func PrimSqrt(_ context.Context, mc *machine.MachineContext) error
PrimSqrt implements the (sqrt) primitive.
R7RS §6.2.6: The branch cut for sqrt lies along the negative real axis, continuous with quadrant II. This means for values on the negative real axis (including those with -0.0 imaginary part), sqrt returns positive imaginary.
func PrimSquare ¶
func PrimSquare(_ context.Context, mc *machine.MachineContext) error
PrimSquare implements the (square) primitive.
func PrimStringToNumber ¶
func PrimStringToNumber(_ context.Context, mc *machine.MachineContext) error
PrimStringToNumber implements the string->number primitive.
R7RS §6.2.7: string->number returns a number of the maximally precise representation expressed by the given string. It is an error if radix is not 2, 8, 10, or 16.
R7RS §7.1.1: The string may contain prefix directives #b, #o, #d, #x (radix) and #e, #i (exactness), in either order, up to one of each. A radix prefix in the string overrides the radix argument.
func PrimTan ¶
func PrimTan(_ context.Context, mc *machine.MachineContext) error
PrimTan implements the (tan z) primitive.
func PrimTruncateDiv ¶
func PrimTruncateDiv(_ context.Context, mc *machine.MachineContext) error
PrimTruncateDiv implements the truncate/ primitive.
R7RS §6.2.6: Returns two values: truncate quotient and truncate remainder. Works on any real numbers, returning exact results when both inputs are exact.
func PrimTruncateQuotient ¶
func PrimTruncateQuotient(_ context.Context, mc *machine.MachineContext) error
PrimTruncateQuotient implements the truncate-quotient primitive.
R7RS §6.2.6: Returns the truncate quotient for any real numbers.
func PrimTruncateRemainder ¶
func PrimTruncateRemainder(_ context.Context, mc *machine.MachineContext) error
PrimTruncateRemainder implements the truncate-remainder primitive.
R7RS §6.2.6: Returns the truncate remainder for any real numbers.
Types ¶
This section is empty.