         }
         matrix.append(array)
     }
+    left = matrix
+    return left
+}
+
+func += <T: NumericType>(inout left: [[T]], right: [[T]]) throws -> [[T]] {
+    if left.count != right.count || left[0].count != right[0].count { throw MatrixError.NotAddable }
+    for i in 0..<left.count {
+        for j in 0..<left[0].count {
+            left[i][j] = left[i][j] + right[i][j]
+        }
+    }
+    return left
+}
+
+func + <T: NumericType>(left: [[T]], right: [[T]]) throws -> [[T]] {
+    var matrix = left
+    try matrix += right
     return matrix
 }
 
+func *= <T: NumericType>(inout left: [[T]], right: T) -> [[T]] {
+    for row in 0..<left.count {
+        for column in 0..<left[row].count {
+            left[row][column] = left[row][column]*right
+        }
+    }
+    return left
+}
+
 func * <T: NumericType>(left: [[T]], right: T) -> [[T]] {
     var left = left
-    for row in 0..<left.count {
-        for column in 0..<left[row].count {
-            left[row][column] = left[row][column]*right
-        }
-    }
+    left *= right
     return left
 }
 
 func * <T: NumericType>(left: T, right: [[T]]) -> [[T]] {
     var right = right
-    for row in 0..<right.count {
-        for column in 0..<right[row].count {
-            right[row][column] = right[row][column]*left
-        }
-    }
+    right *= left
     return right
 }
 
-func print<T>(matrix: [[T]]) {
-    print(toLaTeX(matrix))
+func /= <T: NumericType>(inout left: [[T]], right: T) -> [[T]] {
+    for row in 0..<left.count {
+        for column in 0..<left[row].count {
+            left[row][column] = left[row][column]/right
+        }
+    }
+    return left
+}
+
+func / <T: NumericType>(left: [[T]], right: T) -> [[T]] {
+    var left = left
+    left /= right
+    return left
+}
+
+func / <T: NumericType>(left: T, right: [[T]]) -> [[T]] {
+    var right = right
+    right /= left
+    return right
+}
+
+func == <T: NumericType>(left: [[T]], right: [[T]]) -> Bool {
+    if left.count != right.count || left[0].count != right[0].count { return false }
+    var left = left
+    for row in 0..<left.count {
+        for column in 0..<left[row].count {
+            if left[row][column] != right[row][column] {
+                return false
+            }
+        }
+    }
+    return true
+}
+
+func != <T: NumericType>(left: [[T]], right: [[T]]) -> Bool {
+    return !(left == right)
 }
 
 func toLaTeX<T>(matrix: [[T]]) -> String {

    return out + "\\end{pmatrix}"
}

func toLaTeX<T : NumericType>(matrix1: [[T]], _ matrix2: [[T]]) -> String {
    var out = ""
    if let product = matrix1 * matrix2 {
        out = "\\[\n"
        out += toLaTeX(matrix1)
        out += "\\times\n"
        out += toLaTeX(matrix2)
        out += "=\n"
        out += toLaTeX(product)
        out += "\\] \\[ \\]\n"
    }
    return out
}

func toLaTeX<T : NumericType>(scalar: T, _ matrix: [[T]]) -> String {
    let product = scalar * matrix
    var out = "\\[\n"
    out += "\(scalar)"
    out += "\\times\n"
    out += toLaTeX(matrix)
    out += "=\n"
    out += toLaTeX(product)
    out += "\\] \\[ \\]\n"
    return out
}

func toLaTeX<T : NumericType>(matrix: [[T]], _ scalar: T) -> String {
    let product = matrix * scalar
    var out = "\\[\n"
    out += toLaTeX(matrix)
    out += "\\times\n"
    out += "\(scalar)"
    out += "=\n"
    out += toLaTeX(product)
    out += "\\] \\[ \\]\n"
    return out
}


//  Copyright © 2016 pauljohanneskraft. All rights reserved.
//

//import Foundation

postfix func ++<T: NumericType>(inout left: [[T]]) -> [[T]] {
    let before = left
    ++left
    return before
}

prefix func ++<T: NumericType>(inout left: [[T]]) -> [[T]] {
    for row in 0..<left.count {
        for column in 0..<left[row].count {
            left[row][column]++
        }
    }
    return left
}

func * <T: NumericType>(left: [[T]], right: [[T]]) throws -> [[T]] {
    var left = left
    try left *= right
    return left
}

func *= <T: NumericType>(inout left: [[T]], right: [[T]]) throws -> [[T]] {
    if left[0].count != right.count { throw MatrixError.NotMultipliable }
    var matrix : [[T]] = []
    
    for i in 0..<left.count {
