   (DoubleMatrix.
    (into-array (map double-array mat))))
 
-;; (defn logistic-prob
-;;   "returns the probability of a binary outcome given a parameter
-;;   vector `beta-seq` and a feature vector for a given observation"
-;;   [beta-seq feature-seq]
-;;   (logistic-fn (dot-product beta-seq feature-seq)))
+(defn to-double-rowmat
+  [coll]
+  (to-double-matrix [(vec coll)]))
+
+(defn copy-row
+  [^DoubleMatrix row]
+  (.copy (to-double-matrix [[]]) row))
+
+(def bm (to-double-rowmat (repeat 5 1)))
+(def ym (to-double-rowmat (interleave (repeat 10 0) (repeat 10 1))))
+(defn reshape [v c]
+  (if (= (count v) 1)
+    c
+    (recur (butlast v)
+           (partition (last v) c))))
+(def feat (reshape '(10 5) (range 100)))
+(def Xm (to-double-matrix  feat))
 
 (defn logistic-prob
   [^DoubleMatrix beta ^DoubleMatrix features]
   (logistic-fn
    (.dot beta features)))
 
+;; TODO: convert the functions that are useful but not actually used
+;; in estimation, like `log-likelihood` and `total-log-likelihood`.
 
 (defn log-likelihood
   "returns the log likelihood of a given pixel, conditional on its

    (.mmul (.muliRowVector (.transpose feature-mat) transformed-row)
           feature-mat)))

;; (defn info-matrix
;;   "returns the square information matrix for the logistic probability
;;   function; the dimension is given by the number of features"
;;   [beta-seq feature-mat]
;;   (let [mult-func (fn [x] (* x (- 1 x)))
;;         prob-seq  (->> (probability-calc beta-seq feature-mat)
;;                        (map mult-func))
;;         scale-feat (multiply-rows
;;                     prob-seq
;;                     (transpose feature-mat))]
;;     (.mmul (to-double-matrix scale-feat)
;;            (to-double-matrix feature-mat))))


;; (info-matrix b feat)
;; #<DoubleMatrix [1.665334536937734E-14, 1.9984014443252805E-14, 2.3314683517128275E-14, 2.664535259100374E-14, 2.997602166487921E-14; 1.9984014443252805E-14, 4.539580775988847E-5, 9.079161549979293E-5, 1.3618742323969737E-4, 1.8158323097960185E-4; 2.331468351712827E-14, 9.079161549979293E-5, 1.8158323097627118E-4, 2.723748464527494E-4, 3.6316646192922767E-4; 2.664535259100374E-14, 1.3618742323969737E-4, 2.723748464527494E-4, 4.085622696658014E-4, 5.447496928788534E-4; 2.9976021664879214E-14, 1.8158323097960185E-4, 3.6316646192922767E-4, 5.447496928788534E-4, 7.263329238284793E-4]>

;; (defn beta-update
;;   "returns a vector of updates for the parameter vector; the
;;   ridge-constant is a very small scalar, used to ensure that the
;;   inverted information matrix is non-singular."
;;   [beta-seq label-seq feature-mat rdg-cons]
;;   (let [num-features (count beta-seq)
;;         info-adj (.addi
;;                   (info-matrix beta-seq feature-mat)
;;                   (.muli (DoubleMatrix/eye (int num-features))
;;                          (float rdg-cons)))]
;;     (vec (.toArray
;;           (.mmul (Solve/solve
;;                   info-adj
;;                   (DoubleMatrix/eye (int num-features)))
;;                  (score-seq beta-seq label-seq feature-mat))))))


(defn beta-update
  "returns a vector of updates for the parameter vector; the

    (.mmul (.transpose feature-mat)
           (.transpose (.sub labels prob-seq)))))

;; (score-seq b lab feat)
;; #<DoubleMatrix [-450.0; -459.9999546021313; -469.9999092042626; -479.9998638063939; -489.9998184085252]>

