Orbital library

orbital.math
Interface ValueFactory

All Known Implementing Classes:
Values

public interface ValueFactory

Scalar value and arithmetic object value constructor factory.

This class is the central factory facade for instantiating new arithmetic objects. It also provides "pluggable value factory implementation" that allow other vendor's implementation of arithmetic objects to be used.

Since our general arithmetic objects are modelled as interfaces to provide a maximum of flexibility, you need factory methods to create an arithmetic object value. The class ValueFactory is that central factory class which can create arithmetic object values from all kinds of primitive types. This indirection introduces a more loosely coupled binding between users and providers of arithmetic object classes. When using a static final singleton factory like from Values.getDefault(), closed-world JIT compilers can optimize the resulting code to prevent performance loss. Indeed, because of this delegative construction the factory method can chose the best implementation class suitable for a specific primitive type and size.

Author:
André Platzer
See Also:
Abstract Factory, Facade, "FacadeFactory", Values, Values.getInstance(), Values.getDefault(), Arrays

Method Summary
 Polynomial asPolynomial(Tensor coefficients)
          Returns a polynomial view of a tensor.
 UnivariatePolynomial asPolynomial(Vector a)
          Returns a polynomial view of a vector.
 Tensor asTensor(Polynomial p)
          Returns a vector view of the coefficients of a polynomial.
 Vector asVector(Matrix m)
          Returns a vector view of the specified matrix.
 Vector asVector(Tensor t)
          Returns a vector view of the specified tensor.
 Vector asVector(UnivariatePolynomial p)
          Returns a vector view of the coefficients of a polynomial.
 Vector BASE(int n, int i)
          Gets a vector ei of an ONB of Rn.
 Complex cartesian(double a, double b)
           
 Complex cartesian(Real a, Real b)
          Creates a new complex from cartesian coordinates.
 Complex complex(double a)
           
 Complex complex(double a, double b)
           
 Complex complex(float a, float b)
           
 Complex complex(int a, int b)
           
 Complex complex(long a, long b)
           
 Complex complex(Real a)
          Returns a new (real) complex whose value is equal to a + i*0.
 Complex complex(Real a, Real b)
          Returns a new complex whose value is equal to a + i*b.
 Vector CONST(int n, Arithmetic c)
          Gets a constant Vector, with all elements set to c.
 Matrix constant(Matrix m)
          Returns an unmodifiable view of the specified matrix.
 Polynomial constant(Polynomial p)
          Returns an unmodifiable view of the specified polynomial.
 Tensor constant(Tensor t)
          Returns an unmodifiable view of the specified tensor.
 UnivariatePolynomial constant(UnivariatePolynomial p)
          Returns an unmodifiable view of the specified polynomial.
 Vector constant(Vector v)
          Returns an unmodifiable view of the specified vector.
 Matrix DIAGONAL(Vector diagon)
          Gets diagonal Matrix, with all elements set to 0, except the leading diagonal mi,i set to vi.
 Real E()
          e = 2.71828...
 Fraction fraction(Arithmetic a)
          Returns a new fraction a⁄1 ∈ S-1M = MS.
 Fraction fraction(Arithmetic a, Arithmetic s)
          Returns a new fraction a⁄s ∈ S-1M = MS.
 Function getCoercer()
          Get the transformation function for coercing arithmetic objects.
 Function getCoercer(boolean commutative)
          Get the transformation function for coercing arithmetic objects taking into account commutativity.
 Function getNormalizer()
          Get the transformation function for normalizing arithmetic objects.
 Complex i()
          The imaginary unit iC.
 Complex I()
          The imaginary unit iC.
 Matrix IDENTITY(java.awt.Dimension dim)
          Gets the identity Matrix, with all elements set to 0, except the leading diagonal mi,i set to 1.
 Matrix IDENTITY(int height, int width)
          Gets the identity Matrix, with all elements set to 0, except the leading diagonal mi,i set to 1.
 Complex INFINITY()
          complex infinity ∞∈C.
 Integer MINUS_ONE()
          -1∈Z.
 Polynomial MONOMIAL(Arithmetic exponent)
          The monomial 1·Xi.
 Polynomial MONOMIAL(Arithmetic coefficient, Arithmetic exponent)
          The monomial c·Xi.
 UnivariatePolynomial MONOMIAL(Arithmetic coefficient, int exponent)
          The univariate monomial c·Xe.
 Polynomial MONOMIAL(Arithmetic coefficient, int[] exponents)
          The monomial c·X0i[0]...Xn-1i[n-1].
 UnivariatePolynomial MONOMIAL(int exponent)
          The univariate monomial 1·Xe.
 Polynomial MONOMIAL(int[] exponents)
          The monomial 1·X0i[0]...Xn-1i[n-1].
 Real NaN()
          not a number ⊥∈R∪{⊥}.
 Scalar narrow(Scalar val)
          Returns a minimized Scalar whose value is equal to that of the specified scalar.
 Real NEGATIVE_INFINITY()
          -∞∈R.
 Matrix newInstance(java.awt.Dimension dimension)
          Creates a new instance of matrix with the specified dimension.
 Vector newInstance(int dimension)
          Creates a new instance of vector with the specified dimension.
 Tensor newInstance(int[] dimensions)
          Creates a new instance of tensor with the specified dimensions.
 Matrix newInstance(int height, int width)
           
 Integer ONE()
          1∈Z.
 Arithmetic parse(java.lang.String s)
          Returns an arithmetic object whose value is equal to that of the representation in the specified string.
 Real PI()
          π = 3.14159265...
 Complex polar(double r, double phi)
           
 Complex polar(Real r, Real phi)
          Creates a new complex from polar coordinates with r*eiφ.
 UnivariatePolynomial polynomial(Arithmetic[] coefficients)
          Returns a (univariate) polynomial with the specified coefficients.
 UnivariatePolynomial polynomial(double[] coefficients)
           
 UnivariatePolynomial polynomial(int[] coefficients)
           
 Polynomial polynomial(java.util.Map exponentCoefficientMap)
          Returns a polynomial with the specified (partial) coefficient map.
 Polynomial polynomial(java.lang.Object coefficients)
          Returns a polynomial with the specified coefficients.
 Real POSITIVE_INFINITY()
          +∞∈R.
 Quotient quotient(Arithmetic a, Function mod)
          Returns a new quotient ā=[a]∈M/mod of the given value reduced with the quotient operator.
 Quotient quotient(Arithmetic a, Polynomial m)
          (traps type unification error).
 Quotient quotient(Euclidean a, Euclidean m)
          Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo m.
 Quotient quotient(Euclidean a, Function mod)
          (disambiguates type unification).
 Quotient quotient(Euclidean a, UnivariatePolynomial m)
          (disambiguates type unification).
 Quotient quotient(int a, int m)
          (Convenience) Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo m.
 Quotient quotient(Polynomial a, java.util.Set m, java.util.Comparator monomialOrder)
          Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo (m).
 Rational rational(int p)
           
 Rational rational(Integer p)
          Returns a new (integer) rational whose value is equal to p/1.
 Rational rational(Integer p, Integer q)
          Returns a new rational whose value is equal to p/q.
 Rational rational(int p, int q)
           
 void setCoercer(boolean commuatative, Function coerce)
          Set the transformation function for coercion.
 void setCoercer(Function coerce)
          Set the transformation function for coercion.
 void setNormalizer(Function normalizer)
          Set the transformation function for normalizing arithmetic objects.
 Symbol symbol(java.lang.String signifier)
          Returns a new algebraic symbol.
 Vector tensor(Arithmetic[] values)
          Returns a vector containing the specified arithmetic objects.
 Matrix tensor(Arithmetic[][] values)
          Returns a matrix containing the specified arithmetic objects.
 Tensor tensor(Arithmetic[][][] values)
           
 Tensor tensor(java.util.Map indexCoefficientMap)
          Returns a tensor of rank k containing the specified (partial) map from index to arithmetic object.
 Tensor tensor(java.lang.Object values)
          Returns a tensor of rank k containing the specified arithmetic objects.
 Vector valueOf(Arithmetic[] values)
          Returns a Vector containing the specified arithmetic objects.
 Matrix valueOf(Arithmetic[][] values)
          Returns a Matrix containing the specified arithmetic objects.
 Real valueOf(java.math.BigDecimal val)
          Returns a scalar whose value is equal to that of the specified big number.
 Integer valueOf(java.math.BigInteger val)
          Returns a scalar whose value is equal to that of the specified big number.
 Integer valueOf(byte val)
           
 Integer valueOf(java.lang.Byte val)
           
 Real valueOf(double val)
          Returns a scalar whose value is equal to that of the specified primitive type.
 Real valueOf(java.lang.Double val)
           
 Vector valueOf(double[] values)
           
 Matrix valueOf(double[][] values)
           
 Real valueOf(float val)
          Returns a scalar whose value is equal to that of the specified primitive type.
 Real valueOf(java.lang.Float val)
           
 Integer valueOf(int val)
          Returns a scalar whose value is equal to that of the specified primitive type.
 Vector valueOf(int[] values)
           
 Matrix valueOf(int[][] values)
           
 Integer valueOf(java.lang.Integer val)
           
 Integer valueOf(long val)
          Returns a scalar whose value is equal to that of the specified primitive type.
 Integer valueOf(java.lang.Long val)
           
 Scalar valueOf(java.lang.Number val)
          Returns a Scalar whose value is equal to that of the specified number.
 Integer valueOf(short val)
           
 Integer valueOf(java.lang.Short val)
           
 Arithmetic valueOf(java.lang.String s)
          Returns an arithmetic object whose value is equal to that of the representation in the specified string.
 Integer ZERO()
          0∈Z.
 Matrix ZERO(java.awt.Dimension dim)
          Gets zero Matrix, with all elements set to 0.
 Vector ZERO(int n)
          Gets zero Vector, with all elements set to 0.
 Tensor ZERO(int[] dimensions)
          Gets zero tensor, with all elements set to 0.
 Matrix ZERO(int height, int width)
           
 

Method Detail

ZERO

Integer ZERO()
0∈Z. The neutral element of addition in Z,R etc.

Postconditions:
RES == OLD(RES) ∧ RES = valueOf(0)

ONE

Integer ONE()
1∈Z. The neutral element of multiplication in Z,R etc.

Postconditions:
RES == OLD(RES) ∧ RES = valueOf(1)

MINUS_ONE

Integer MINUS_ONE()
-1∈Z.

Postconditions:
RES == OLD(RES) ∧ RES = valueOf(-1)

POSITIVE_INFINITY

Real POSITIVE_INFINITY()
+∞∈R.

See Also:
INFINITY(), NEGATIVE_INFINITY()
Postconditions:
RES == OLD(RES)

NEGATIVE_INFINITY

Real NEGATIVE_INFINITY()
-∞∈R.

See Also:
INFINITY(), POSITIVE_INFINITY()
Postconditions:
RES == OLD(RES)

PI

Real PI()
π = 3.14159265... . The proportion of the circumference of a circle to its diameter. π is transcendental over Q.

Postconditions:
RES == OLD(RES)

E

Real E()
e = 2.71828... . The base of the natural logarithm. e is transcendental over Q.

Postconditions:
RES == OLD(RES)

NaN

Real NaN()
not a number ⊥∈R∪{⊥}.

Postconditions:
RES == OLD(RES)

I

Complex I()
The imaginary unit iC. Alternative name for i().

See Also:
i()
Postconditions:
RES == OLD(RES) ∧ RES = complex(0, 1)

i

Complex i()
The imaginary unit iC. Alternative name for I().

See Also:
I()
Postconditions:
RES == OLD(RES) ∧ RES = complex(0, 1)

INFINITY

Complex INFINITY()
complex infinity ∞∈C.

See Also:
INFINITY()
Postconditions:
RES == OLD(RES)

valueOf

Integer valueOf(int val)
Returns a scalar whose value is equal to that of the specified primitive type.

See Also:
Facade (method), BigInteger.valueOf(long)
Postconditions:
RES.intValue() == val

valueOf

Integer valueOf(java.lang.Integer val)

valueOf

Integer valueOf(long val)
Returns a scalar whose value is equal to that of the specified primitive type.

See Also:
Facade (method), BigInteger.valueOf(long)
Postconditions:
RES.longValue() == val

valueOf

Integer valueOf(java.lang.Long val)

valueOf

Integer valueOf(byte val)

valueOf

Integer valueOf(java.lang.Byte val)

valueOf

Integer valueOf(short val)

valueOf

Integer valueOf(java.lang.Short val)

valueOf

Integer valueOf(java.math.BigInteger val)
Returns a scalar whose value is equal to that of the specified big number. Legacy conversion method.


valueOf

Real valueOf(double val)
Returns a scalar whose value is equal to that of the specified primitive type.

See Also:
Facade (method), BigInteger.valueOf(long)
Postconditions:
RES.doubleValue() == val

valueOf

Real valueOf(java.lang.Double val)

valueOf

Real valueOf(float val)
Returns a scalar whose value is equal to that of the specified primitive type.

See Also:
Facade (method), BigInteger.valueOf(long)
Postconditions:
RES.floatValue() == val

valueOf

Real valueOf(java.lang.Float val)

valueOf

Real valueOf(java.math.BigDecimal val)
Returns a scalar whose value is equal to that of the specified big number. Legacy conversion method.


valueOf

Scalar valueOf(java.lang.Number val)
Returns a Scalar whose value is equal to that of the specified number. Legacy conversion method.

Returns:
an instance of scalar that has the same value as the number.
See Also:
Facade (method), valueOf(double)

rational

Rational rational(Integer p,
                  Integer q)
Returns a new rational whose value is equal to p/q.

Parameters:
p - the numerator of p/q.
q - the denominator p/q.

rational

Rational rational(int p,
                  int q)

rational

Rational rational(Integer p)
Returns a new (integer) rational whose value is equal to p/1.

Parameters:
p - the numerator of p/1.

rational

Rational rational(int p)

complex

Complex complex(Real a,
                Real b)
Returns a new complex whose value is equal to a + i*b.

Parameters:
a - real part.
b - imaginary part.
Returns:
a + i*b.
See Also:
cartesian(Real, Real)

complex

Complex complex(double a,
                double b)

complex

Complex complex(float a,
                float b)

complex

Complex complex(int a,
                int b)

complex

Complex complex(long a,
                long b)

complex

Complex complex(Real a)
Returns a new (real) complex whose value is equal to a + i*0.

Parameters:
a - real part.
Returns:
a + i*0.
See Also:
complex(Real, Real)

complex

Complex complex(double a)

cartesian

Complex cartesian(Real a,
                  Real b)
Creates a new complex from cartesian coordinates.

Parameters:
a - real part.
b - imaginary part.
Returns:
a + i*b.
See Also:
polar(Real, Real)

cartesian

Complex cartesian(double a,
                  double b)

polar

Complex polar(Real r,
              Real phi)
Creates a new complex from polar coordinates with r*eiφ.

Parameters:
r - = |z| is the length.
phi - = φ is the angle ∠ in radians.
Returns:
r*eiφ = r * (cos φ + i sin φ).
See Also:
cartesian(Real, Real)
Preconditions:
r≥0

polar

Complex polar(double r,
              double phi)

valueOf

Vector valueOf(Arithmetic[] values)
Returns a Vector containing the specified arithmetic objects.

Note that the resulting vector may or may not be backed by the specified array.

See Also:
Facade (method), tensor(Arithmetic[])

valueOf

Vector valueOf(double[] values)

valueOf

Vector valueOf(int[] values)

newInstance

Vector newInstance(int dimension)
Creates a new instance of vector with the specified dimension.

Parameters:
dimension - the dimension of the vector.
Returns:
a vector of the specified dimension, with undefined components.
See Also:
Facade (method)
Postconditions:
RES.dimension() == dimension()

ZERO

Vector ZERO(int n)
Gets zero Vector, with all elements set to 0.


BASE

Vector BASE(int n,
            int i)
Gets a vector ei of an ONB of Rn. It has all elements set to 0 except element i set to 1. These ei are the standard base of Rn: ∀xRn ∃! xkR: x = x1*e1 + ... + xn*en.


CONST

Vector CONST(int n,
             Arithmetic c)
Gets a constant Vector, with all elements set to c.


constant

Vector constant(Vector v)
Returns an unmodifiable view of the specified vector. The result is a read only view.


valueOf

Matrix valueOf(Arithmetic[][] values)
Returns a Matrix containing the specified arithmetic objects.

Matrix components are expected row-wise, which means that as the first index in values, the row i is used and as the second index in values, the column j is used.

Note that the resulting vector may or may not be backed by the specified array.

Parameters:
values - the element values of the matrix to create. The matrix may be backed by this exact array per reference.
See Also:
Facade (method), tensor(Arithmetic[][])

valueOf

Matrix valueOf(double[][] values)

valueOf

Matrix valueOf(int[][] values)

newInstance

Matrix newInstance(java.awt.Dimension dimension)
Creates a new instance of matrix with the specified dimension.

Parameters:
dimension - the dimension of the matrix.
Returns:
a matrix of the specified dimensions, with undefined components.
See Also:
Facade (method)
Postconditions:
RES.dimension().equals(dimension)

newInstance

Matrix newInstance(int height,
                   int width)

ZERO

Matrix ZERO(java.awt.Dimension dim)
Gets zero Matrix, with all elements set to 0.


ZERO

Matrix ZERO(int height,
            int width)

IDENTITY

Matrix IDENTITY(java.awt.Dimension dim)
Gets the identity Matrix, with all elements set to 0, except the leading diagonal mi,i set to 1.

Preconditions:
dim.width == dim.height

IDENTITY

Matrix IDENTITY(int height,
                int width)
Gets the identity Matrix, with all elements set to 0, except the leading diagonal mi,i set to 1.

See Also:
Functions.delta, IDENTITY(Dimension)
Preconditions:
width == height

DIAGONAL

Matrix DIAGONAL(Vector diagon)
Gets diagonal Matrix, with all elements set to 0, except the leading diagonal mi,i set to vi.

See Also:
Functions.delta

constant

Matrix constant(Matrix m)
Returns an unmodifiable view of the specified matrix. The result is a read only view.


tensor

Vector tensor(Arithmetic[] values)
Returns a vector containing the specified arithmetic objects. Vectors are the tensors of rank 1.

Note that the resulting vector may or may not be backed by the specified array.

See Also:
Facade (method)

tensor

Matrix tensor(Arithmetic[][] values)
Returns a matrix containing the specified arithmetic objects. Matrices are the tensors of rank 2.

Matrix components are expected row-wise, which means that as the first index in values, the row i is used and as the second index in values, the column j is used.

Note that the resulting vector may or may not be backed by the specified array.

Parameters:
values - the element values of the matrix to create. The matrix may be backed by this exact array per reference.
See Also:
Facade (method)

tensor

Tensor tensor(Arithmetic[][][] values)

tensor

Tensor tensor(java.lang.Object values)
Returns a tensor of rank k containing the specified arithmetic objects.

Note that the resulting tensor may or may not be backed by the specified array.

Tensors of type Vector, and Matrix are returned for tensors of rank 1 or 2.

Parameters:
values - the element values of the tensor to create. The tensor may be backed by this exact array per reference.
See Also:
Facade (method)
Preconditions:
values is a rectangular multi-dimensional array of arithmetic objects or of primitive types

tensor

Tensor tensor(java.util.Map indexCoefficientMap)
Returns a tensor of rank k containing the specified (partial) map from index to arithmetic object.

Note that the resulting tensor may or may not be backed by the specified array.

Tensors of type Vector, and Matrix are returned for tensors of rank 1 or 2.

Parameters:
indexCoefficientMap - a map mapping index to element value.
Returns:
the tensor (ai)i according to the indices i and elements ai in the indexCoefficientMap.
See Also:
Facade (method)
Preconditions:
keys in indexCoefficientMap are compatible

newInstance

Tensor newInstance(int[] dimensions)
Creates a new instance of tensor with the specified dimensions.

Tensors of type Vector, and Matrix are returned for tensors of rank 1 or 2.

Parameters:
dimensions - the dimensions n1×n2×…×nr of the tensor.
Returns:
a tensor of the specified dimensions, with undefined components.
See Also:
Facade (method)
Postconditions:
Utilities.equalsAll(RES.dimensions(), dimensions)

ZERO

Tensor ZERO(int[] dimensions)
Gets zero tensor, with all elements set to 0.


constant

Tensor constant(Tensor t)
Returns an unmodifiable view of the specified tensor.

The resulting tensor is a read-only view of this tensor. So, this method allows modules to provide users with "read-only" access to constant tensors.

Query operations on the returned tensor "read through" to the specified tensor, and attempts to modify the returned tensor, whether direct or via its iterator, result in an UnsupportedOperationException.

Note that cloning a constant tensor will not return a constant tensor, but a clone of the specified tensor t.


polynomial

Polynomial polynomial(java.lang.Object coefficients)
Returns a polynomial with the specified coefficients. The number of variables equals the rank (i.e. number of dimensions) of the array of coefficients.

Note that the resulting polynomial may or may not be backed by the specified array.

Polynomials of type UnivariatePolynomial, are returned for polynomials in one variable.

Parameters:
coefficients - a multi-dimensional array a containing the coefficients of the polynomial.
Returns:
the polynomial a0,...,0 + a1,0,...,0X1 + a1,1,0,....,0X1X2 + ... + a2,1,0,....,0X12X2 + ... + ad1,...,dnX1d1...&Xndn.
See Also:
Facade (method)
Preconditions:
coefficients is a rectangular multi-dimensional array of arithmetic objects or of primitive types

polynomial

Polynomial polynomial(java.util.Map exponentCoefficientMap)
Returns a polynomial with the specified (partial) coefficient map.

Note that the resulting polynomial may or may not be backed by the specified map.

Polynomials of type UnivariatePolynomial, are returned for polynomials in one variable.

Parameters:
exponentCoefficientMap - a map mapping exponent to coefficient.
Returns:
the polynomial aiXi according to the indices i and coefficients ai in the exponentCoefficientMap.
See Also:
Facade (method)
Preconditions:
keys in exponentCoefficientMap are compatible

asPolynomial

Polynomial asPolynomial(Tensor coefficients)
Returns a polynomial view of a tensor.

The returned polynomial is a view of the tensor. It interprets the components of the tensor as the coefficients of a polynomial.

Parameters:
coefficients - a tensor a containing the coefficients of the polynomial.
Returns:
the polynomial a0,...,0 + a1,0,...,0X1 + a1,1,0,....,0X1X2 + ... + a2,1,0,....,0X12X2 + ... + ad1,...,dnX1d1...&Xndn.
See Also:
polynomial(Object), asTensor(Polynomial)

asTensor

Tensor asTensor(Polynomial p)
Returns a vector view of the coefficients of a polynomial.

The returned tensor is a view of the polynomial. It interprets the coefficients of the polynomial as the components of a tensor.

Returns:
the tensor (a0,...,0,...,ad1,...,dn).
Throws:
java.lang.ClassCastException - if p does not have S=Nn as indices, and thus is not a multivariate polynomial in the proper sense.
See Also:
asPolynomial(Tensor)

constant

Polynomial constant(Polynomial p)
Returns an unmodifiable view of the specified polynomial. The result is a read only view.


MONOMIAL

Polynomial MONOMIAL(Arithmetic coefficient,
                    Arithmetic exponent)
The monomial c·Xi.

Parameters:
coefficient - the coefficient c of the monomial.
exponent - the exponent i of the monomial.

MONOMIAL

Polynomial MONOMIAL(Arithmetic coefficient,
                    int[] exponents)
The monomial c·X0i[0]...Xn-1i[n-1].

Parameters:
coefficient - the coefficient c of the monomial.
exponents - the exponents i of the monomial. The number of variables is n:=exponents.length.

MONOMIAL

Polynomial MONOMIAL(Arithmetic exponent)
The monomial 1·Xi. Note that the coefficient is 1Z.

Parameters:
exponent - the exponent i of the monomial.
See Also:
Convenience Method, MONOMIAL(Arithmetic,Arithmetic)

MONOMIAL

Polynomial MONOMIAL(int[] exponents)
The monomial 1·X0i[0]...Xn-1i[n-1]. Note that the coefficient is 1Z.

Parameters:
exponents - the exponents i of the monomial. The number of variables is n:=exponents.length.
See Also:
Convenience Method, MONOMIAL(Arithmetic,int[])

MONOMIAL

UnivariatePolynomial MONOMIAL(Arithmetic coefficient,
                              int exponent)
The univariate monomial c·Xe.

Parameters:
coefficient - the coefficient c of the monomial.
exponent - the exponents e of the monomial.
See Also:
Convenience Method

MONOMIAL

UnivariatePolynomial MONOMIAL(int exponent)
The univariate monomial 1·Xe. Note that the coefficient is 1Z.

Parameters:
exponent - the exponents e of the monomial.
See Also:
Convenience Method, MONOMIAL(Arithmetic,int)

polynomial

UnivariatePolynomial polynomial(Arithmetic[] coefficients)
Returns a (univariate) polynomial with the specified coefficients.

Note that the resulting polynomial may or may not be backed by the specified array.

Parameters:
coefficients - an array a containing the coefficients of the polynomial.
Returns:
the polynomial a0 + a1X + a2X2 + ... + anXn for n=coefficients.length-1.
See Also:
Facade (method), asPolynomial(Vector), Facade (method)

polynomial

UnivariatePolynomial polynomial(double[] coefficients)
See Also:
polynomial(Arithmetic[]), polynomial(Object)

polynomial

UnivariatePolynomial polynomial(int[] coefficients)
See Also:
polynomial(Arithmetic[]), polynomial(Object)

asPolynomial

UnivariatePolynomial asPolynomial(Vector a)
Returns a polynomial view of a vector.

The returned polynomial is a view of the vector. It interprets the components of the vector as the coefficients of a polynomial.

Returns:
the polynomial a0 + a1X + a2X2 + ... + anXn for n:=a.dimension()-1.
See Also:
polynomial(Arithmetic[]), asVector(UnivariatePolynomial)

asVector

Vector asVector(UnivariatePolynomial p)
Returns a vector view of the coefficients of a polynomial.

The returned vector is a view of the polynomial. It interprets the coefficients of the polynomial as the components of a vector.

Returns:
the vector (a0,a1,a2,...,an) of the polynomial a0 + a1X + a2X2 + ... + anXn for n=a.degree().
See Also:
UnivariatePolynomial.getCoefficients(), asPolynomial(Vector)

constant

UnivariatePolynomial constant(UnivariatePolynomial p)
Returns an unmodifiable view of the specified polynomial. The result is a read only view.


quotient

Quotient quotient(Arithmetic a,
                  Function mod)
Returns a new quotient ā=[a]∈M/mod of the given value reduced with the quotient operator.

Note that unlike quotients of Euclidean rings and due to the black-box behaviour of the quotient operator these quotients do not guarantee an implementation of Arithmetic.inverse().

Parameters:
mod - is the quotient operator applied (see Quotient.getQuotientOperator()).

quotient

Quotient quotient(Euclidean a,
                  Euclidean m)
Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo m.

Will use special remainder classes modulo m in Euclidean rings. These remainder classes are those induced by the Euclidean remainder operator. Quotients of Euclidean rings have the big advantage of supporting a simple calculation of multiplicative inverses modulo m.


quotient

Quotient quotient(Polynomial a,
                  java.util.Set m,
                  java.util.Comparator monomialOrder)
Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo (m).

Will use special remainder classes modulo (m) for a Groebner basis m of (multivariate) polynomial rings. These remainder classes are those induced by the reduction operator.

Parameters:
m - the Groebner basis modulo whose generated ideal (m) to form the quotients.
monomialOrder - the monomial order applied for reducing polynomials.
Preconditions:
m = AlgebraicAlgorithms.groebnerBasis(m,monomialOrder)
Postconditions:
RES = quotient(a, AlgebraicAlgorithms.reduce(m, monomialOrder))

quotient

Quotient quotient(Euclidean a,
                  UnivariatePolynomial m)
(disambiguates type unification). Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo m.

Being identical to quotient(Euclidean,Euclidean), this method only helps resolving the argument type ambiguity for polynomials. This type ambiguity will not occur at all, if templates have been enabled.

See Also:
quotient(Euclidean,Euclidean)

quotient

Quotient quotient(Euclidean a,
                  Function mod)
(disambiguates type unification). Returns a new quotient ā=[a]∈M/mod of the given value reduced with the quotient operator.

Being identical to quotient(Arithmetic,Function), this method only helps resolving the argument type ambiguity for polynomials. This type ambiguity will not occur at all, if templates have been enabled.

Parameters:
a - the value
mod - is the quotient operator applied (see Quotient.getQuotientOperator()).
See Also:
quotient(Arithmetic,Function)

quotient

Quotient quotient(Arithmetic a,
                  Polynomial m)
(traps type unification error).

This method only helps resolving the argument type ambiguity for polynomials. This type ambiguity will not occur at all, if templates have been enabled. Even though Polynomials extends Function<....,R>, it does not extend Function if A is the type of a. Therefore it (usually) is not a quotient operator as expected by quotient(Arithmetic,Function). However, if you have disabled templates, then your compiler will not be able to detect the type unification error occurring in the generic arguments.

Throws:
java.lang.ClassCastException - if a and m are not both instances of Euclidean.
See Also:
quotient(Arithmetic,Function)

quotient

Quotient quotient(int a,
                  int m)
(Convenience) Returns a new quotient ā=[a]∈M/(m) of the given value reduced modulo m.

This is only a convenience constructor for a special case of M=Z, M/(m)=Z/mZ. Although this case appears rather often, it is by far not the only case of quotients, of course.

See Also:
Convenience Method, quotient(Euclidean,Euclidean)

fraction

Fraction fraction(Arithmetic a,
                  Arithmetic s)
Returns a new fraction a⁄s ∈ S-1M = MS.

Note that this implementation does not check whether denominators are in the submonoid S, but only check for them to have the right type S. Since if S really is a monoid, it would suffice to check this at the instantiation, here. However, additionally this implementation does not check the prerequisite of Arithmetic.inverse() to have a numerator in the submonoid S, but only check for its type, again.

The only alternative would require users to provide predicates checking for containement in the submonoid S, all the time.

Also note that due to computational aspects, we generally assume the underlying ring to be an integrity domain for equality checking, of course.


fraction

Fraction fraction(Arithmetic a)
Returns a new fraction a⁄1 ∈ S-1M = MS.

Returns:
canonical embedding of a∈ M into S-1M = MS.

symbol

Symbol symbol(java.lang.String signifier)
Returns a new algebraic symbol.

Returns:
the algebraic symbol signifier.

parse

Arithmetic parse(java.lang.String s)
                 throws java.lang.NumberFormatException
Returns an arithmetic object whose value is equal to that of the representation in the specified string.

Parameters:
s - the string to be parsed.
Returns:
an instance of arithmetic that is equal to the representation in s.
Throws:
java.lang.NumberFormatException - if the string does not contain a parsable arithmetic object.
See Also:
Facade (method), valueOf(String)

valueOf

Arithmetic valueOf(java.lang.String s)
                   throws java.lang.NumberFormatException
Returns an arithmetic object whose value is equal to that of the representation in the specified string.

Parameters:
s - the string to be parsed.
Returns:
an instance of arithmetic that is equal to the representation in s.
Throws:
java.lang.NumberFormatException - if the string does not contain a parsable arithmetic object.
See Also:
Facade (method), parse(String)

asVector

Vector asVector(Matrix m)
Returns a vector view of the specified matrix. The result is a structurally unmodifiable view.

See Also:
asVector(Tensor)

asVector

Vector asVector(Tensor t)
Returns a vector view of the specified tensor. The result is a structurally unmodifiable view.

The tensor is interpreted row-wise as a vector.


narrow

Scalar narrow(Scalar val)
Returns a minimized Scalar whose value is equal to that of the specified scalar.

Returns:
an instance of scalar that is most restrictive. This means that an integer will be returned instead of a real whenever possible and so on.
Postconditions:
RES.equals(val)

getCoercer

Function getCoercer()
Get the transformation function for coercing arithmetic objects. This transformation is a function that transforms an array of arithmetic objects into an array of coerced arithmetic objects whose values are equal to the original ones.
coerce
arithmetic objects have been coerced if either
  • they have the same type, and this type is the infimum type (the most restrictive one). So whenever possible an integer will be preferred over a rational, a rational over a real and that over a complex. That is they are instances of the common superclass.
  • or they have otherwise minimum compatible types, such as a matrix and a vector.

This transformation function is often used to implement sly arithmetic operations with full dynamic dispatch by Operations.

Returns:
a transformation function that takes an array of objects (usually Arithmetic objects) and returns an array of the same length (usually 2). The elements returned have the same value as the elements in the argument array. And all will have the coerced type. This means that an integer will be returned instead of a real whenever possible, a real instead of a complex and so on. But it will always be true that both elements returned have compatible types, or a RuntimeException will be thrown.
See Also:
Operations, setCoercer(orbital.logic.functor.Function)
Preconditions:
0<=RES.args.length && RES.args.length<=2 (currently)
Postconditions:
REs.RES.length==RES.args.length && (RES.RES[0].getClass() "compatible to" RES.RES[1].getClass() || RES.RES[0].getClass() == RES.RES[1].getClass())

getCoercer

Function getCoercer(boolean commutative)
Get the transformation function for coercing arithmetic objects taking into account commutativity. The returned transformation does the same as getCoercer(), except that when commutative=true, the arithmetic objects passed to it can be swapped to get compatible objects.

Parameters:
commutative - whether the returned transformation is allowed to commute (swap) its arguments provided that this is correct for the given types.
See Also:
getCoercer()

setCoercer

void setCoercer(Function coerce)
                throws java.lang.SecurityException
Set the transformation function for coercion.

The transformation function set here must fulfill the same criteria that the default one does as described in the getCoercer() method. To simply hook an additional transformation, implement your transformation function on top of the one got from getCoercer().

Throws:
java.lang.SecurityException
See Also:
getCoercer()

setCoercer

void setCoercer(boolean commuatative,
                Function coerce)
                throws java.lang.SecurityException
Set the transformation function for coercion.

The transformation function set here must fulfill the same criteria that the default one does as described in the getCoercer() method. To simply hook an additional transformation, implement your transformation function on top of the one got from getCoercer().

Parameters:
commutative - whether the given coercer will be allowed to commute (swap) its arguments provided that this is correct for the given types.
Throws:
java.lang.SecurityException
See Also:
getCoercer(boolean)

getNormalizer

Function getNormalizer()
Get the transformation function for normalizing arithmetic objects. This transformation is a function that transforms an arithmetic object into normalized representation of the same arithmetic object. Whenever possible and feasible, this normalization function will even assure canonical representations.

Returns:
a transformation function that takes arithmetic objects to arithmetic objects.
See Also:
setNormalizer(orbital.logic.functor.Function)
Postconditions:
&& (RES.RES.getClass() "compatible to" RES.arg.getClass())

setNormalizer

void setNormalizer(Function normalizer)
                   throws java.lang.SecurityException
Set the transformation function for normalizing arithmetic objects.

The transformation function set here must fulfill the same criteria that the default one does as described in the getNormalizer() method. To simply hook an additional transformation, implement your transformation function on top of the one got from getNormalizer().

Throws:
java.lang.SecurityException
See Also:
getNormalizer()

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.