              :refer [PseudoFunctor Foldable fmap! fold foldmap]]
             [uncomplicate.neanderthal
              [protocols :refer :all]
-             [core :refer [transfer! copy!]]]
+             [core :refer [transfer! copy! mrows ncols]]]
             [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

            BLAS RealBufferAccessor BufferAccessor DataAccessor
            RealVector RealMatrix Vector Matrix RealChangeable Block]))

(defn ^:private hash* ^double [^double h ^double x]
  (double (clojure.lang.Util/hashCombine h (Double/hashCode x))))


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

