Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Dom::Multiset

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

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(set)

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

powerset(set)

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

random()

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

Access Methods

_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(set, s)

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

equal(set1, set2)

The system function _equal is used for the test.

expand(set)

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

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(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(set, func, <expr, …>)

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

multiplicity(set, s)

Elements which are not contained in set have multiplicity zero.

card(set)

This method overloads the function card.

nops(set)

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

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(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(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(set, …)

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

Conversion Methods

convert(x)

FAIL is returned if the conversion fails.

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

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(set)

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

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(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(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(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(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?