mirror of
https://git.FreeBSD.org/ports.git
synced 2024-10-19 19:59:43 +00:00
The spice3 "^" operator (power) did not work properly unless its
right-hand operand was a constant, because of a bug in the code to take the derivative of an expression. Add a patch to fix that.
This commit is contained in:
parent
9823d4bce0
commit
6c89186444
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=162349
34
cad/spice/files/patch-src_lib_inp_inpptree_c
Normal file
34
cad/spice/files/patch-src_lib_inp_inpptree_c
Normal file
@ -0,0 +1,34 @@
|
||||
--- src/lib/inp/inpptree.c.orig Mon May 3 02:16:54 1993
|
||||
+++ src/lib/inp/inpptree.c Sun May 14 09:34:56 2006
|
||||
@@ -1,6 +1,8 @@
|
||||
/**********
|
||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group
|
||||
+Modified: 2006 John D. Polstra - Fix differentiation of a^b where b is not
|
||||
+ constant.
|
||||
**********/
|
||||
|
||||
#include "spice.h"
|
||||
@@ -206,18 +208,10 @@
|
||||
mkcon(p->right->constant - 1))),
|
||||
arg1);
|
||||
} else {
|
||||
- /* This is complicated. f(x) ^ g(x) ->
|
||||
- * exp(y(x) * ln(f(x)) ...
|
||||
- */
|
||||
- arg1 = PTdifferentiate(p->left, varnum);
|
||||
- arg2 = PTdifferentiate(p->right, varnum);
|
||||
- newp = mkb(PT_TIMES, mkf(PTF_EXP, mkb(PT_TIMES,
|
||||
- p->right, mkf(PTF_LN, p->left))),
|
||||
- mkb(PT_PLUS, mkb(PT_TIMES, p->right,
|
||||
- mkb(PT_DIVIDE, arg1, p->left)),
|
||||
- mkb(PT_TIMES, arg2,
|
||||
- mkf(PTF_LN, arg1))));
|
||||
-
|
||||
+ /* Rewrite a^b as exp(ln(a) * b) */
|
||||
+ newp = mkf(PTF_EXP, mkb(PT_TIMES, mkf(PTF_LN, p->left), p->right));
|
||||
+ /* Differentiate the rewritten form. */
|
||||
+ newp = PTdifferentiate(newp, varnum);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user