MultiSet - Maple Help

Online Help

All Products    Maple    MapleSim


MultiSet

overview of MultiSets

 

Calling Sequence

Parameters

Description

List of MultiSet Object Commands

Examples

Compatibility

Calling Sequence

MultiSet( element_spec, ... )

MultiSet['generalized']( element_spec, ... )

Parameters

element_spec

-

specifies the MultiSet elements and their multiplicities

generalized

-

literal index which indicates that a generalized MultiSet should be constructed

Description

• 

A MultiSet is a data structure which stores and manipulates an unordered collection of elements which may be repeated.  It is implemented as a Maple object. The procedure exports of a MultiSet are used to create, update, query and otherwise interact with one or more MultiSet objects.

• 

A MultiSet can be constructed from another MultiSet, from a set or list of elements, or from an expression sequence of elements with their multiplicities:

– 

If M is a MultiSet, then MultiSet(M) produces a new MultiSet with the same elements and multiplicities.

– 

If L is a Maple list or set of two-element lists, where the second element of each list is a non-negative integer (normal case) or real number (generalized case), then MultiSet(L) is a MultiSet whose elements are the first elements of each list with multiplicities given by the corresponding second elements of each list.

– 

If L is any other Maple list, then MultiSet(L) is a MultiSet of the same elements, with multiplicities the same as in L.

– 

If S is any other Maple set, then MultiSet(S) is a MultiSet of the same elements, each with multiplicity 1.

– 

Each of the expressions M( a, b=2, c=3 ) and M( a, [b, 2], [c, 3] ) constructs a MultiSet in which the element a has multiplicity 1, b has multiplicity 2 and c has multiplicity 3.  Here a, b, and c can be any Maple expressions.

– 

Multiplicities must be non-negative integers, unless the generalized index is provided on the constructor, in which case arbitrary (real) numeric multiplicities are also permitted.  An element with multiplicity 0 is removed from its MultiSet.

• 

MultiSets are displayed using a set-of-lists-of-pairs notation, but MultiSets are not sets in the usual Maple sense.  The convert command can be used to realize a MultiSet in a variety of different alternate formats.

• 

To test whether an expression is a MultiSet, use type(..., MultiSet).

• 

To iterate over a MultiSet, see MultiSet Iteration.

• 

For commands which operate on more than one MultiSet, for example intersect, at least one operand must be a MultiSet.  Other operands can be MultiSets, sets or lists; a non-MultiSet operand will be converted to a MultiSet before the operation is carried out.

• 

Generalized and standard (non-generalized) MultiSets cannot be combined in commands which operate on more than one MultiSet.  Note that this means that if a generalized MultiSet appears in an operation, for example, union, with another argument which is not a MultiSet (for example, a list or set), then that other argument will be converted to a generalized MultiSet before proceeding with the operation.

• 

The command IsGeneralized(M) can be used to determine if a MultiSet is generalized or not.

List of MultiSet Object Commands

• 

The following is a list of the commands which work with MultiSet objects.

*

+

<>

=

`[]`

Elements

Entries

in

Insert

intersect

IsEmpty

IsGeneralized

member

Members

minus

numelems

Remove

subset

symmdiff

union

Examples

MMultiSeta=2&comma;b&comma;4&comma;c

Ma&comma;2&comma;b&comma;4&comma;c&comma;1

(1)

NMultiSetgeneralizedx&comma;4&comma;y&comma;32&comma;z&comma;2

Nx&comma;4&comma;y&comma;32&comma;z&comma;−2

(2)

evalbM=MultiSetEntriesM

true

(3)

EntriesM

a&comma;2&comma;b&comma;4&comma;c&comma;1

(4)

Compatibility

• 

The MultiSet object was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

convert/multiset

convert/MultiSet

object

set