convert/MultiSet - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : MultiSet : convert/MultiSet

convert/MultiSet

convert tables, lists, sets or algebraic expressions to MultiSets

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

convert( t, MultiSet )

convert( t, MultiSet, g_opt )

convert( M, r )

Parameters

t

-

object or expression to convert

g_opt

-

identical(generalized)=truefalse; whether to return a generalized MultiSet

M

-

MultiSet; MultiSet to be converted to something else

r

-

name; what to convert M to

Description

• 

convert(t, MultiSet) converts the expression t to a MultiSet, using the following rules:

– 

if t is a MultiSet, then a copy of t is returned.

– 

if t is a set or list, it is converted to a MultiSet by passing t (and the generalized option, if given) to the MultiSet object constructor.

– 

if t is a table whose indices are expression sequences of length 1 and whose entries are positive integers (or any real numbers, if the generalized = true option is given), it is converted to a MultiSet whose elements are the table indices with multiplicities as given by the table entries.

– 

if t is an algebraic expression of type * or ^, where the factor exponents are real numbers, it is converted to a MultiSet whose elements are the factors of the expression, with multiplicities the corresponding factor multiplicities; if the generalized = true option is not given, factors with non-positive-integer exponents will be treated as general algebraic expressions, with multiplicity 1.

– 

if t is any other algebraic expression, the MultiSet constructed by the call MultiSet( [t, 1] ) (or MultiSet[generalized]( [t, 1] )) is returned.

• 

The generalized = true option can be given simply as generalized.

• 

convert( M, list ) converts the MultiSet M to a list; this is equivalent to [op(Entries(M))].

• 

convert( M, set ) converts the MultiSet M to a set; this is equivalent to Members(M).

• 

convert( M, table ) returns a copy of the Maple table which is used to hold the data which defines M; the indices of the returned table are the elements of M, and the entries of the table are the corresponding multiplicities.  Note that this table has the sparse indexing function.

Examples

Mconverta,b,a,c,MultiSet

Ma,2,b,1,c,1

(1)

convertM,MultiSet

a,2,b,1,c,1

(2)

converttablea=13,b=2,MultiSet,generalized

a,13,b,−2

(3)

convertx2x33x32x2,MultiSet

x,2,1x32x2,1,x3,3

(4)

convertx2x33x32x2,MultiSet,generalized

x,2,x3,3,x32x,−2

(5)

convertx121x32,MultiSet,generalized

x,12,1x,32

(6)

convertM,list

c,1,b,1,a,2

(7)

convertM,set

a,b,c

(8)

tconvertM,table

ttablesparse,c=1,b=1,a=2

(9)

td3

td3

(10)

M

a,2,b,1,c,1

(11)

Compatibility

• 

The convert/MultiSet command was introduced in Maple 2016.

• 

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

See Also

convert/multiset

MultiSet

table