From 9b15d4b5fcb548b021f55f19c3848019bd906da1 Mon Sep 17 00:00:00 2001
From: Liam Healy <liam@thinkpad.local>
Date: Sun, 16 Nov 2008 10:48:19 -0500
Subject: [PATCH] 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.
---
 data/array-tests.lisp | 26 ++++++++++----------------
 data/both.lisp        | 12 +++++-------
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/data/array-tests.lisp b/data/array-tests.lisp
index d13a65a9..0baa88d3 100644
--- a/data/array-tests.lisp
+++ b/data/array-tests.lisp
@@ -1,6 +1,6 @@
 ;; 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)))
diff --git a/data/both.lisp b/data/both.lisp
index 1b6aa03c..a099d89d 100644
--- a/data/both.lisp
+++ b/data/both.lisp
@@ -1,6 +1,6 @@
 ;; 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
-- 
GitLab