-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontinuous_p.lisp
117 lines (99 loc) · 4.01 KB
/
continuous_p.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(in-package :maxima)
(defun $myload (str)
(load ($file_search str) :print t :verbose t))
(defvar *c-hashtable* (make-hash-table :size 32 :test #'eq))
(defvar *op* (make-hash-table))
(defun $report ()
(maphash #'(lambda (a b) (mtell "~M ~M ~%" a b)) *op*))
(defun continuous-p (e x pt)
(let ((fn))
(cond ((memq pt (list '$minf '$inf '$infinity '$und '$ind)) nil)
((memq e (list '$minf '$inf '$infinity '$und '$ind)) nil)
(($mapatom e) t)
(t
(setq fn (gethash (caar e) *c-hashtable* nil))
(when (not fn)
(setf (gethash (caar e) *op*) (+ 1 (gethash (caar e) *op* 0))))
(if fn (funcall fn (cdr e) x pt) nil)))))
(defun limit-by-direct-subst (e x pt)
(if (continuous-p e x pt) (maxima-substitute pt x e) nil))
(defun log-continuous-p (e x pt)
(setq e (risplit (first e)))
(and
(continuous-p (car e) x pt)
(continuous-p (cdr e) x pt)
(eq t (mnqp 0 (maxima-substitute pt x (car e))))
(eq t (mnqp 0 (maxima-substitute pt x (cdr e))))))
(setf (gethash '%log *c-hashtable*) #'log-continuous-p)
(defun gamma-continuous-p (e x pt)
(setq e (first e))
(cond ((continuous-p e x pt)
(setq e (maxima-substitute pt x e))
(not (and ($integerp e) (eq t (mgrp 0 e)))))
(t nil)))
(setf (gethash '%gamma *c-hashtable*) #'gamma-continuous-p)
(defun mfactorial-continuous-p (e x pt)
(setq e (first e))
(cond ((continuous-p e x pt)
(setq e (maxima-substitute pt x e))
(not (and ($integerp e) (eq t (mgrp 1 e)))))
(t nil)))
;(setf (gethash 'mfactorial *c-hashtable*) #'mfactorial-continuous-p)
(defun expt-continuous-p (e x pt)
(let ((a (first e)) (b (second e)))
(cond ((and (continuous-p a x pt)
(continuous-p b x pt))
(setq a (maxima-substitute pt x a))
(setq b (maxima-substitute pt x b))
(or
(eq t (mgrp a 0))
(and
($integerp b)
(eq t (mgrp b 0))))))))
(setf (gethash 'mexpt *c-hashtable*) #'expt-continuous-p)
(defun floor-continuous-p (e x pt)
(setq e (first e))
(and
(continuous-p e x pt)
($featurep (maxima-substitute pt x e) '$noninteger)))
(setf (gethash '$floor *c-hashtable*) #'floor-continuous-p)
(setf (gethash '$ceiling *c-hashtable*) #'floor-continuous-p)
(defun round-continuous-p (e x pt)
(setq e (first e))
(and
(continuous-p e x pt)
($featurep (sub (maxima-substitute pt x e) (div 1 2))
'$noninteger)))
(setf (gethash '%round *c-hashtable*) #'floor-continuous-p)
(defun signum-continuous-p (e x pt)
(setq e (first e))
(and
(continuous-p e x pt)
(eq t (mnqp (maxima-substitute pt x e) 0))))
(setf (gethash '%signum *c-hashtable*) #'signum-continuous-p)
(setf (gethash '$unit_step *c-hashtable*) #'signum-continuous-p)
(defun asinh-continuous-p (e x pt)
(setq e (first e))
(and
(continuous-p e x pt)
($featurep e '$real)))
(setf (gethash '%asinh *c-hashtable*) #'asinh-continuous-p)
(setf (gethash '%atan *c-hashtable*) #'asinh-continuous-p)
(defun atan2-continuous-p (e x pt)
(let ((b (first e)) (a (second e)))
(mtell "a = ~M; b = ~M; x = ~M ; pt = ~M ~%" a b x pt)
(and
(continuous-p a x pt)
(continuous-p b x pt)
($featurep a '$real)
($featurep b '$real)
(eq t (mgrp (maxima-substitute pt x a) 0)))))
(setf (gethash '$atan2 *c-hashtable*) #'atan2-continuous-p)
(setf (gethash '%asinh *c-hashtable*) #'asinh-continuous-p)
(setf (gethash '%atan *c-hashtable*) #'asinh-continuous-p)
(defmfun $continuous_p (e x pt)
(continuous-p e x pt))
(defun default-continuous-p (e x pt)
(every #'(lambda (q) (continuous-p q x pt)) e))
(dolist (xxx (list '%integrate '$max '$min '%cos '%sin '%cosh '%sinh 'mplus 'mabs 'mtimes '$conjugate))
(setf (gethash xxx *c-hashtable*) #'default-continuous-p))