Commit bd7b3ba8 authored by Liam M. Healy's avatar Liam M. Healy

Check dimensions with dimensionless units

When calling #'check-dimension with units = 'dimensionless and an
argument that is a pdq that is not a grid, return an error message
that specifically says it is not dimensionless. This fixes an error in
arc trig functions that would not even give an error, but return the
dimel (list) for 'dimensionless (i.e., all zeros). Rather than fixing
in #'equal-dimension, it is fixed here so that the error message is
clear to the user.'
parent 0e2f00ff
;; Objects that represent physical measurements.
;; Liam Healy Wed Mar 6 2002 - 09:04
;; Time-stamp: <2017-11-23 19:09:19EST physical-quantities.lisp>
;; Time-stamp: <2019-01-05 09:57:45EST physical-quantities.lisp>
;; Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Liam M. Healy
;; Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -92,7 +92,9 @@
(if (and obj (grid:gridp obj) (not (scalar-dimension obj)))
(loop for i from 0 below (grid:total-size obj)
always (equal-dimension (grid:aref* obj i) (grid:aref* obj i)))
(equal-dimension obj (parse-units units) errorp zeros-have-any-dimension t))
(if (eq units 'dimensionless)
(if errorp (error "~a is not dimensionless" obj) nil)
(equal-dimension obj (parse-units units) errorp zeros-have-any-dimension t)))
(eq units 'dimensionless)))
(defun equal-dimension
......
;; Physical dimension quantity with a magnitude that is a scalar
;; Liam Healy 2011-01-01 12:05:37EST grid.lisp
;; Time-stamp: <2017-10-15 22:11:39EDT scalar.lisp>
;; Time-stamp: <2019-01-05 09:55:46EST scalar.lisp>
;; Copyright 2011, 2013, 2015 Liam M. Healy
;; Copyright 2011, 2013, 2015, 2017, 2019 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -53,6 +53,9 @@
(defun physical-quantity-p (x) (typep x 'antik:physical-quantity))
(defparameter *zero-is-dimensionless* t
"Numbers with zero magnitude are made dimensionless.")
(defun make-pq-object (mag dimel scalar-dimension)
#+debug
(when (physical-quantity-p mag)
......@@ -77,9 +80,6 @@
'physical-quantity
:magnitude mag :dimension dimel :scalar-dimension scalar-dimension)))
(defparameter *zero-is-dimensionless* t
"Numbers with zero magnitude are made dimensionless.")
;;; (make-pq 33.4 "meters/second")
;;; (make-pq 88 '(/ feet minute))
;;; (make-pq 5 'speed)
......
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