Commit 74aed234 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Use grid:aref instead of grid:gref

parent fcc1723d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
;; Basis splines.
;; Liam Healy 2008-02-18 14:43:20EST basis-splines.lisp
;; Time-stamp: <2011-01-13 10:24:59EST basis-splines.lisp>
;; Time-stamp: <2011-05-26 12:37:29EDT basis-splines.lisp>
;;
;; Copyright 2008, 2009, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
@@ -125,18 +125,18 @@
      (let* ((xi (coerce (* i (/ 15 (1- ndata))) 'double-float))
	     (yi (+ (* (cos xi) (exp (* -0.1d0 xi)))
		    (sample rng :gaussian :sigma sigma))))
	(setf (grid:gref x i) xi
	      (grid:gref y i) yi
	      (grid:gref w i) (/ (expt sigma 2)))))
	(setf (grid:aref x i) xi
	      (grid:aref y i) yi
	      (grid:aref w i) (/ (expt sigma 2)))))
    ;; Uniform breakpoints [0, 15]
    (uniform-knots 0.0d0 15.0d0 bw)
    ;; Fit matrix
    (dotimes (i ndata)
      ;; Compute B_j
      (evaluate bw (grid:gref x i) :b B)
      (evaluate bw (grid:aref x i) :b B)
      ;; Fill in row i of X
      (dotimes (j ncoeffs)
	(setf (grid:gref Xmatrix i j) (grid:gref B j))))
	(setf (grid:aref Xmatrix i j) (grid:aref B j))))
    ;; Do the fit
    (linear-mfit Xmatrix y c w nil cov mw)
    ;; Return the smoothed curve
+2 −2
Original line number Diff line number Diff line
;; Functions for both vectors and matrices.
;; Liam Healy 2008-04-26 20:48:44EDT both.lisp
;; Time-stamp: <2011-01-12 00:38:30EST both.lisp>
;; Time-stamp: <2011-05-26 12:37:36EDT both.lisp>
;;
;; Copyright 2008, 2009, 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
@@ -81,7 +81,7 @@
;;;;****************************************************************************
;;;; Array elements; used in callbacks scalarsp=T only
;;;;****************************************************************************
;;; Normal foreign array access is with grid:gref, but in order to
;;; Normal foreign array access is with grid:aref, but in order to
;;; avoid the overhead of instantiating a foreign-array object to
;;; access components, we use these macros which expand to gsl_*_get
;;; and gsl_*_set.
+2 −2
Original line number Diff line number Diff line
;; Permutations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2011-01-10 18:16:26EST permutation.lisp>
;; Time-stamp: <2011-05-26 12:37:36EDT permutation.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
@@ -339,7 +339,7 @@

(save-test permutation
 (let ((perm-1 (make-permutation 4 t)))
   (grid:gref perm-1 2))
   (grid:aref perm-1 2))
 (let ((perm-1 (make-permutation 4 t)))	;grid:contents
   (grid:contents perm-1))
 (let ((perm-1 (make-permutation 4 t)))	;permutation-reverse
+10 −10
Original line number Diff line number Diff line
;; Example FFT: transform a pulse (using the "clean" fft interface)
;; Sumant Oemrawsingh, Sat Oct 31 2009 - 00:24
;; Time-stamp: <2011-01-11 23:32:17EST example.lisp>
;; Time-stamp: <2011-05-26 12:37:35EDT example.lisp>
;;
;; Copyright 2009, 2010, 2011 Sumant Oemrawsingh, Liam M. Healy
;; Distributed under the terms of the GNU General Public License
@@ -42,10 +42,10 @@
  (assert (and (integerp dimension) (> dimension 20)))
  (let ((pulse (grid:make-foreign-array element-type :dimensions dimension))
        (init-value (coerce 1 element-type)))
    (setf (grid:gref pulse 0) init-value)
    (setf (grid:aref pulse 0) init-value)
    (loop for i from 1 to 10
          do (setf (grid:gref pulse i) init-value
                   (grid:gref pulse (- dimension i)) init-value))
          do (setf (grid:aref pulse i) init-value
                   (grid:aref pulse (- dimension i)) init-value))
    (forward-fourier-transform pulse)))

(save-test
@@ -82,7 +82,7 @@
    (when init-offset
      (loop for i from 0 below size
            do
            (setf (grid:gref vec i)
            (setf (grid:aref vec i)
                  (if (subtypep element-type 'complex)
                    (coerce (complex (+ (* 2 i) init-offset)
                                     (+ (* 2 i) init-offset 1))
@@ -97,7 +97,7 @@
                                   (* stride dimension) :init-offset init-offset)))
    (loop for i from 0 below (* stride dimension) by stride
       do
       (setf (grid:gref vec i)
       (setf (grid:aref vec i)
	     (if (subtypep element-type 'complex)
		 (coerce (complex (urand) (urand)) element-type)
		 (complex (coerce (urand) element-type)))))
@@ -112,8 +112,8 @@
            :init-offset init-offset)))
    (loop for i below (size complex-vector) by stride
          do
          (setf (grid:gref real-vector i)
                (realpart (grid:gref complex-vector i))))
          (setf (grid:aref real-vector i)
                (realpart (grid:aref complex-vector i))))
    real-vector))

(defun copy-with-stride (vector &key (stride 1) init-offset)
@@ -125,7 +125,7 @@
	  :init-offset init-offset)))
    (loop for i below (size vector) by stride
          do
       (setf (grid:gref vec i) (grid:gref vector i)))
       (setf (grid:aref vec i) (grid:aref vector i)))
    vec))

(defun size-vector-scalar (vector &key (stride 1))
@@ -144,7 +144,7 @@
    (loop with length = (size-vector-scalar vector :stride stride)
          for i from 0 below (size vector) by stride
          do
          (setf (grid:gref vector i) (coerce (/ (grid:gref vector i) length) element-type)))
          (setf (grid:aref vector i) (coerce (/ (grid:aref vector i) length) element-type)))
  vector))

(defun test-real-fft-noise (vector &key (stride 1) non-radix-2)
+8 −8
Original line number Diff line number Diff line
@@ -76,12 +76,12 @@
         (zero-pos (if (evenp n) (- split 1) split)))
    ;; Positive frequencies
    (loop for i from zero-pos to (- n 1)
          do (setf (grid:gref shifted (* i stride))
                   (grid:gref vector (* (- i zero-pos) stride))))
          do (setf (grid:aref shifted (* i stride))
                   (grid:aref vector (* (- i zero-pos) stride))))
    ;; Negative frequencies
    (loop for i from (+ split 1) to (- n 1)
          do (setf (grid:gref shifted (* (- i split 1) stride))
                   (grid:gref vector (* i stride))))
          do (setf (grid:aref shifted (* (- i split 1) stride))
                   (grid:aref vector (* i stride))))
    shifted))

(export 'fft-inverse-shift)
@@ -96,10 +96,10 @@
         (zero-pos (if (evenp n) (- split 1) split)))
    ;; Positive frequencies
    (loop for i from zero-pos to (- n 1)
          do (setf (grid:gref inv-shifted (* (- i zero-pos) stride))
                   (grid:gref vector (* i stride))))
          do (setf (grid:aref inv-shifted (* (- i zero-pos) stride))
                   (grid:aref vector (* i stride))))
    ;; Negative frequencies
    (loop for i from (+ split 1) to (- n 1)
          do (setf (grid:gref inv-shifted (* i stride))
                   (grid:gref vector (* (- i split 1) stride))))
          do (setf (grid:aref inv-shifted (* i stride))
                   (grid:aref vector (* (- i split 1) stride))))
    inv-shifted))
Loading