   (outputf terminate?
            "f = % .8e, |grad| = % .8e, |dx| = % .8e%n"
            :value
-           (comp m/magnitude force :gradient)
+           (comp m/magnitude :gradient)
            (fn [state]
              (if-not (:initial-step state)
-               (m/magnitude (force (:last-step state)))
+               (m/magnitude (:last-step state))
                Double/NaN))))
 
 (defn pause

         initial-step true]
    (let [function (cp/update-parameters function params)
          gradient (cp/gradient function)
          state (merge
                  {:params params
                   :value (delay (cp/output function))
                   :gradient gradient
                   :optimiser optimiser
                   :initial-step initial-step}
                  (if-not initial-step
                    (merge
                      (cp/get-state optimiser)
                      {:last-step (delay (- params last-params))})))]
      (if-not (terminate? state)
        (let [optimiser (cp/compute-parameters optimiser gradient params)
              new-params (cp/parameters optimiser)]

  [terminate? cutoff]
  (fn [state]
    (or (terminate? state)
        (<= (:value state)
            cutoff))))

(defn limit-gradient
  [terminate? cutoff]
  (fn [state]
    (or (terminate? state)
        (<= (m/magnitude (:gradient state))
            cutoff))))

;;;; I/O
