Dom
::Product
Homogeneous direct products
Syntax
Domain Creation
Dom::Product(Set
, <n
>)
Dom::ProductSetn(e1, e2, …
, en
)
Dom::ProductSetn(List
)
Description
Dom::Product(Set, n)
is an n
-fold
direct product of the domain Set.
Dom::Product(Set, n)(e1, e2, ..., en)
creates
the n
-tuple (e_{1}, e_{2},
…, e_{n}).
The objects e1
, e2
, ..., en
must
be convertible into elements of the domain Set
,
otherwise an error message is issued.
Dom::Product(Set, n)(List)
creates the n
-tuple (l_{1}, l_{2},
…, l_{n}).
The n
elements l_{i} of List
must
be convertible into elements of the domain Set
,
otherwise an error message is issued.
The list must consist of exactly n
elements,
otherwise an error message is issued.
Following to the definition of a direct product many of the
methods such as "D"
and "_negate"
just
map the operation to all the components of the tuple.
Most n
-ary methods like "_plus"
and "_mult"
apply
the operation component-wise to the tuples.
Examples
Example 1
Define the 3-fold direct product of the rational numbers:
and create elements:
We use the standard arithmetical operators to calculate with
such tuples:
Some system functions were overloaded for such elements, such
as diff
, map
or zip
(see the description
of the corresponding methods "diff"
, "map"
and "zip"
above).
For example, to divide each component of a
by
2 we enter:
The quoted character `/`
is another notation
for the function _divide
, the functional form of
the division operator /
.
Be careful that the mapping function returns elements of the
domain the product is defined over. This is not checked by the function map
(for
efficiency reasons) and may lead to “invalid” tuples.
For example:
But the components of b
are no longer rational
numbers!
Entries
"dimen" | is the dimension of Dom::Product(Set, n) ,
which is equal to n . |
"coeffRing" | is the domain S . |
"one" | is the n -tuple (Set::one,
Set::one, ..., Set::one) . This entry only exists if Set is
a monoid, i.e., a domain of category Cat::Monoid . |
"zero" | is the n -tuple (Set::zero,
Set::zero, ..., Set::zero) . This entry only exists if Set is
an Abelian group, i.e., a domain of category Cat::AbelianGroup . |
Methods
expand all
Mathematical Methods
_divide
— Divide tuples
_divide(x
, y
)
This method only exists if Set
is a (multiplicative)
group, i.e., a domain of category Cat::Group
.
This method overloads the function _divide
for n
-tuples,
i.e., one may use it in the form x / y
, or in functional
notation: _divide(x, y)
.
_invert
— Compute the inverse of a tuple
_invert(x
)
This method only exists if Set
is a (multiplicative)
group, i.e., a domain of category Cat::Group
.
This method overloads the function _invert
for n
-tuples,
i.e., one may use it in the form 1/x
or x^(-1)
,
or in functional notation: _inverse(x)
.
_less
— Less-than relation
_less(x
, y
)
An implementation is provided only if Set
is
an ordered set, i.e., a domain of category Cat::OrderedSet
.
This method overloads the function _less
for n
-tuples,
i.e., one may use it in the form x < y
, or in
functional notation: _less(x, y)
.
_mult
— Multiplie tuples by tuples and scalars
_mult(x
, y, …
)
If x
is not of the type Dom::Product(Set,n)
,
it is considered as a scalar which is multiplied to each component
of the n
-tuple y
(and vice versa).
This method only exists if Set
is a semigroup,
i.e., a domain of category Cat::SemiGroup
.
This method also handles more than two arguments. In this case,
the argument list is split into two parts of the same length which
both are multiplied with the function _mult
. These two result
are multiplied again with _mult
whose result then
is returned.
This method overloads the function _mult
for n
-tuples,
i.e., one may use it in the form x * y
, or in functional
notation: _mult(x, y)
.
_negate
— Negate an n
-tuple
_negate(x
)
This method overloads the function _negate
for n
-tuples,
i.e., one may use it in the form -x
, or in functional
notation: _negate(x)
.
_power
— i
th power of a tuple
_power(x
, i
)
An implementation is provided only if Set
is
a semigroup, i.e., a domain of category Cat::SemiGroup
.
This method overloads the function _power
for n
-tuples,
i.e., one may use it in the form x^i
, or in functional
notation: _power(x, i)
.
_plus
— Add tuples
_plus(x
, y, …
)
The sum of two n
-tuples x and y is
defined component-wise as (x_{1} + y_{1},
…, x_{n} + y_{n}).
This method overloads the function _plus
for n
-tuples,
i.e., one may use it in the form x + y
, or in functional
notation: _plus(x, y)
.
D
— Differential operator
D(x
)
An implementation is provided only if Set
is
a partial differential ring, i.e., a domain of category Cat::PartialDifferentialRing
.
This method overloads the operator D
for n
-tuples,
i.e., one may use it in the form D(x)
.
diff
— Differentiation of n
-tuples
diff(a
, x
)
This method overloads the function diff
for n
-tuples,
i.e., one may use it in the form diff(a, x)
.
An implementation is provided only if Set
is
a partial differential ring, i.e., a domain of category Cat::PartialDifferentialRing
.
equal
— Test on equality of n
-tuples
intmult
— Multiple of a tuple
intmult(x
, k
)
An implementation is provided only if Set
is
an Abelian semigroup, i.e., a domain of category Cat::AbelianSemiGroup
.
iszero
— Test on zero
iszero(x
)
Note that there may be more than one representation of the zero n
-tuple
if R
does not have Ax::canonicalRep
.
This method overloads the function iszero
for n
-tuples,
i.e., one may use it in the form iszero(x)
.
random
— Random tuple generation
Access Methods
_index
— Tuple indexing
_index(x
, i
)
See also the method "op"
.
This method overloads the function _index
for n
-tuples,
i.e., one may use it in the form x[i]
, or in functional
notation: _index(x, i)
.
map
— Apply a function to tuple components
map(x
, func
,
<expr, …
>)
Note
Note that the function values will not be
implicitly converted into elements of the domain Set
.
One has to take care that the function calls return elements of the
domain type Set
.
This method overloads the function map
for n
-tuples,
i.e., one may use it in the form map(x, func, ...)
.
mapCanFail
— Apply a function to tuple components
mapCanFail(x
, func
,
<expr, …
>)
op
— Component of a tuple
op(x
, i
)
op(x
)
See also the method "_index"
.
This method overloads the function op
for n
-tuples, i.e.,
one may use it in the form op(x, i)
.
Returns a sequence of all components of x
.
set_index
— Assigning tuple components
set_index(x
, i
, e
)
See also the method "subsop"
.
Note
This method does not check whether e
has
the correct type.
This method overloads the indexed assignment _assign
for n
-tuples,
i.e., one may use it in the form x[i] := e
, or
in functional notation: _assign(x[i], e)
.
sort
— Sorting the components of a tuple
sort(x
)
This method overloads function sort
for tuples, i.e. one may use it
in the form sort(x)
.
subs
— Substitution of tuple components
subs(x, …
)
Note
The objects obtained by the substitutions will not be implicitly
converted into elements of the domain Set
. One
has to take care that the substitutions return elements of the domain Set
.
This method overloads the function subs
for n
-tuples,
i.e., one may use it in the form subs(x, ...)
.
See subs
for
details and calling sequences.
testEach
— Check every component for a certain condition
testEach(x
, func
,
<expr, …
>)
func
must return either TRUE
or FALSE
,
otherwise a runtime error is raised.
testOne
— Check an component for a certain condition
testOne(x
, func
,
<expr, …
>)
func
must return either TRUE
or FALSE
,
otherwise a runtime error is raised.
zip
— Combine tuples component-wise
zip(x
, y
, func
,
<expr, …
>)
Note
The function values will not be implicitly converted into elements
of the domain Set
. One has to take care that the
function calls return elements of the domain Set
.
This method overloads the function zip
for n
-tuples,
i.e., one may use it in the form zip(x, y, func, ...)
.
zipCanFail
— Combine tuples component-wise
zipCanFail(x
, y
, func
,
<expr, …
>)
Conversion Methods
convert
— Conversion into an n
-tuple
convert(List
)
convert(e1
, <e2,
…
>)
FAIL
is returned if this conversion fails.
Tries to convert the arguments into an element of the domain Dom::Product(Set,
n)
. This can be done if exactly n
arguments
are given where each argument can be converted into an element of
the domain Set
.
FAIL
is returned if this conversion fails.
expr
— Conversion into an object of a kernel domain
expr(x
)
This method overloads the function expr
for n
-tuples,
i.e., one may use it in the form expr(x)
.