1 |
|
2 |
|
3 | # Function setMultiplicity
|
4 |
|
5 | Count the multiplicity of an element in a multiset.
|
6 | A multi-dimension array will be converted to a single-dimension array before the operation.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.setMultiplicity(element, set)
|
13 | ```
|
14 |
|
15 | ### Parameters
|
16 |
|
17 | Parameter | Type | Description
|
18 | --------- | ---- | -----------
|
19 | `e` | number | BigNumber | Fraction | Complex | An element in the multiset
|
20 | `a` | Array | Matrix | A multiset
|
21 |
|
22 | ### Returns
|
23 |
|
24 | Type | Description
|
25 | ---- | -----------
|
26 | number | The number of how many times the multiset contains the element
|
27 |
|
28 |
|
29 | ## Examples
|
30 |
|
31 | ```js
|
32 | math.setMultiplicity(1, [1, 2, 2, 4]) // returns 1
|
33 | math.setMultiplicity(2, [1, 2, 2, 4]) // returns 2
|
34 | ```
|
35 |
|
36 |
|
37 | ## See also
|
38 |
|
39 | [setDistinct](setDistinct.md),
|
40 | [setSize](setSize.md)
|