1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#[macro_export]
macro_rules! hstack {
    // Two
    ( $x:expr, $y:expr ) => {
        {
            let l = $x.len();
            let mut temp = $x;
            temp.extend(&$y);
            matrix(temp, l, 2, Col)
        }
    };

    // Multi
    ( $x0:expr, $( $x: expr ),* ) => {
        {
            let r = $x0.len();
            let mut temp0 = $x0;
            let mut c = 1usize;

            $(
                let mut temp = $x;
                // Must equal row
                assert_eq!(r, temp.len());
                // Add column
                c += 1;
                temp0.extend_from_slice(&temp[..]);
            )*
            matrix(temp0, r, c, Col)
        }
    };
}

#[macro_export]
macro_rules! vstack {
    // Two
    ( $x:expr, $y:expr ) => {
        {
            let l = $x.len();
            let mut temp = $x;
            temp.extend(&$y);
            matrix(temp, 2, l, Row)
        }
    };

    // Multi
    ( $x0:expr, $( $x: expr ),* ) => {
        {
            let c = $x0.len();
            let mut temp0 = $x0;
            let mut r = 1usize;

            $(
                let mut temp = $x;
                // Must equal row
                assert_eq!(c, temp.len());
                // Add column
                r += 1;
                temp0.extend_from_slice(&temp[..]);
            )*
            matrix(temp0, r, c, Row)
        }
    };
}