anchor.diff:  	  (push nums nums-m))))
       (list-matrix (reverse nums-m))))
     
  -(defun get-gamma (hstate times alpha beta)
  -  (declare (type fixnum times)
  +(defun get-gamma (hstate tms alpha beta)
  +  (declare (type fixnum tms)
   	   (type matrix alpha)
   	   (type matrix beta))
  -  (let ((denom 0.0d0)
  -	(gamma (make-array '(times (get-states hstate)) :element-type 'double-float)))
  +  (let ((denom 0.0)
  +	(gamma (make-array (list tms (get-states hstate)) :element-type 'float)))
       (do ((tm 0 (1+ tm)))
  -	((>= tm (- times 1)))
  +	((>= tm (- tms 1)))
         (progn
  -	(setf denom 0.0d0)
  +	(setf denom 0.0)
   	(do ((i 0 (1+ i)))
   	    ((>= i (get-states hstate)))
   	  (progn
  
positive.code: 			  max-value-indice k))))
  	    (setf (aref delta tm j) (* max-value (aref (get-measure-matrix hstate) j (aref o tm)))
  		  (aref psi tm j) max-value-indice))))
        (setf (aref q (- times 1)) 1)
        (do ((l 0 (1+ l)))
  	  ((>= l (get-states hstate)))
  	(if (> (aref delta (- times 1) l) prob)
  	    (setf prob (aref delta (- times 1) l)
  		  (aref q (- times 1)) l)))
        (do ((tm (- times 2) (1- tm)))
  	  ((< tm 0))
  	(setf (aref q tm) (aref psi (+ tm 1) (aref q (+ tm 1))))))
      (values q prob)))
negative.code:       (format out "M =~%")
        (pprint-matrix out (get-measure-matrix hstate)))))
  
  (defun forward (hstate tms o)
    "Forward algorithm."
    (declare (type array o)
  	   (type fixnum tms))
    (let ((alpha (make-array (list tms (get-states hstate)) :element-type 'float))
  	(sum 0.0)
  	(prob 0.0))
      (progn
        (do ((i 0 (1+ i)))
  	  ((>= i (get-states hstate)))
  	(setf (aref alpha 0 i) (* (aref (get-initial-distributions hstate) i)
  				  (aref (get-measure-matrix hstate) i (aref o 0)))))
        (do ((tm 0 (1+ tm)))
  	  ((>= tm (- tms 1)))
  	(do ((j 0 (1+ j)))
  	    ((>= j (get-states hstate)))
  	  (progn
  	    (setf sum 0.0)
  	    (do ((k 0 (1+ k)))
  		((>= k (get-states hstate)))
  	      (incf sum (* (aref alpha tm k)
  			   (aref (get-transition-matrix hstate) k j))))
  	    (setf (aref alpha (+ 1 tm) j) (* sum (aref (get-measure-matrix hstate) j (aref o (+ 1 tm))))))))
        (do ((l 0 (1+ l)))
  	  ((>= l (get-states hstate)))
  	(incf prob (aref alpha (- tms 1) l))))
      (values alpha prob)))
  
  (defun backward (hstate tms o)
    "Backward algorithm."
    (declare (type array o)
  	   (type fixnum tms))
    (let ((beta (make-array (list tms (get-states hstate)) :element-type 'float))
  	(sum 0.0)
  	(prob 0.0))
      (progn
        (do ((i 0 (1+ i)))
  	  ((>= i (get-states hstate)))
  	(setf (aref beta (- tms 1) i) 1.0))
        (do ((tm (- tms 2) (1- tm)))
  	  ((< tm 0))
  	(do ((k 0 (1+ k)))
  	    ((>= k (get-states hstate)))
  	  (progn
  	    (setf sum 0.0)
  	    (do ((j 0 (1+ j)))
  		((>= j (get-states hstate)))
  	      (incf sum (* (aref (get-transition-matrix hstate) k j)
  			   (aref (get-measure-matrix hstate) j (aref o (+ 1 tm)))
  			   (aref beta (+ 1 tm) j))))
  	    (setf (aref beta tm k) sum))))
        (do ((l 0 (1+ l)))
  	  ((>= l (get-states hstate)))
  	(incf prob (aref beta 0 l))))
      (values beta prob)))
  
  (defun viterbi (hstate tms o)
    "Viterbi algorithm."
    (declare (type array o)
  	   (type fixnum tms))
    (let ((delta (make-array (list tms (get-states hstate)) :element-type 'float))
  	(psi (make-array (list tms (get-states hstate)) :element-type 'integer))
  	(q (make-array tms :element-type 'integer))
  	(max-value 0.0)
  	(max-value-indice 0)
  	(value 0.0)
  	(prob 0.0))
      (progn
        (do ((i 0 (1+ i)))
  	  ((>= i (get-states hstate)))
  	(setf (aref delta 0 i) (* (aref (get-initial-distributions hstate) i)
  				  (aref (get-measure-matrix hstate) i (aref o 0)))
  	      (aref psi 0 i) 0))
        (do ((tm 1 (1+ tm)))
  	  ((>= tm tms))
          (do ((j 0 (1+ j)))
  	    ((>= j (get-states hstate)))
  	  (progn
  	    (setf max-value 0.0
  		  max-value-indice 1)
  	    (do ((k 0 (1+ k)))
  		((>= k (get-states hstate)))
  