Contents

Dom::Multiset

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

Dom::Multiset(<s1, s2, …>)

Description

Dom::Multiset is the domain of multisets, i.e., sets with possibly multiple identical elements.

A multiset is represented by a set of lists of the form [s, m], where s is an element of the multiset and m its multiplicity.

Multisets can be returned by the system solver solve. For example, the input solve(x^3 - 4*x^2 + 5*x - 2, x, Multiple) gives all roots of the polynomial x3 - 4 x2 + 5 x - 2 in form of the multiset {[1, 2], [2, 1]}.

The standard set operations such as union, intersection and subtraction of sets have been extended to deal with multisets.

These operations can handle different types of sets, such as sets of type DOM_SET and multisets. One may, for example, compute the union of the multiset {[a, 2], [b, 1]} and the set {c}, which results in the multiset {[a, 2], [b, 1], [c, 1]}.

The elements of the multiset are sorted at the time where the multiset is created. The system function sort is used in order to guarantee that exactly one representation exists for a multiset, independent of the sequence in which the arguments appear.

Dom::Multiset(s1, s2, ...) creates the multiset consisting of the elements s1, s2, ...

Multiple identical elements in s1, s2, ... are collected. For example, the call Dom::Multiset(a, b, a, c) creates a multiset with the elements a, b, c. The element a has multiplicity two, the other two elements b and c both have multiplicity one.

Superdomain

Dom::BaseDomain

Categories

Cat::Set

Examples

Example 1

The multiset {a, a, b} consists of the two different elements a and b, where a has multiplicity two and b has multiplicity one:

delete a, b, c:
set1 := Dom::Multiset(a, a, b)

We create another multiset:

set2 := Dom::Multiset(a, c, c)

Standard set operations such as disjoint union, intersection or subtraction are implemented for multisets and can be performed using the standard set operators of MuPAD®:

set1 union set2

set1 intersect set2

contains(set1, a), contains(set1, d)

Example 2

Some system functions were overloaded for multisets, such as expand, normal or split.

If we apply expand to a multiset, for example, we get an expression sequence of all elements of the multiset (appearing in correspondence to their multiplicity):

delete a, b, c, d, e:
set := Dom::Multiset(a, b, c, a, c, d, c, e, c)

expand(set)

If you want to convert a multiset into an ordinary set of the domain type DOM_SET, use coerce:

coerce(set, DOM_SET)

Note: The system function coerce uses the methods "convert" and "convert_to" of the domain Dom::Multiset.

Compare the last result with the return value of the function expr, when it is applied for multisets:

expr(set)

The result is a set of the domain type DOM_SET, consisting of lists of the domain type DOM_LIST with two entries, an element of the multiset and the corresponding multiplicity of that element.

Parameters

s1, s2, …

Objects of any type

Entries

"isFinite"

is TRUE because Dom::Multiset represents finite sets.

"inhomog_intersect"

a table of the form T = Proc(multiset, setoftypeT). This entry is used internally by the implementation, and thus should not be touched.

"inhomog_union"

a table of the form T = Proc(multiset, setoftypeT). This entry is used internally by the implementation, and thus should not be touched.

Methods

expand all

Mathematical Methods

normal — Normalization of multisets

normal(set)

This method overloads the function normal for multisets, i.e., one may use it in the form normal(set).

powerset — Power set of a multiset

powerset(set)

The power set of set is returned as a set of multisets.

random — Random multiset generation

random()

The number of elements created, including their multiplicities, is restricted to 20.

Access Methods

_index — Multiset indexing

_index(set, i)

See the method "op".

This method overloads the function _index for multisets, i.e., one may use it in the form set[i], or in functional notation: _index(set, i).

contains — Check on existence of set elements

contains(set, s)

This method overloads the function contains for multisets, i.e., one may use it in the form contains(set, s).

equal — Test on equality of multisets

equal(set1, set2)

The system function _equal is used for the test.

expand — Expand a multiset to a sequence of its elements

expand(set)

This method overloads the function expand for multisets, i.e., one may use it in the form expand(set).

getElement — Extract one element from a multiset

getElement(set)

Note that the elements of the multiset are sorted with the use of the system function sort, and thus the order of a multiset depends on the sorting criteria specified by this function.

This method overloads the function solvelib::getElement, i.e., one may use it in the form solvelib::getElement(set).

has — Check on existence of (sub-)expressions

has(set, expr)

To check whether expr is contained as an element of set and not as a subexpression of the elements of set, the function contains must be used.

This method overloads the function has for multisets, i.e., one may use it in the form has(set, expr).

map — Apply a function to multiset elements

map(set, func, <expr, …>)

It overloads the function map for multisets, i.e., one may use it in the form map(set, func, ...).

multiplicity — Multiplicity of an element

multiplicity(set, s)

Elements which are not contained in set have multiplicity zero.

card — Number of elements in a multiset

card(set)

This method overloads the function card.

nops — Number of different elements in a multiset

nops(set)

This method overloads the function nops for multisets, i.e., one may use it in the form nops(set).

op — Element of a multiset

op(set)

op(set, i)

Returns the i-th element s of the multiset set and its multiplicity m in form of the list [s, m].

See also the method "_index".

Note that the elements of the multiset are sorted with the use of the system function sort, and thus the order of a multiset depends on the sorting criteria specified by this function.

This method overloads the function op for multisets, i.e., one may use it in the form op(s, i).

select — Selecting of multiset elements

select(set, func, <expr, …>)

This method overloads the function select for multisets, i.e., one may use it in the form select(set, func, ...). See select for details.

split — Splitting a multiset

split(set, func, <expr, …>)

This method overloads the function split for multisets, i.e., one may use it in the form split(set, func, ...). See split for details.

subs — Substitution of elements in multisets

subs(set, …)

This method overloads the function subs for multisets, i.e., one may use it in the form subs(set, ...).

Conversion Methods

convert — Conversion into a multiset

convert(x)

FAIL is returned if the conversion fails.

Currently only sets of type DOM_SET can be converted into multisets.

convert_to — Multiset conversion

convert_to(set, T)

FAIL is returned if the conversion fails.

Currently T may either be DOM_SET to convert the multiset set into a set (loosing the multiplicities and the order of the elements of set), or DOM_EXPR or "_exprseq" to convert set into an expression sequence (see the method "expand" for details).

See also the method "expr".

expr — Multiset conversion into an object of a kernel domain

expr(set)

This method overloads the function expr for multisets, i.e., one may use it in the form expr(set).

sort — Sorting of multisets

sort(set)

This method overloads the function sort for multisets, i.e., one may use it in the form sort(set).

Technical Methods

bin_intersect — Intersection of two multisets

bin_intersect(set1, set2)

This method is called from routines defined in the category Cat::Set, which implements among others the overloading of the function intersect for multisets. One may intersect two multisets directly by set1 intersect set2, or in functional notation by _intersect(set1, set2).

bin_minus — Subtraction of two multisets

bin_minus(set1, set2)

This method is called from routines defined in the category Cat::Set, which implements among others the overloading of the function minus for multisets. One may subtract two multisets directly by set1 minus set2, or in functional notation by _minus(set1, set2).

homog_union — Union of multisets

homog_union(set, …)

This method is called from routines defined in the category Cat::Set, which implements among others the overloading of the function union for multisets. One may compute the union of two multisets directly by set1 union set2, or in functional notation by _union(set1, set2).

nested_union — Union of nested sets

nested_union(setofsets)

This method is called from routines defined in the category Cat::Set, which implements among others the overloading of the function union for multisets and sets. One may compute the union of multisets and sets directly by set1 union set2, or in functional notation by _union(set1, set2).

See Also

MuPAD Domains

Was this topic helpful?