        (recur (inc i) (vector-reduce-map f acc g (.col x i)))
        acc)))
   ([^Matrix x g f init ^Matrix y]
-   (loop [i 0 acc init]
-     (if (< i (.ncols x))
-       (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i)))
-       acc)))
+   (if (check-matrix-dimensions x y)
+     (loop [i 0 acc init]
+       (if (< i (.ncols x))
+         (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i)))
+         acc))
+     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))     ))
   ([^Matrix x g f init ^Matrix y ^Matrix z]
-   (loop [i 0 acc init]
-     (if (< i (.ncols x))
-       (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i) (.col z i)))
-       acc)))
+   (if (check-matrix-dimensions x y z)
+     (loop [i 0 acc init]
+       (if (< i (.ncols x))
+         (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i) (.col z i)))
+         acc))
+     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))))
   ([^Matrix x g f init ^Matrix y ^Matrix z ^Matrix v]
-   (loop [i 0 acc init]
-     (if (< i (.ncols x))
-       (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i) (.col z i) (.col v i)))
-       acc)))
+   (if (check-matrix-dimensions x y z v)
+     (loop [i 0 acc init]
+       (if (< i (.ncols x))
+         (recur (inc i) (vector-reduce-map f acc g (.col x i) (.col y i) (.col z i) (.col v i)))
+         acc))
+     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))))
   ([x g f init y z v ws]
    (throw (UnsupportedOperationException. "Matrix fold support up to 4 matrices."))))
 

             :refer [PseudoFunctor Foldable fmap! fold foldmap]]
            [uncomplicate.neanderthal
             [protocols :refer :all]
             [core :refer [transfer! copy!]]]
            [uncomplicate.clojurecl.core :refer [Releaseable]])
  (:import [java.nio ByteBuffer DirectByteBuffer]
           [clojure.lang IFn IFn$D IFn$DD IFn$LD IFn$DDD IFn$LDD IFn$DDDD

           (vector-fmap* f (.row x i))))
       x))
  ([^Matrix x f ^Matrix y]
   (if (check-matrix-dimensions x y)
     (do (if (column-major? x)
           (dotimes [i (.ncols x)]
             (vector-fmap* f (.col x i) (.col y i)))
           (dotimes [i (.mrows x)]
             (vector-fmap* f (.row x i) (.row y i))))
         x)
     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))))
  ([^Matrix x f ^Matrix y ^Matrix z]
   (if (check-matrix-dimensions x y z)
     (do (if (column-major? x)
           (dotimes [i (.ncols x)]
             (vector-fmap* f (.col x i) (.col y i) (.col z i)))
           (dotimes [i (.mrows x)]
             (vector-fmap* f (.row x i) (.row y i) (.row z i))))
         x)
     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))))
  ([^Matrix x f ^Matrix y ^Matrix z ^Matrix v]
   (if (check-matrix-dimensions x y z v)
     (do (if (column-major? x)
           (dotimes [i (.ncols x)]
             (vector-fmap* f (.col x i) (.col y i) (.col z i) (.col v i)))
           (dotimes [i (.mrows x)]
             (vector-fmap* f (.row x i) (.row y i) (.row z i) (.col v i))))
         x)
     (throw (IllegalArgumentException. FITTING_DIMENSIONS_MATRIX_MSG))))
  ([x f y z w ws]
   (throw (UnsupportedOperationException. "Matrix fmap support up to 4 matrices."))))

