/[cl-gsl]/cl-gsl/vector.lisp
ViewVC logotype

Contents of /cl-gsl/vector.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Sun Apr 10 02:31:06 2005 UTC (9 years ago) by edenny
Branch: MAIN
Changes since 1.6: +14 -9 lines
Fix scale and add-constant functions. Only subvector and
subvector-with-stride functions now have problems.
1 edenny 1.1 ;;;; -*- Mode: Lisp; Synatx: ANSI-Common-Lisp; Base: 10 -*-
2     ;;;;
3     ;;;; Copyright (C) 2005 Edgar Denny <edgardenny@comcast.net>
4     ;;;; This file is part of CL-GSL.
5     ;;;;
6     ;;;; This program is free software; you can redistribute it and/or modify
7     ;;;; it under the terms of the GNU General Public License as published by
8     ;;;; the Free Software Foundation; either version 2 of the License, or
9     ;;;; (at your option) any later version.
10     ;;;;
11     ;;;; This program is distributed in the hope that it will be useful,
12     ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13     ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     ;;;; GNU General Public License for more details.
15     ;;;;
16     ;;;; You should have received a copy of the GNU General Public License
17     ;;;; along with this program; if not, write to the Free Software
18     ;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19    
20     (in-package #:cl-gsl-vector)
21    
22     (defmacro def-vector-type-funcs% (typ)
23     (let ((type-ptr)
24     (type-val)
25     (type-val-ptr)
26     (type-string))
27     (cond
28     ((eq typ 'double-float)
29     (setq type-ptr 'gsl-vector-ptr)
30     (setq type-val :double)
31     (setq type-val-ptr '(* :double))
32     (setq type-string "vector"))
33     ((eq typ 'single-float)
34     (setq type-ptr 'gsl-vector-float-ptr)
35     (setq type-val :float)
36     (setq type-val-ptr '(* :float))
37     (setq type-string "vector_float"))
38     ((eq typ 'integer)
39     (setq type-ptr 'gsl-vector-int-ptr)
40     (setq type-val :int)
41     (setq type-val-ptr '(* :int))
42     (setq type-string "vector_int"))
43 edenny 1.3 ((equal typ '(complex (double-float)))
44 edenny 1.1 (setq type-ptr 'gsl-vector-complex-ptr)
45     (setq type-val 'gsl-complex)
46     (setq type-val-ptr '(* gsl-complex))
47     (setq type-string "vector_complex"))
48 edenny 1.3 ((equal typ '(complex (single-float)))
49 edenny 1.1 (setq type-ptr 'gsl-vector-complex-float-ptr)
50     (setq type-val 'gsl-complex-float)
51     (setq type-val-ptr '(* gsl-complex-float))
52     (setq type-string "vector_complex_float"))
53     (t
54     (error "no matching type.")))
55    
56     `(progn
57     (defun-foreign ,(concatenate 'string "gsl_" type-string "_alloc")
58     ((size size-t))
59     ,type-ptr)
60    
61     (defun-foreign ,(concatenate 'string "gsl_" type-string "_free")
62     ((v ,type-ptr))
63     :void)
64    
65     (defun-foreign ,(concatenate 'string "gsl_" type-string "_get")
66     ((v ,type-ptr)
67     (i size-t))
68     ,type-val)
69    
70     (defun-foreign ,(concatenate 'string "gsl_" type-string "_set")
71     ((v ,type-ptr)
72     (i size-t)
73     (x ,type-val))
74     :void)
75    
76     (defun-foreign ,(concatenate 'string "gsl_" type-string "_set_all")
77     ((v ,type-ptr)
78     (x ,type-val))
79     :void)
80    
81     (defun-foreign ,(concatenate 'string "gsl_" type-string "_set_zero")
82     ((v ,type-ptr))
83     :void)
84    
85     (defun-foreign ,(concatenate 'string "gsl_" type-string "_set_basis")
86     ((v ,type-ptr)
87     (i size-t))
88     :void)
89    
90     (defun-foreign ,(concatenate 'string "gsl_" type-string "_memcpy")
91     ((v1 ,type-ptr)
92     (v2 ,type-ptr))
93     :int)
94    
95     (defun-foreign ,(concatenate 'string "gsl_" type-string "_swap")
96     ((v1 ,type-ptr)
97     (v2 ,type-ptr))
98     :int)
99    
100     (defun-foreign ,(concatenate 'string "gsl_" type-string "_swap_elements")
101     ((v1 ,type-ptr)
102     (i size-t)
103     (j size-t))
104     :int)
105    
106     (defun-foreign ,(concatenate 'string "gsl_" type-string "_reverse")
107     ((v1 ,type-ptr))
108     :int)
109    
110 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
111     (equal typ '(complex (single-float))))
112 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_add")
113     ((va ,type-ptr)
114     (vb ,type-ptr))
115     :int))
116    
117 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
118     (equal typ '(complex (single-float))))
119 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_sub")
120     ((va ,type-ptr)
121     (vb ,type-ptr))
122     :int))
123    
124 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
125     (equal typ '(complex (single-float))))
126 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_mul")
127     ((va ,type-ptr)
128     (vb ,type-ptr))
129     :int))
130    
131 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
132     (equal typ '(complex (single-float))))
133 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_div")
134     ((va ,type-ptr)
135     (vb ,type-ptr))
136     :int))
137    
138 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
139     (equal typ '(complex (single-float))))
140 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_scale")
141     ((vec ,type-ptr)
142 edenny 1.7 ;; seems odd that this is :double for all types
143     (x :double))
144 edenny 1.2 :int))
145    
146 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
147     (equal typ '(complex (single-float))))
148 edenny 1.2 `(defun-foreign ,(concatenate 'string
149     "gsl_" type-string "_add_constant")
150     ((vec ,type-ptr)
151 edenny 1.7 ;; and again, :double for all types
152     (x :double))
153 edenny 1.2 :int))
154    
155 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
156     (equal typ '(complex (single-float))))
157 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_max")
158     ((vec ,type-ptr))
159     ,type-val))
160    
161 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
162     (equal typ '(complex (single-float))))
163 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_min")
164     ((vec ,type-ptr))
165     ,type-val))
166    
167 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
168     (equal typ '(complex (single-float))))
169 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_minmax")
170     ((vec ,type-ptr)
171     (min ,type-val-ptr)
172     (max ,type-val-ptr))
173     :void))
174    
175 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
176     (equal typ '(complex (single-float))))
177 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_max_index")
178     ((vec ,type-ptr))
179     size-t))
180    
181 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
182     (equal typ '(complex (single-float))))
183 edenny 1.2 `(defun-foreign ,(concatenate 'string "gsl_" type-string "_min_index")
184     ((vec ,type-ptr))
185     size-t))
186    
187 edenny 1.3 ,(unless (or (equal typ '(complex (double-float)))
188     (equal typ '(complex (single-float))))
189 edenny 1.2 `(defun-foreign ,(concatenate 'string
190     "gsl_" type-string "_minmax_index")
191     ((vec ,type-ptr)
192     (min size-t-ptr)
193     (max size-t-ptr))
194     :void))
195 edenny 1.1
196     (defun-foreign ,(concatenate 'string "gsl_" type-string "_isnull")
197     ((vec ,type-ptr))
198     :int)
199    
200     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string "_fwrite")
201     ((fn :cstring)
202     (v ,type-ptr))
203     :int)
204    
205     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string "_fread")
206     ((fn :cstring)
207     (v ,type-ptr))
208     :int)
209    
210     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string "_fprintf")
211     ((fn :cstring)
212     (v ,type-ptr))
213     :int)
214    
215     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string "_fscanf")
216     ((fn :cstring)
217     (v ,type-ptr))
218     :int)
219    
220     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string
221     "_subvector")
222 edenny 1.7 ((v ,type-ptr)
223 edenny 1.1 (offset size-t)
224     (n size-t))
225     ,type-ptr)
226    
227     (defun-foreign ,(concatenate 'string "wrap_gsl_" type-string
228     "_subvector_with_stride")
229 edenny 1.7 ((v ,type-ptr)
230 edenny 1.1 (offset size-t)
231     (stride size-t)
232     (n size-t))
233     ,type-ptr))))
234    
235    
236 edenny 1.4 (defun-foreign "gsl_vector_complex_float_ptr"
237     ((v gsl-vector-complex-float-ptr)
238     (i size-t))
239     (* gsl-complex-float))
240    
241     (defun-foreign "gsl_vector_complex_ptr"
242     ((v gsl-vector-complex-ptr)
243     (i size-t))
244     (* gsl-complex))
245    
246     (defun-foreign "wrap_gsl_vector_complex_float_set"
247     ((v gsl-vector-complex-float-ptr)
248     (i size-t)
249     (z (* gsl-complex-float)))
250     :void)
251    
252     (defun-foreign "wrap_gsl_vector_complex_set"
253     ((v gsl-vector-complex-ptr)
254     (i size-t)
255     (z (* gsl-complex)))
256     :void)
257    
258     (defun-foreign "wrap_gsl_vector_complex_float_set_all"
259     ((v gsl-vector-complex-float-ptr)
260     (z (* gsl-complex-float)))
261     :void)
262    
263     (defun-foreign "wrap_gsl_vector_complex_set_all"
264     ((v gsl-vector-complex-ptr)
265     (z (* gsl-complex)))
266     :void)
267    
268 edenny 1.1 (def-vector-type-funcs% double-float)
269     (def-vector-type-funcs% single-float)
270     (def-vector-type-funcs% integer)
271 edenny 1.3 (def-vector-type-funcs% (complex (double-float)))
272     (def-vector-type-funcs% (complex (single-float)))
273 edenny 1.1
274     (defstruct gsl-vec
275     ;; TODO: print-function ?
276     ptr
277     size
278     element-type)
279    
280     (defun alloc (v)
281 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
282     (cond
283     ((eq (gsl-vec-element-type v) 'integer)
284 edenny 1.1 (setf (gsl-vec-ptr v) (gsl-vector-int-alloc (gsl-vec-size v))))
285 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
286 edenny 1.1 (setf (gsl-vec-ptr v) (gsl-vector-float-alloc (gsl-vec-size v))))
287 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
288 edenny 1.1 (setf (gsl-vec-ptr v) (gsl-vector-alloc (gsl-vec-size v))))
289 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
290 edenny 1.1 (setf (gsl-vec-ptr v) (gsl-vector-complex-float-alloc (gsl-vec-size v))))
291 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
292     (setf (gsl-vec-ptr v) (gsl-vector-complex-alloc (gsl-vec-size v))))
293     (t
294     (error "No matching type"))))
295 edenny 1.1
296    
297     (defun free (v)
298 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
299     (cond
300     ((eq (gsl-vec-element-type v) 'integer)
301 edenny 1.1 (gsl-vector-int-free (gsl-vec-ptr v)))
302 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
303 edenny 1.1 (gsl-vector-float-free (gsl-vec-ptr v)))
304 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
305 edenny 1.1 (gsl-vector-free (gsl-vec-ptr v)))
306 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
307 edenny 1.1 (gsl-vector-complex-float-free (gsl-vec-ptr v)))
308 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
309     (gsl-vector-complex-free (gsl-vec-ptr v)))
310     (t
311     (error "No matching type")))
312 edenny 1.1 (setf (gsl-vec-ptr v) nil)
313     (setf (gsl-vec-size v) nil)
314     (setf (gsl-vec-element-type v) nil))
315    
316    
317     (defun get-element (v i)
318 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
319 edenny 1.1 (assert (typep i 'integer))
320     (assert (< i (gsl-vec-size v)))
321 edenny 1.3 (cond
322     ((eq (gsl-vec-element-type v) 'integer)
323 edenny 1.1 (gsl-vector-int-get (gsl-vec-ptr v) i))
324 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
325 edenny 1.1 (gsl-vector-float-get (gsl-vec-ptr v) i))
326 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
327 edenny 1.1 (gsl-vector-get (gsl-vec-ptr v) i))
328 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
329 edenny 1.4 (gsl-complex-float->complex
330     (gsl-vector-complex-float-ptr (gsl-vec-ptr v) i)))
331 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
332 edenny 1.4 (gsl-complex->complex (gsl-vector-complex-ptr (gsl-vec-ptr v) i)))
333 edenny 1.3 (t
334     (error "No matching type"))))
335 edenny 1.1
336    
337 edenny 1.6 ;; TODO: make a (setf (get-element v i) x) version.
338 edenny 1.1 (defun set-element (v i x)
339 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
340     (assert (typep x (gsl-vec-element-type v)))
341 edenny 1.1 (assert (typep i 'integer))
342     (assert (< i (gsl-vec-size v)))
343 edenny 1.3 (cond
344     ((eq (gsl-vec-element-type v) 'integer)
345 edenny 1.1 (gsl-vector-int-set (gsl-vec-ptr v) i x))
346 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
347 edenny 1.1 (gsl-vector-float-set (gsl-vec-ptr v) i x))
348 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
349 edenny 1.1 (gsl-vector-set (gsl-vec-ptr v) i x))
350 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
351 edenny 1.5 (with-complex-single-float->gsl-complex-float-ptr (c-ptr x)
352     (wrap-gsl-vector-complex-float-set (gsl-vec-ptr v) i c-ptr)))
353 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
354 edenny 1.5 (with-complex-double-float->gsl-complex-ptr (c-ptr x)
355     (wrap-gsl-vector-complex-set (gsl-vec-ptr v) i c-ptr)))
356 edenny 1.3 (t
357 edenny 1.6 (error "No matching type")))
358     v)
359 edenny 1.1
360    
361     (defun set-all (v x)
362 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
363     (assert (typep x (gsl-vec-element-type v)))
364     (cond
365     ((eq (gsl-vec-element-type v) 'integer)
366 edenny 1.1 (gsl-vector-int-set-all (gsl-vec-ptr v) x))
367 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
368 edenny 1.1 (gsl-vector-float-set-all (gsl-vec-ptr v) x))
369 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
370 edenny 1.1 (gsl-vector-set-all (gsl-vec-ptr v) x))
371 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
372 edenny 1.5 (with-complex-single-float->gsl-complex-float-ptr (c-ptr x)
373     (wrap-gsl-vector-complex-float-set-all (gsl-vec-ptr v) c-ptr)))
374 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
375 edenny 1.5 (with-complex-double-float->gsl-complex-ptr (c-ptr x)
376     (wrap-gsl-vector-complex-set-all (gsl-vec-ptr v) c-ptr)))
377 edenny 1.3 (t
378 edenny 1.6 (error "No matching type")))
379     v)
380 edenny 1.3
381 edenny 1.1
382     (defun set-zero (v)
383 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
384     (cond
385     ((eq (gsl-vec-element-type v) 'integer)
386 edenny 1.1 (gsl-vector-int-set-zero (gsl-vec-ptr v)))
387 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
388 edenny 1.1 (gsl-vector-float-set-zero (gsl-vec-ptr v)))
389 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
390 edenny 1.1 (gsl-vector-set-zero (gsl-vec-ptr v)))
391 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
392 edenny 1.2 (gsl-vector-complex-float-set-zero (gsl-vec-ptr v)))
393 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
394     (gsl-vector-complex-set-zero (gsl-vec-ptr v)))
395     (t
396 edenny 1.6 (error "No matching type")))
397     v)
398 edenny 1.1
399    
400     (defun set-basis (v i)
401 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
402 edenny 1.1 (assert (typep i 'integer))
403     (assert (< i (gsl-vec-size v)))
404 edenny 1.3 (cond
405     ((eq (gsl-vec-element-type v) 'integer)
406 edenny 1.1 (gsl-vector-int-set-basis (gsl-vec-ptr v) i))
407 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
408 edenny 1.1 (gsl-vector-float-set-basis (gsl-vec-ptr v) i))
409 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
410 edenny 1.1 (gsl-vector-set-basis (gsl-vec-ptr v) i))
411 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
412 edenny 1.4 (gsl-vector-complex-float-set-basis (gsl-vec-ptr v) i))
413 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
414 edenny 1.4 (gsl-vector-complex-set-basis (gsl-vec-ptr v) i))
415 edenny 1.3 (t
416 edenny 1.6 (error "No matching type")))
417     v)
418    
419    
420     (defun read-from-binary-file (v file-name size)
421     (assert (eq 'gsl-vec (type-of v)))
422     (assert (<= size (gsl-vec-size v)))
423     (let ((status))
424     (uffi:with-cstring (c-file-name file-name)
425     (setq status
426     (cond
427     ((eq (gsl-vec-element-type v) 'integer)
428     (wrap-gsl-vector-int-fread c-file-name (gsl-vec-ptr v)))
429     ((eq (gsl-vec-element-type v) 'single-float)
430     (wrap-gsl-vector-float-fread c-file-name (gsl-vec-ptr v)))
431     ((eq (gsl-vec-element-type v) 'double-float)
432     (wrap-gsl-vector-fread c-file-name (gsl-vec-ptr v)))
433     ((equal (gsl-vec-element-type v) '(complex (single-float)))
434     (wrap-gsl-vector-complex-float-fread c-file-name (gsl-vec-ptr v)))
435     ((equal (gsl-vec-element-type v) '(complex (double-float)))
436     (wrap-gsl-vector-complex-fread c-file-name (gsl-vec-ptr v)))
437     (t
438     (error "No matching type")))))
439     (values v status)))
440    
441    
442     (defun read-from-file (v file-name size)
443     (assert (eq 'gsl-vec (type-of v)))
444     (assert (<= size (gsl-vec-size v)))
445     (let ((status))
446     (uffi:with-cstring (c-file-name file-name)
447     (setq status
448     (cond
449     ((eq (gsl-vec-element-type v) 'integer)
450     (wrap-gsl-vector-int-fscanf c-file-name (gsl-vec-ptr v)))
451     ((eq (gsl-vec-element-type v) 'single-float)
452     (wrap-gsl-vector-float-fscanf c-file-name (gsl-vec-ptr v)))
453     ((eq (gsl-vec-element-type v) 'double-float)
454     (wrap-gsl-vector-fscanf c-file-name (gsl-vec-ptr v)))
455     ((equal (gsl-vec-element-type v) '(complex (single-float)))
456     (wrap-gsl-vector-complex-float-fscanf c-file-name
457     (gsl-vec-ptr v)))
458     ((equal (gsl-vec-element-type v) '(complex (double-float)))
459     (wrap-gsl-vector-complex-fscanf c-file-name (gsl-vec-ptr v)))
460     (t
461     (error "No matching type")))))
462     (values v status)))
463 edenny 1.1
464    
465     (defun make-vector (size &key (element-type 'double-float) initial-element
466 edenny 1.6 initial-contents from-file from-binary-file)
467 edenny 1.1 (assert (typep size 'integer))
468     (assert (find element-type '(integer single-float double-float
469 edenny 1.3 (complex (single-float))
470     (complex (double-float))) :test #'equal))
471 edenny 1.1 (let ((v (make-gsl-vec :size size :element-type element-type)))
472 edenny 1.2 (setf (gsl-vec-ptr v) (alloc v))
473 edenny 1.1 (cond
474 edenny 1.6 ((and initial-element initial-contents from-file from-binary-file)
475     (error "can only define one of the keys: initial-element, initial-contents, from-file, from-binary-file."))
476 edenny 1.1 (initial-element
477     (gsl-vector:set-all v initial-element))
478     (initial-contents
479     (cond
480     ((listp initial-contents)
481     (do ((x initial-contents (cdr x))
482     (i 0 (1+ i)))
483     ((= i size))
484     (gsl-vector:set-element v i (car x))))
485     ((vectorp initial-contents)
486     (do ((i 0 (1+ i)))
487     ((= i size))
488     (gsl-vector:set-element v i (aref initial-contents i))))
489     (t
490 edenny 1.6 (error "initial-contents must be either a list or a vector."))))
491     (from-file
492     (read-from-file v from-file size))
493     (from-binary-file
494     (read-from-binary-file v from-binary-file size)))
495 edenny 1.1 v))
496    
497    
498 edenny 1.6 (defmacro with-vector
499     ((vec size &key element-type initial-element initial-contents from-file
500     from-binary-file) &body body)
501 edenny 1.5 `(let ((,vec (make-vector ,size
502     :element-type (or ,element-type 'double-float)
503     :initial-element ,initial-element
504 edenny 1.6 :initial-contents ,initial-contents
505     :from-file ,from-file
506     :from-binary-file ,from-binary-file)))
507 edenny 1.5 (unwind-protect
508 edenny 1.6 (progn ,@body)
509 edenny 1.5 (free ,vec))))
510    
511    
512 edenny 1.1 (defun write-to-binary-file (file-name v)
513 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
514 edenny 1.1 (let ((status))
515 edenny 1.3 ;; TODO: check if uffi:with-string returns a result, docs unclear.
516 edenny 1.2 (uffi:with-cstring (c-file-name file-name)
517 edenny 1.1 (setq status
518 edenny 1.3 (cond
519     ((eq (gsl-vec-element-type v) 'integer)
520 edenny 1.1 (wrap-gsl-vector-int-fwrite c-file-name (gsl-vec-ptr v)))
521 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
522 edenny 1.2 (wrap-gsl-vector-float-fwrite c-file-name (gsl-vec-ptr v)))
523 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
524 edenny 1.2 (wrap-gsl-vector-fwrite c-file-name (gsl-vec-ptr v)))
525 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
526 edenny 1.2 (wrap-gsl-vector-complex-float-fwrite c-file-name
527     (gsl-vec-ptr v)))
528 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
529     (wrap-gsl-vector-complex-fwrite c-file-name (gsl-vec-ptr v)))
530     (t
531     (error "No matching type")))))
532 edenny 1.1 status))
533    
534    
535     (defun write-to-file (file-name v)
536 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
537 edenny 1.1 (let ((status))
538 edenny 1.2 (uffi:with-cstring (c-file-name file-name)
539 edenny 1.1 (setq status
540 edenny 1.3 (cond
541     ((eq (gsl-vec-element-type v) 'integer)
542 edenny 1.1 (wrap-gsl-vector-int-fprintf c-file-name (gsl-vec-ptr v)))
543 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
544 edenny 1.2 (wrap-gsl-vector-float-fprintf c-file-name (gsl-vec-ptr v)))
545 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
546 edenny 1.2 (wrap-gsl-vector-fprintf c-file-name (gsl-vec-ptr v)))
547 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
548 edenny 1.2 (wrap-gsl-vector-complex-float-fprintf c-file-name
549     (gsl-vec-ptr v)))
550 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
551     (wrap-gsl-vector-complex-fprintf c-file-name (gsl-vec-ptr v)))
552     (t
553     (error "No matching type")))))
554 edenny 1.1 status))
555    
556    
557     (defun subvector (v offset n)
558 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
559 edenny 1.1 (assert (typep offset 'integer))
560     (assert (typep n 'integer))
561     (assert (< (+ offset n) (gsl-vec-size v)))
562     ;; use make-gsl-vec here rather than make-vector - we do not want to
563     ;; allocate any foreign memory for the subvector.
564     (let ((v-sub (make-gsl-vec :size n :element-type (gsl-vec-element-type v))))
565     (setf (gsl-vec-ptr v-sub)
566 edenny 1.3 (cond
567     ((eq (gsl-vec-element-type v) 'integer)
568 edenny 1.1 (wrap-gsl-vector-int-subvector (gsl-vec-ptr v) offset n))
569 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
570 edenny 1.1 (wrap-gsl-vector-float-subvector (gsl-vec-ptr v) offset n))
571 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
572 edenny 1.1 (wrap-gsl-vector-subvector (gsl-vec-ptr v) offset n))
573 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
574 edenny 1.1 (wrap-gsl-vector-complex-float-subvector (gsl-vec-ptr v) offset n))
575 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
576     (wrap-gsl-vector-complex-subvector (gsl-vec-ptr v) offset n))
577     (t
578     (error "No matching type"))))
579 edenny 1.1 v-sub))
580    
581    
582     (defun subvector-with-stride (v offset stride n)
583 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
584 edenny 1.1 (assert (typep offset 'integer))
585     (assert (typep stride 'integer))
586     (assert (typep n 'integer))
587     (assert (< (* (+ offset n) stride) (gsl-vec-size v)))
588     ;; use make-gsl-vec here rather than make-vector - we do not want to
589     ;; allocate any foreign memory for the subvector.
590     (let ((v-sub (make-gsl-vec :size n :element-type (gsl-vec-element-type v))))
591     (setf (gsl-vec-ptr v-sub)
592 edenny 1.3 (cond
593     ((eq (gsl-vec-element-type v) 'integer)
594 edenny 1.1 (wrap-gsl-vector-int-subvector-with-stride (gsl-vec-ptr v)
595     offset stride n))
596 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
597 edenny 1.1 (wrap-gsl-vector-float-subvector-with-stride (gsl-vec-ptr v)
598     offset stride n))
599 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
600 edenny 1.1 (wrap-gsl-vector-subvector-with-stride (gsl-vec-ptr v)
601     offset stride n))
602 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
603 edenny 1.1 (wrap-gsl-vector-complex-float-subvector-with-stride
604     (gsl-vec-ptr v) offset stride n))
605 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
606 edenny 1.1 (wrap-gsl-vector-complex-subvector-with-stride (gsl-vec-ptr v)
607 edenny 1.3 offset stride n))
608     (t
609     (error "No matching type"))))
610 edenny 1.1 v-sub))
611    
612    
613     (defun copy (v-src)
614 edenny 1.3 (assert (eq 'gsl-vec (type-of v-src)))
615 edenny 1.2 (let* ((v-dest (make-vector (gsl-vec-size v-src)
616     :element-type (gsl-vec-element-type v-src)))
617 edenny 1.3 (status (cond
618     ((eq (gsl-vec-element-type v-src) 'integer)
619 edenny 1.1 (gsl-vector-int-memcpy (gsl-vec-ptr v-dest)
620     (gsl-vec-ptr v-src)))
621 edenny 1.3 ((eq (gsl-vec-element-type v-src) 'single-float)
622 edenny 1.1 (gsl-vector-float-memcpy (gsl-vec-ptr v-dest)
623     (gsl-vec-ptr v-src)))
624 edenny 1.3 ((eq (gsl-vec-element-type v-src) 'double-float)
625 edenny 1.1 (gsl-vector-memcpy (gsl-vec-ptr v-dest)
626     (gsl-vec-ptr v-src)))
627 edenny 1.3 ((equal (gsl-vec-element-type v-src)
628     '(complex (single-float)))
629 edenny 1.1 (gsl-vector-complex-float-memcpy (gsl-vec-ptr v-dest)
630     (gsl-vec-ptr v-src)))
631 edenny 1.3 ((equal (gsl-vec-element-type v-src)
632     '(complex (double-float)))
633 edenny 1.1 (gsl-vector-complex-memcpy (gsl-vec-ptr v-dest)
634 edenny 1.3 (gsl-vec-ptr v-src)))
635     (t
636     (error "No matching type")))))
637 edenny 1.1 (values v-dest status)))
638 edenny 1.5
639    
640     (defmacro with-vector-copy ((vec-dest vec-src) &body body)
641     `(let ((,vec-dest (copy ,vec-src)))
642     (unwind-protect
643     ,@body
644     (free ,vec-dest))))
645 edenny 1.1
646    
647     (defun swap (va vb)
648 edenny 1.3 (assert (eq 'gsl-vec (type-of va)))
649     (assert (eq 'gsl-vec (type-of vb)))
650 edenny 1.1 (assert (eq (gsl-vec-element-type va) (gsl-vec-element-type vb)))
651     (assert (= (gsl-vec-size va) (gsl-vec-size vb)))
652     (let ((status
653 edenny 1.3 (cond
654     ((eq (gsl-vec-element-type va) 'integer)
655 edenny 1.1 (gsl-vector-int-swap (gsl-vec-ptr va) (gsl-vec-ptr vb)))
656 edenny 1.3 ((eq (gsl-vec-element-type va) 'single-float)
657 edenny 1.1 (gsl-vector-float-swap (gsl-vec-ptr va) (gsl-vec-ptr vb)))
658 edenny 1.3 ((eq (gsl-vec-element-type va) 'double-float)
659 edenny 1.1 (gsl-vector-swap (gsl-vec-ptr va) (gsl-vec-ptr vb)))
660 edenny 1.3 ((equal (gsl-vec-element-type va) '(complex (single-float)))
661 edenny 1.1 (gsl-vector-complex-float-swap (gsl-vec-ptr va) (gsl-vec-ptr vb)))
662 edenny 1.3 ((equal (gsl-vec-element-type va) '(complex (double-float)))
663     (gsl-vector-complex-swap (gsl-vec-ptr va) (gsl-vec-ptr vb)))
664     (t
665     (error "No matching type")))))
666     (values va status)))
667 edenny 1.1
668    
669     (defun swap-elements (v i j)
670 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
671 edenny 1.1 (assert (typep i 'integer))
672     (assert (typep j 'integer))
673     (assert (< i (gsl-vec-size v)))
674     (assert (< j (gsl-vec-size v)))
675     (let ((status
676 edenny 1.3 (cond
677     ((eq (gsl-vec-element-type v) 'integer)
678 edenny 1.1 (gsl-vector-int-swap-elements (gsl-vec-ptr v) i j))
679 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
680 edenny 1.1 (gsl-vector-float-swap-elements (gsl-vec-ptr v) i j))
681 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
682 edenny 1.1 (gsl-vector-swap-elements (gsl-vec-ptr v) i j))
683 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
684 edenny 1.1 (gsl-vector-complex-float-swap-elements (gsl-vec-ptr v) i j))
685 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
686     (gsl-vector-complex-swap-elements (gsl-vec-ptr v) i j))
687     (t
688     (error "No matching type")))))
689 edenny 1.1 (values v status)))
690    
691    
692     (defun reverse-vector (v)
693 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
694 edenny 1.1 (let ((status
695 edenny 1.3 (cond
696     ((eq (gsl-vec-element-type v) 'integer)
697 edenny 1.1 (gsl-vector-int-reverse (gsl-vec-ptr v)))
698 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
699 edenny 1.1 (gsl-vector-float-reverse (gsl-vec-ptr v)))
700 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
701 edenny 1.1 (gsl-vector-reverse (gsl-vec-ptr v)))
702 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
703 edenny 1.1 (gsl-vector-complex-float-reverse (gsl-vec-ptr v)))
704 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
705     (gsl-vector-complex-reverse (gsl-vec-ptr v)))
706     (t
707     (error "No matching type")))))
708 edenny 1.1 (values v status)))
709    
710    
711     (defun add (va vb)
712 edenny 1.3 (assert (eq 'gsl-vec (type-of va)))
713     (assert (eq 'gsl-vec (type-of vb)))
714 edenny 1.1 (assert (eq (gsl-vec-element-type va) (gsl-vec-element-type vb)))
715     (assert (= (gsl-vec-size va) (gsl-vec-size vb)))
716     (let ((status
717 edenny 1.3 (cond
718     ((eq (gsl-vec-element-type va) 'integer)
719 edenny 1.1 (gsl-vector-int-add (gsl-vec-ptr va) (gsl-vec-ptr vb)))
720 edenny 1.3 ((eq (gsl-vec-element-type va) 'single-float)
721 edenny 1.1 (gsl-vector-float-add (gsl-vec-ptr va) (gsl-vec-ptr vb)))
722 edenny 1.3 ((eq (gsl-vec-element-type va) 'double-float)
723     (gsl-vector-add (gsl-vec-ptr va) (gsl-vec-ptr vb)))
724     (t
725     (error "No matching type")))))
726 edenny 1.1 (values va status)))
727    
728    
729     (defun sub (va vb)
730 edenny 1.3 (assert (eq 'gsl-vec (type-of va)))
731     (assert (eq 'gsl-vec (type-of vb)))
732 edenny 1.1 (assert (eq (gsl-vec-element-type va) (gsl-vec-element-type vb)))
733     (assert (= (gsl-vec-size va) (gsl-vec-size vb)))
734     (let ((status
735 edenny 1.3 (cond
736     ((eq (gsl-vec-element-type va) 'integer)
737 edenny 1.1 (gsl-vector-int-sub (gsl-vec-ptr va) (gsl-vec-ptr vb)))
738 edenny 1.3 ((eq (gsl-vec-element-type va) 'single-float)
739 edenny 1.1 (gsl-vector-float-sub (gsl-vec-ptr va) (gsl-vec-ptr vb)))
740 edenny 1.3 ((eq (gsl-vec-element-type va) 'double-float)
741     (gsl-vector-sub (gsl-vec-ptr va) (gsl-vec-ptr vb)))
742     (t
743     (error "No matching type")))))
744 edenny 1.1 (values va status)))
745    
746 edenny 1.3
747 edenny 1.1 (defun mul (va vb)
748 edenny 1.3 (assert (eq 'gsl-vec (type-of va)))
749     (assert (eq 'gsl-vec (type-of vb)))
750 edenny 1.1 (assert (eq (gsl-vec-element-type va) (gsl-vec-element-type vb)))
751     (assert (= (gsl-vec-size va) (gsl-vec-size vb)))
752     (let ((status
753 edenny 1.3 (cond
754     ((eq (gsl-vec-element-type va) 'integer)
755 edenny 1.1 (gsl-vector-int-mul (gsl-vec-ptr va) (gsl-vec-ptr vb)))
756 edenny 1.3 ((eq (gsl-vec-element-type va) 'single-float)
757 edenny 1.1 (gsl-vector-float-mul (gsl-vec-ptr va) (gsl-vec-ptr vb)))
758 edenny 1.3 ((eq (gsl-vec-element-type va) 'double-float)
759     (gsl-vector-mul (gsl-vec-ptr va) (gsl-vec-ptr vb)))
760     (t
761     (error "No matching type")))))
762 edenny 1.1 (values va status)))
763    
764    
765     (defun div (va vb)
766 edenny 1.3 (assert (eq 'gsl-vec (type-of va)))
767     (assert (eq 'gsl-vec (type-of vb)))
768 edenny 1.1 (assert (eq (gsl-vec-element-type va) (gsl-vec-element-type vb)))
769     (assert (= (gsl-vec-size va) (gsl-vec-size vb)))
770     (let ((status
771 edenny 1.3 (cond
772     ((eq (gsl-vec-element-type va) 'integer)
773 edenny 1.1 (gsl-vector-int-div (gsl-vec-ptr va) (gsl-vec-ptr vb)))
774 edenny 1.3 ((eq (gsl-vec-element-type va) 'single-float)
775 edenny 1.1 (gsl-vector-float-div (gsl-vec-ptr va) (gsl-vec-ptr vb)))
776 edenny 1.3 ((eq (gsl-vec-element-type va) 'double-float)
777     (gsl-vector-div (gsl-vec-ptr va) (gsl-vec-ptr vb)))
778     (t
779     (error "No matching type")))))
780 edenny 1.1 (values va status)))
781    
782    
783     (defun scale (v x)
784 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
785     (assert (typep x (gsl-vec-element-type v)))
786 edenny 1.1 (let ((status
787 edenny 1.3 (cond
788     ((eq (gsl-vec-element-type v) 'integer)
789 edenny 1.7 ;; coerce to double-float looks wrong, but isn't.
790     (gsl-vector-int-scale (gsl-vec-ptr v) (coerce x 'double-float)))
791 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
792 edenny 1.7 (gsl-vector-float-scale (gsl-vec-ptr v) (coerce x 'double-float)))
793 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
794     (gsl-vector-scale (gsl-vec-ptr v) x))
795     (t
796     (error "No matching type")))))
797 edenny 1.1 (values v status)))
798    
799    
800     (defun add-constant (v x)
801 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
802     (assert (typep x (gsl-vec-element-type v)))
803 edenny 1.1 (let ((status
804 edenny 1.3 (cond
805     ((eq (gsl-vec-element-type v) 'integer)
806 edenny 1.7 (gsl-vector-int-add-constant (gsl-vec-ptr v)
807     (coerce x 'double-float)))
808 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
809 edenny 1.7 (gsl-vector-float-add-constant (gsl-vec-ptr v)
810     (coerce x 'double-float)))
811 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
812     (gsl-vector-add-constant (gsl-vec-ptr v) x))
813     (t
814     (error "No matching type")))))
815 edenny 1.1 (values v status)))
816    
817    
818     (defun max-value (v)
819 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
820     (cond
821     ((eq (gsl-vec-element-type v) 'integer)
822 edenny 1.1 (gsl-vector-int-max (gsl-vec-ptr v)))
823 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
824 edenny 1.1 (gsl-vector-float-max (gsl-vec-ptr v)))
825 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
826     (gsl-vector-max (gsl-vec-ptr v)))
827     (t
828     (error "No matching type"))))
829 edenny 1.1
830    
831     (defun min-value (v)
832 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
833     (cond
834     ((eq (gsl-vec-element-type v) 'integer)
835 edenny 1.1 (gsl-vector-int-min (gsl-vec-ptr v)))
836 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
837 edenny 1.1 (gsl-vector-float-min (gsl-vec-ptr v)))
838 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
839     (gsl-vector-min (gsl-vec-ptr v)))
840     (t
841     (error "No matching type"))))
842 edenny 1.1
843    
844     (defun max-index (v)
845 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
846     (cond
847     ((eq (gsl-vec-element-type v) 'integer)
848 edenny 1.1 (gsl-vector-int-max-index (gsl-vec-ptr v)))
849 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
850 edenny 1.1 (gsl-vector-float-max-index (gsl-vec-ptr v)))
851 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
852     (gsl-vector-max-index (gsl-vec-ptr v)))
853     (t
854     (error "No matching type"))))
855 edenny 1.1
856    
857 edenny 1.2 (defun min-index (v)
858 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
859     (cond
860     ((eq (gsl-vec-element-type v) 'integer)
861 edenny 1.1 (gsl-vector-int-min-index (gsl-vec-ptr v)))
862 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
863 edenny 1.1 (gsl-vector-float-min-index (gsl-vec-ptr v)))
864 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
865     (gsl-vector-min-index (gsl-vec-ptr v)))
866     (t
867     (error "No matching type"))))
868    
869 edenny 1.1
870     (defun min-max-indicies (v)
871 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
872 edenny 1.1 (let ((min-ptr (uffi:allocate-foreign-object 'size-t))
873     (max-ptr (uffi:allocate-foreign-object 'size-t)))
874 edenny 1.3 (cond
875     ((eq (gsl-vec-element-type v) 'integer)
876 edenny 1.2 (gsl-vector-int-minmax-index (gsl-vec-ptr v) min-ptr max-ptr))
877 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
878 edenny 1.2 (gsl-vector-float-minmax-index (gsl-vec-ptr v) min-ptr max-ptr))
879 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
880     (gsl-vector-minmax-index (gsl-vec-ptr v) min-ptr max-ptr))
881     (t
882     (error "No matching type")))
883 edenny 1.1 (prog1
884 edenny 1.2 (list (uffi:deref-pointer min-ptr 'size-t)
885     (uffi:deref-pointer max-ptr 'size-t))
886 edenny 1.1 (uffi:free-foreign-object min-ptr)
887     (uffi:free-foreign-object max-ptr))))
888    
889    
890     (defun min-max-values (v)
891 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
892 edenny 1.1 (destructuring-bind (min-index max-index)
893     (min-max-indicies v)
894     (list (get-element v min-index)
895     (get-element v max-index))))
896    
897    
898     (defun isnull (v)
899 edenny 1.3 (assert (eq 'gsl-vec (type-of v)))
900     (1/0->t/nil (cond
901     ((eq (gsl-vec-element-type v) 'integer)
902 edenny 1.1 (gsl-vector-int-isnull (gsl-vec-ptr v)))
903 edenny 1.3 ((eq (gsl-vec-element-type v) 'single-float)
904 edenny 1.1 (gsl-vector-float-isnull (gsl-vec-ptr v)))
905 edenny 1.3 ((eq (gsl-vec-element-type v) 'double-float)
906 edenny 1.1 (gsl-vector-isnull (gsl-vec-ptr v)))
907 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (single-float)))
908 edenny 1.1 (gsl-vector-complex-float-isnull (gsl-vec-ptr v)))
909 edenny 1.3 ((equal (gsl-vec-element-type v) '(complex (double-float)))
910     (gsl-vector-complex-isnull (gsl-vec-ptr v)))
911     (t
912     (error "No matching type")))))
913 edenny 1.6
914    
915 edenny 1.7 (defun gsl->lisp-vector (v)
916 edenny 1.6 (assert (eq 'gsl-vec (type-of v)))
917     (let ((a (make-array (gsl-vec-size v) :element-type (gsl-vec-element-type v))))
918     (dotimes (i (gsl-vec-size v) a)
919     (setf (aref a i) (get-element v i)))))
920 edenny 1.1
921     ;; Function: gsl_vector_view gsl_vector_complex_real (gsl_vector_complex *v)
922     ;; Function: gsl_vector_view gsl_vector_complex_imag (gsl_vector_complex *v)
923    
924     ;; ----------------------------------------------------------------------
925     ;; Functions that I don't think need binding.
926     ;;
927    
928     ;; Function: gsl_vector * gsl_vector_calloc (size_t n)
929    
930     ;; Function: double * gsl_vector_ptr (gsl_vector * v, size_t i)
931     ;; Function: const double * gsl_vector_const_ptr (const gsl_vector * v, size_t i)
932    
933     ;; Function: gsl_vector_const_view gsl_vector_const_subvector (const gsl_vector * v, size_t offset, size_t n)
934    
935     ;; Function: gsl_vector_const_view gsl_vector_const_subvector_with_stride (const gsl_vector * v, size_t offset, size_t stride, size_t n)
936    
937     ;; Function: gsl_vector_const_view gsl_vector_complex_const_real (const gsl_vector_complex *v)
938    
939     ;; Function: gsl_vector_const_view gsl_vector_complex_const_imag (const gsl_vector_complex *v)
940    
941     ;; Function: gsl_vector_view gsl_vector_view_array_with_stride (double * base, size_t stride, size_t n)
942     ;; Function: gsl_vector_const_view gsl_vector_const_view_array_with_stride (const double * base, size_t stride, size_t n)
943 edenny 1.4

  ViewVC Help
Powered by ViewVC 1.1.5