1 |
|
2 |
|
3 | # Function setCartesian
|
4 |
|
5 | Create the cartesian product of two (multi)sets.
|
6 | Multi-dimension arrays will be converted to single-dimension arrays
|
7 | and the values will be sorted in ascending order before the operation.
|
8 |
|
9 |
|
10 | ## Syntax
|
11 |
|
12 | ```js
|
13 | math.setCartesian(set1, set2)
|
14 | ```
|
15 |
|
16 | ### Parameters
|
17 |
|
18 | Parameter | Type | Description
|
19 | --------- | ---- | -----------
|
20 | `a1` | Array | Matrix | A (multi)set
|
21 | `a2` | Array | Matrix | A (multi)set
|
22 |
|
23 | ### Returns
|
24 |
|
25 | Type | Description
|
26 | ---- | -----------
|
27 | Array | Matrix | The cartesian product of two (multi)sets
|
28 |
|
29 |
|
30 | ## Examples
|
31 |
|
32 | ```js
|
33 | math.setCartesian([1, 2], [3, 4]) // returns [[1, 3], [1, 4], [2, 3], [2, 4]]
|
34 | math.setCartesian([4, 3], [2, 1]) // returns [[3, 1], [3, 2], [4, 1], [4, 2]]
|
35 | ```
|
36 |
|
37 |
|
38 | ## See also
|
39 |
|
40 | [setUnion](setUnion.md),
|
41 | [setIntersect](setIntersect.md),
|
42 | [setDifference](setDifference.md),
|
43 | [setPowerset](setPowerset.md)
|