 convert/MultiSet - Maple Help

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

convert/MultiSet

convert tables, lists, sets or algebraic expressions to MultiSets 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

 > $M≔\mathrm{convert}\left(\left[a,b,a,c\right],\mathrm{MultiSet}\right)$
 ${M}{≔}\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{1}\right]{,}\left[{c}{,}{1}\right]\right\}$ (1)
 > $\mathrm{convert}\left(M,\mathrm{MultiSet}\right)$
 $\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{1}\right]{,}\left[{c}{,}{1}\right]\right\}$ (2)
 > $\mathrm{convert}\left(\mathrm{table}\left(\left[a=\frac{1}{3},b=-2\right]\right),\mathrm{MultiSet},\mathrm{generalized}\right)$
 $\left\{\left[{a}{,}\frac{{1}}{{3}}\right]{,}\left[{b}{,}{-2}\right]\right\}$ (3)
 > $\mathrm{convert}\left(\frac{{x}^{2}{\left(x-3\right)}^{3}}{{\left({x}^{3}-2x\right)}^{2}},\mathrm{MultiSet}\right)$
 $\left\{\left[{x}{,}{2}\right]{,}\left[\frac{{1}}{{\left({{x}}^{{3}}{-}{2}{}{x}\right)}^{{2}}}{,}{1}\right]{,}\left[{x}{-}{3}{,}{3}\right]\right\}$ (4)
 > $\mathrm{convert}\left(\frac{{x}^{2}{\left(x-3\right)}^{3}}{{\left({x}^{3}-2x\right)}^{2}},\mathrm{MultiSet},\mathrm{generalized}\right)$
 $\left\{\left[{x}{,}{2}\right]{,}\left[{x}{-}{3}{,}{3}\right]{,}\left[{{x}}^{{3}}{-}{2}{}{x}{,}{-2}\right]\right\}$ (5)
 > $\mathrm{convert}\left({x}^{\frac{1}{2}}{\left(1-x\right)}^{-\frac{3}{2}},\mathrm{MultiSet},\mathrm{generalized}\right)$
 $\left\{\left[{x}{,}\frac{{1}}{{2}}\right]{,}\left[{1}{-}{x}{,}{-}\frac{{3}}{{2}}\right]\right\}$ (6)
 > $\mathrm{convert}\left(M,\mathrm{list}\right)$
 $\left[\left[{a}{,}{2}\right]{,}\left[{b}{,}{1}\right]{,}\left[{c}{,}{1}\right]\right]$ (7)
 > $\mathrm{convert}\left(M,\mathrm{set}\right)$
 $\left\{{a}{,}{b}{,}{c}\right\}$ (8)
 > $t≔\mathrm{convert}\left(M,\mathrm{table}\right)$
 ${t}{≔}{table}{}\left({\mathrm{sparse}}{,}\left[{a}{=}{2}{,}{b}{=}{1}{,}{c}{=}{1}\right]\right)$ (9)
 > $t\left[d\right]≔3$
 ${{t}}_{{d}}{≔}{3}$ (10)
 > $M$
 $\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{1}\right]{,}\left[{c}{,}{1}\right]\right\}$ (11) Compatibility

 • The convert/MultiSet command was introduced in Maple 2016.