Interfaces for Generic Operations | Extreme Optimization Numerical Libraries for .NET Professional |

At the core of the generic arithmetic framework is a set of interfaces that define arithmetic operations on generic types. A type that implements one or more of these interfaces is an Arithmetic. An arithmetic performs arithmetic operations on a specific operand type. The relationship between an airthmetic type and its operand type is declared using a custom attribute.

The arithmetic operations are grouped according to the algebraic structure of the operand type.

A group is a set that has an addition operator.
It usually also has a subtraction operator.
The IGroupOperations

Member | Description |
---|---|

The smallest value of the type. | |

The smallest value of the type. | |

The identity element for addition. | |

Returns the magnitude of an operand. | |

Returns the result of adding two operands. | |

Returns the additive inverse of its operand. | |

Returns the result of subtracting one operand from another. |

A ring is a group that
has a multiplication operator. It usually also has a unit element.
The IRingOperations

Member | Description |
---|---|

Converts an integer to the operand type. | |

Returns the result of multiplying two operands. | |

Returns the unit element. | |

Returns the result of multiplying an operand by a power of two. |

Division presents somewhat of a challenge because it is not always well defined.
For example, the value of 7/2 is not an integer, but it is a rational number.
In technical terms, the set of integers is not closed under division,
but the set of rational numbers is. In other words, the set of rational numbers is the
closure of the integers under division. It is this relationship
that is expressed by the
IDivisionOperations

This interface has two type parameters. The first is the operand type. The second
is the type of the closure.
It depends on IRingOperations

Member | Description |
---|---|

Returns the result of dividing two operands as the closure type. | |

Returns the multiplicative inverse of an operand as the closure type. |

A ring that is closed under division is called a field. Examples of fields are: the rational numbers, the real numbers, and integers modulo a prime number.

Operations on fields are defined by the
IFieldOperations

A Euclidean ring is a ring that has a well-defined division with remainder. The name derives from the fact that division with remainder is the core of Euclid's algorithm to compute the greatest common divisor of two numbers.

The quotient, q and the remainder, r of the division a / b are uniquely defined such that a = qb + r with 0 <= |r| < b. There are other ways to uniquely define q and r, which can be specified by the rounding mode.

Division with remainder is defined by the
IEuclideanRingOperations

Member | Description |
---|---|

Returns the quotient of dividing two operands and returns the remainder in an out parameter. | |

Returns the quotient of dividing two operands. | |

Returns the quotient of dividing two operands using the specified rounding mode. | |

Returns the remainder after dividing one operand by another. |

The
IFractionalOperations

Member | Description |
---|---|

Returns the smallest integer greater than or equal to the operand. | |

Returns the largest integer smaller than or equal to the operand. | |

Returns the operand rounded to the specified number of decimal digits using the specified rounding mode. |

The
IRealOperations

Member | Description |
---|---|

Gets the machine precision of the operand type. | |

Gets the smallest positive number that is greater than zero. | |

Gets the number π. | |

Returns the equivalent of a Double as an instance of the operand type. | |

Returns the inverse tangent of the two operands. | |

Returns the cosine of the operand. | |

Returns the hyperbolic cosine of the operand. | |

Returns the hyperbolic cosine of the operand. | |

Returns the exponential of the operand. | |

Returns the logarithm of the operand. | |

Returns an operand raised to a power. | |

Returns the sine of the operand. | |

Returns the hyperbolic sine of the operand. | |

Returns the square root of the operand. |

The IEEE-754 standard defines three special values: positive infinity, negative infinity, and Not-a-Number (NaN). Although these values originally applied to single and double precision floating-point numbers, they can be used more generally.

The Not-a-Number value in particular deserves special attention. It is used when the result of an operation is undefined. For example: 0/0 is undefined. NaN's compare not equal to all values, including other NaN's.

The
IIeeeOperations

Member | Description |
---|---|

Gets the operand type value that represents Not-a-Number. | |

Gets the operand type value that represents positive infinity. | |

Gets the operand type value that represents negative infinity. | |

Returns whether a value is Not-a-Number. |

Copyright © 2004-20116,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.