BigRational Module
Parses, converts, formats and calculates with BigRational values, including divisors, multiples of an increment and ranges from a minimum to a maximum. The module is compiled with the Module suffix, so that its compiled name does not clash with the BigRational type.
Types and nested modules
| Type/Module | Description |
|
Holds the Unquote tests of the valueToFactorRatio function. |
|
|
Exception type |
|
|
Message type to be used when an exception message is warranted |
Functions and values
| Function or value |
Description
|
Full Usage:
BigRational.apply f x
Parameters:
BigRational -> 'a
x : BigRational
Returns: 'a
Type parameters: 'a |
|
Full Usage:
BigRational.calcCartesian op vs1 vs2
Parameters:
BigRational -> BigRational -> BigRational
vs1 : BigRational[]
vs2 : BigRational[]
Returns: BigRational[]
|
|
Full Usage:
BigRational.calcConc max conc
Parameters:
BigInteger
conc : RationalX
Returns: RationalX seq
|
Calculate the set of possible solutions with a concentration conc up to a maximum value max in descending order
|
Full Usage:
BigRational.calcMinOrMaxToMultiple isMax isIncl incrs minOrMax
Parameters:
bool
-
Specifies whether the maximum value is being calculated.
isIncl : bool
-
Indicates whether the result should be inclusive or exclusive of minOrMax.
incrs : Set<RationalX>
-
A set of positive increments to consider for adjusting the starting value.
minOrMax : RationalX
-
The starting value for which to calculate the minimum or maximum.
Returns: RationalX
The calculated minimum or maximum value based on the provided conditions.
|
Calculates the minimum or maximum value that can be obtained by adding (or subtracting)
positive increments to a given starting value (
|
Full Usage:
BigRational.calculate n1 o n2
Parameters:
'a option
o : 'a -> 'b -> 'c
n2 : 'b option
Returns: 'c option
Type parameters: 'a, 'b, 'c |
Perform a calculation when both n1 and n2 are 'some'
|
|
|
|
Order-preserving distinct over a BigRational array using the default
.NET equality comparer. Because BigRational (RationalX) is a struct that
implements IEquatable<_>, this takes the unboxed equality path, avoiding
the per-element boxing that F#'s structural Array.distinct incurs for a
[
|
|
Get all divisors of a BigInt
|
|
Get all the divisors of a BigRational
|
|
A decimal as its exact text writes it: an optional minus sign, digits, and digits after a decimal point. Only the digits 0 to 9, as .NET reads every Unicode digit for \d.
|
|
Fix the precision of a BigRational and return the result as a float
|
Full Usage:
BigRational.formatDecimal format br
Parameters:
decimal -> string
br : BigRational
Returns: string
|
The text that the format function makes of the decimal of a BigRational. A value beyond the range of a decimal is written as its fraction.
|
|
|
|
|
|
Converts a float to a BigRational through decimal, so that a float read from a text such as 0.14 gives the exact value 7/50. A float that the decimal does not give back exactly, or that is beyond the range of a decimal, is converted with Double.floatToFract. None for infinity and not a number.
|
|
|
|
Get the greatest common divisor of two BigRationals a and b
|
Full Usage:
BigRational.getDivisors modulo zero one two n
Parameters:
^a -> ^a -> ^a
zero : ^a
one : ^a
two : ^b
n : ^a
Returns: ^a list
Modifiers: inline Type parameters: ^a, ^b (requires (static member Abs : ^a -> ^a) and (static member op_Division : ^a * ^b -> ^a) and (static member get_One : -> ^a) and (static member op_Addition : ^a * ^a -> ^a) and comparison and (static member op_Division : ^a * ^b -> ^a)) |
Generic function to calculate all divisors of n, using a modulo function
|
|
Utility to enable type inference
|
Full Usage:
BigRational.isDivisor zero dividend divisor
Parameters:
'a
dividend : ^b
divisor : ^c
Returns: bool
Modifiers: inline Type parameters: 'a, ^b, ^c (requires equality and (static member op_Modulus : ^b * ^c -> 'a) and (static member op_Modulus : ^b * ^c -> 'a)) |
Generic function to check whether a divisor is a divisor of a dividend, i.e. the number being divided
|
Full Usage:
BigRational.isDivisorOfBigInt dividend divisor
Parameters:
bigint
divisor : bigint
Returns: bool
|
Check whether a divisor divides a dividend
|
Full Usage:
BigRational.isDivisorOfBigR dividend divisor
Parameters:
BigRational
divisor : BigRational
Returns: bool
|
Check whether a divisor divides a dividend
|
Full Usage:
BigRational.isMultiple incr v
Parameters:
BigRational
v : BigRational
Returns: bool
|
|
|
Get the least common multiple of two BigRationals a and b
|
|
Calculates the maximum value (exclusive) that can be obtained by adding positive increments
to a given starting value ( Example
val set: elements: 'T seq -> Set<'T> (requires comparison)
|
|
Calculates the maximum value (inclusive) that can be obtained by adding positive increments
to a given starting value ( Example
val set: elements: 'T seq -> Set<'T> (requires comparison)
|
|
Calculates the minimum value (exclusive) that can be obtained by adding positive increments
to a given starting value ( Example
val set: elements: 'T seq -> Set<'T> (requires comparison)
|
|
Calculates the minimum value (inclusive) that can be obtained by adding positive increments
to a given starting value ( Example
val set: elements: 'T seq -> Set<'T> (requires comparison)
|
|
Takes a min, set of increments, and max and returns a sequence of all values that are a multiple of an increment, have a minimum value that is a multiple of that increment and a maximum value that is a multiple of that increment.
Example
module Seq
from Microsoft.FSharp.Collections
val toList: source: 'T seq -> 'T list
|
|
Split a rational number in a numerator and denominator
|
|
|
|
Constant 1
|
|
|
|
|
|
|
|
|
|
Convert an optional BigRational to a string. If None then return empty string.
|
|
Parse a string to a bigrational Raises an exception Message when the string cannot be parsed
|
|
|
|
|
Full Usage:
BigRational.reduceRatio num denom
Parameters:
BigRational
denom : BigRational
Returns: RationalX * RationalX
|
Reduce a ratio where num is the numerator and denom is the denominator
|
|
Constant 3
|
|
Create a decimal from a BigRational
|
|
The exact decimal form of a BigRational, "0.5" for 1/2, or None when it has none, as 1/3, or when it is beyond the range of a decimal. Unlike toDecimal, which goes through a float, nothing is rounded.
|
|
|
|
|
|
|
|
|
|
Calculates the nearest multiple of the given multiple based on whether it's required to be a minimum or maximum value. - Parameters: - isMinOrMax: Specifies whether the value should be the minimum or maximum multiple. - multiple: The increment value for which to find the nearest multiple. - value: The value for which the nearest multiple needs to be calculated. - Returns: The calculated nearest multiple value.
|
|
|
|
The exact text of a BigRational: its decimal form when it has a finite one, "0.5", else the reduced fraction, "1/3".
|
|
|
|
Try to parse a string and return None if it fails otherwise Some bigrational
|
|
A BigRational from its exact text: a decimal, "0.5", or a fraction, "1/3" or "500/1"; None for anything else. A decimal takes only a leading sign and a decimal point, so an exponent, a group separator or a decimal comma is refused. Its digits are read as they are, so a decimal of any length stays exact.
|
|
Constant 2
|
Full Usage:
BigRational.valueToBigIntFactorRatio v (arg2, arg2, arg2, arg2)
Parameters:
BigRational
arg1 : bigint option
arg2 : bool
arg3 : bigint option
arg4 : bool
Returns: (bigint * bigint) option
|
Calculate a rational factor ratio for a given input value based on conditions.
|
Full Usage:
BigRational.valueToFactorRatio v (arg2, arg2, arg2, arg2)
Parameters:
BigRational
arg1 : RationalX option
arg2 : bool
arg3 : RationalX option
arg4 : bool
Returns: (RationalX * RationalX) option
|
Calculate a rational factor ratio for a given input value based on conditions. This function takes an input value v of type BigRational and a tuple r containing the following components: - n: An optional numerator. - nIsMult: A boolean flag indicating whether the numerator should be a multiple of n (true) or exact value (false). - d: An optional denominator. - dIsMult: A boolean flag indicating whether the denominator should be a multiple of d (true) or exact value (false). Parameters: - v: The input value for which the factor ratio is calculated (of type BigRational). - r: A tuple containing the conditions and components for calculating the factor ratio. Returns: - If the calculated factor ratio accurately represents the original value, returns Some (n, d). - Otherwise, returns None.
|
|
Constant 0
|
Active patterns
| Active pattern |
Description
|
|
|
|
GenPRES