freebsd-ports/cad/spice/files/patch-src_lib_inp_inpptree_c
Philip M. Gollucci 0ec10e2e24 -Clean some warnings by using string.h instead of strings.h
Applied several patches from this website:
http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/secD.html
specifically fixes for:
- Where command causes crashes
- Recognition of scale factors in arbitrary source
- Current Controlled Switch in subckt, parsing error
- Noise analysis bug
- Save segmentation faults
- BSIM1 model xpart parameter random
- Tran analysis default TSTEP

PR:             ports/143727
Submitted by:   "Pedro F. Giffuni" <giffunip@tutopia.com>
2010-02-11 19:40:33 +00:00

43 lines
1.5 KiB
Text

--- src/lib/inp/inpptree.c.orig 1993-05-03 09:16:54.000000000 +0000
+++ src/lib/inp/inpptree.c 2010-02-09 15:45:52.000000000 +0000
@@ -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;
@@ -977,7 +971,7 @@
break;
}
- td = INPevaluate(&sbuf, &err, 0);
+ td = INPevaluate(&sbuf, &err, 1);
if (err == OK) {
el.token = TOK_VALUE;
el.type = TYP_NUM;