NumberIsMultiplicativeGroup

com.phasmidsoftware.number.algebra.eager.Number.NumberIsMultiplicativeGroup
object NumberIsMultiplicativeGroup extends MultiplicativeGroup[Number]

An implicit object defining the multiplicative group structure for Number instances.

The NumberIsMultiplicativeGroup provides implementations for the methods required by the MultiplicativeGroup type class, enabling operations such as multiplication (times) and division (div) as well as access to the multiplicative identity (one). It supports a variety of Number subtypes, including Real, RationalNumber, and WholeNumber, and handles necessary conversions or raises exceptions when operations cannot be performed.

Attributes

Graph
Supertypes
trait MultiplicativeGroup[Number]
trait MultiplicativeMonoid[Number]
trait MultiplicativeSemigroup[Number]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Concrete methods

def div(x: Number, y: Number): Number

Divides one Number by another and returns the resulting Number.

Divides one Number by another and returns the resulting Number.

This method performs safe division for different types of Number instances, such as Real. If the divisor is zero or an unsupported type is encountered, an exception is thrown.

Value parameters

x

the numerator as a Number

y

the denominator as a Number

Attributes

Returns

the result of dividing x by y as a Number

Note

Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if division by zero occurs or if the operation cannot be performed

def times(x: Number, y: Number): Number

Multiplies two Number instances and returns the resulting Number.

Multiplies two Number instances and returns the resulting Number.

This method performs multiplication between two instances of Number. The exact operation depends on the type of the input numbers, supporting various types such as Real, RationalNumber, and WholeNumber. If the types mismatch or a conversion between types is required, the appropriate logic is applied to carry out the multiplication. If the numbers cannot be multiplied due to an unsupported type or incorrect conversion, an exception is thrown.

Value parameters

x

the first Number to be multiplied

y

the second Number to be multiplied

Attributes

Returns

the result of multiplying x and y as a Number

Note

Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the multiplication is not possible for the given inputs

Inherited methods

def isOne(a: Number)(implicit ev: Eq[Number]): Boolean

Tests if a is one.

Tests if a is one.

Attributes

Inherited from:
MultiplicativeMonoid
override def multiplicative: Group[Number]

Attributes

Definition Classes
MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
Inherited from:
MultiplicativeGroup
override def pow(a: Number, n: Int): Number

Attributes

Definition Classes
MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
Inherited from:
MultiplicativeGroup
def product(as: IterableOnce[Number]): Number

Given a sequence of as, compute the product.

Given a sequence of as, compute the product.

Attributes

Inherited from:
MultiplicativeMonoid

Attributes

Inherited from:
MultiplicativeGroup
override def tryProduct(as: IterableOnce[Number]): Option[Number]

Given a sequence of as, combine them and return the total.

Given a sequence of as, combine them and return the total.

If the sequence is empty, returns None. Otherwise, returns Some(total).

Attributes

Definition Classes
MultiplicativeMonoid -> MultiplicativeSemigroup
Inherited from:
MultiplicativeMonoid

Concrete fields

lazy val one: Number

Retrieves the numerical value that represents one.

Retrieves the numerical value that represents one.

Attributes

Returns

the predefined constant representing the number one