Commit 9b15d4b5 authored by Liam Healy's avatar Liam Healy

Sclar addition/multiplication use doubles for the scalar

GSL uses doubles for scalar addition and multiplication, regardless of
the element type of the array, so modified the definitions of #'m*c,
#'m+c accordingly.
parent 817cdcef
;; Tests of array functions
;; Liam Healy 2008-10-20 22:41:48EDT array-tests.lisp
;; Time-stamp: <2008-11-08 22:27:39EST array-tests.lisp>
;; Time-stamp: <2008-11-16 10:28:21EST array-tests.lisp>
;; $Id: $
;;; Generate each file with #'write-test-to-file, e.g.
......@@ -113,27 +113,21 @@
(m2 (array-default '(3 3))))
(cl-array (m/ m1 m2))))
#| Temporarily commented out due to GSL bug
(generate-all-array-tests vector-mult-scalar :no-complex
(letm ((v1 (array-default 3))
(scalar (scalar-default)))
(cl-array (m*c v1 scalar))))
(letm ((v1 (array-default 3)))
(cl-array (m*c v1 1.39d0))))
(generate-all-array-tests matrix-mult-scalar :no-complex
(letm ((m1 (array-default '(3 3)))
(scalar (scalar-default)))
(cl-array (m*c m1 scalar))))
(letm ((m1 (array-default '(3 3))))
(cl-array (m*c m1 1.39d0))))
(generate-all-array-tests vector-add-scalar :no-complex
(letm ((v1 (array-default 3))
(scalar (scalar-default)))
(cl-array (m+c v1 scalar))))
(letm ((v1 (array-default 3)))
(cl-array (m+c v1 18.19d0))))
(generate-all-array-tests matrix-add-scalar :no-complex
(letm ((m1 (array-default '(3 3)))
(scalar (scalar-default)))
(cl-array (m+c m1 scalar))))
|#
(letm ((m1 (array-default '(3 3))))
(cl-array (m+c m1 18.19d0))))
;;;;****************************************************************************
;;;; Maximum and minimum elements
......@@ -215,7 +209,7 @@
(generate-all-array-tests set-identity t
(letm ((m1 (array-default '(3 3))))
(set-identity m1)))
(cl-array (set-identity m1))))
(generate-all-array-tests row t
(letm ((m1 (array-default '(3 3)))
......
;; Functions for both vectors and matrices.
;; Liam Healy 2008-04-26 20:48:44EDT both.lisp
;; Time-stamp: <2008-11-08 17:23:47EST both.lisp>
;; Time-stamp: <2008-11-16 10:23:32EST both.lisp>
;; $Id$
(in-package :gsl)
......@@ -105,8 +105,6 @@
;;; Errors in GSL:
;;; 1) complex operations in older versions of GSL
;;; https://savannah.gnu.org/bugs/index.php?22478
;;; 2) Scalar operation m*c, m+c require a double
;;; for the scalar. Reported 2008-11-08.
(defmfun m+ ((a both) (b both))
("gsl_" :category :type "_add")
......@@ -176,25 +174,25 @@
(defmfun m*c ((a both) x)
("gsl_" :category :type "_scale")
(((mpointer a) :pointer) (x :element-c-type))
(((mpointer a) :pointer) (x :double))
:definition :generic
:element-types :no-complex
:inputs (a)
:outputs (a)
:return (a)
:documentation ; FDL
"Multiply the elements of a by the constant factor x.")
"Multiply the elements of a by the scalar factor x.")
(defmfun m+c ((a both) x)
("gsl_" :category :type "_add_constant")
(((mpointer a) :pointer) (x :element-c-type))
(((mpointer a) :pointer) (x :double))
:definition :generic
:element-types :no-complex
:inputs (a)
:outputs (a)
:return (a)
:documentation ; FDL
"Add the constant value x to the elements of the a.")
"Add the scalar double x to all the elements of array a.")
;;;;****************************************************************************
;;;; Maximum and minimum elements
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment