Previous Page Next Page Contents

Dom::Multiset -- multisets

Introduction

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

Details

Creating Elements

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

Parameters

s1, s2... - objects of any type

Categories

Cat::Set

Related Domains

DOM_SET, Dom::ImageSet

Details

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.

Method normal: normalization of multisets

Method powerset: the power set of a multiset

Method random: random multiset generation

Method _index: multiset indexing

Method contains: check on existence of set elements

Method equal: test on equality of multisets

Method expand: expand a multiset to a sequence of its elements

Method getElement: extracts one element from a multiset

Method has: check on existence of (sub-)expressions

Method map: apply a function to multiset elements

Method multiplicity: multiplicity of an element

Method nops: number of different elements in a multiset

Method op: elements of a multiset

Method select: selecting of multiset elements

Method split: splitting a multiset

Method subs: substitution of elements in multisets

Method convert: conversion into a multiset

Method convert_to: multiset conversion

Method expr: multiset conversion into an object of a kernel domain

Method bin_intersect: intersection of two multisets

Method bin_minus: subtraction of two multisets

Method homog_union: union of multisets

Method nested_union: union of nested sets

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)
                             {[a, 2], [b, 1]}

We create another multiset:

>> set2 := Dom::Multiset(a, c, c)
                             {[a, 1], [c, 2]}

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

>> set1 union set2
                         {[b, 1], [a, 3], [c, 2]}
>> set1 intersect set2
                                 {[a, 1]}
>> contains(set1, a), contains(set1, d)
                                TRUE, FALSE

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)
                 {[a, 2], [b, 1], [d, 1], [e, 1], [c, 4]}
>> expand(set)
                         e, d, c, c, c, c, b, a, a

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

>> coerce(set, DOM_SET)
                              {a, b, c, d, e}

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)
                 {[a, 2], [b, 1], [d, 1], [e, 1], [c, 4]}

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.

Super-Domain

Dom::BaseDomain

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000