; slot accessor methods for the inverse-proto ; read in the jacobian and stick it in the jacobian slot (defmeth inverse-proto :read-jacobian (file) (let* ((j (read-data-columns file 3)) (rows (max (second j))) (cols (max (third j))) (jacobian (make-array (list rows cols))) ) (dotimes (i (length (first j))) (setf (aref jacobian (- (elt (second j) i) 1) (- (elt (third j) i) 1) ) (elt (first j) i)) ) (send self :jacobian jacobian) (send self :num-rows rows) (send self :num-cols cols) ) ) (defmeth inverse-proto :jacobian (&optional (jacobian nil set)) (if set (let ((tt "nil")) (setf (slot-value 'jacobian) jacobian) (setf tt "t") ) (slot-value 'jacobian) ) ) ; read in the right hand side and stick it in the rhs slot (defmeth inverse-proto :read-rhs (file) ; (send self :rhs (third (read-data-columns file 3))) (send self :rhs (first (read-data-columns file ))) ) (defmeth inverse-proto :rhs (&optional (rhs nil set)) (if set (let ((tt "nil")) (setf (slot-value 'rhs) rhs) (setf tt "t") ) (slot-value 'rhs) ) ) ; sig is the assumed known standard deviation of the data. ; it can be a vector or a scalar (defmeth inverse-proto :sig (&optional (sig nil set)) (if set (setf (slot-value 'sig) sig)) (slot-value 'sig) ) ; eps is the truncation level for the svd (defmeth inverse-proto :eps (&optional (eps nil set)) (if set (setf (slot-value 'eps) eps)) (slot-value 'eps) ) ; had to come up with a slightly unusual accessor method ; for the matrices so that you don't see the contents of ; the slot by default when you set it. (defmeth inverse-proto :svd (&optional (svd nil set)) (if set (let ((tt "nil")) (setf (slot-value 'svd) svd) (setf tt "t") ) (slot-value 'svd) ) ) ; unconstrained solution goes here (defmeth inverse-proto :solution (&optional (solution nil set)) (if set (setf (slot-value 'solution) solution)) (slot-value 'solution) ) ; constrained solution goes here (defmeth inverse-proto :constrained-solution (&optional (constrained-solution nil set)) (if set (setf (slot-value 'constrained-solution) constrained-solution)) (slot-value 'constrained-solution) ) ; dimensions of the model (defmeth inverse-proto :zmin (&optional (zmin nil set)) (if set (setf (slot-value 'zmin) zmin)) (slot-value 'zmin) ) (defmeth inverse-proto :zmax (&optional (zmax nil set)) (if set (setf (slot-value 'zmax) zmax)) (slot-value 'zmax) ) ; compute the normalized chi-squared of the model response ; NB, sig may or may not be a vector (defmeth inverse-proto :chisq () (let* ((data (send self :rhs)) (response (send self :response)) (x (- data response)) (sig (send self :sig)) ) (/ (sum (^ (/ x sig) 2)) (length x)) ) ) ; vector upper bound on velocity (defmeth inverse-proto :upper-bound (&optional (upper-bound nil set)) (if set (setf (slot-value 'upper-bound) upper-bound)) (slot-value 'upper-bound) ) ; vector lower bound on velocity (defmeth inverse-proto :lower-bound (&optional (lower-bound nil set)) (if set (setf (slot-value 'lower-bound) lower-bound)) (slot-value 'lower-bound) ) ; dimensions of the jacobian (defmeth inverse-proto :num-rows (&optional (num-rows nil set)) (if set (setf (slot-value 'num-rows) num-rows)) (slot-value 'num-rows) ) (defmeth inverse-proto :num-cols (&optional (num-cols nil set)) (if set (setf (slot-value 'num-cols) num-cols)) (slot-value 'num-cols) ) ; title (defmeth inverse-proto :title (&optional (title nil set)) (if set (setf (slot-value 'title) title)) (slot-value 'title) ) ; response (defmeth inverse-proto :response (&optional (response nil set)) (if set (setf (slot-value 'response) response)) (slot-value 'response) )