use limiting mylog()/mylog10() functions in expression calculator
This commit is contained in:
parent
4bbed85d23
commit
29d6655a01
|
|
@ -29,6 +29,12 @@ double mylog10(double x)
|
|||
else return -35;
|
||||
}
|
||||
|
||||
double mylog(double x)
|
||||
{
|
||||
if(x > 0) return log(x);
|
||||
else return -35;
|
||||
}
|
||||
|
||||
int my_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
while(tolower(*s1) == tolower(*s2)) {
|
||||
|
|
|
|||
10
src/save.c
10
src/save.c
|
|
@ -764,11 +764,11 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
|
|||
}
|
||||
else if(!strcmp(n, "exch()")) stack1[stackptr1++].i = EXCH;
|
||||
else if(!strcmp(n, "dup()")) stack1[stackptr1++].i = DUP;
|
||||
else if( (strtod(n, &endptr)), endptr > n) {
|
||||
else if( (strtod(n, &endptr)), endptr > n) { /* NUMBER */
|
||||
stack1[stackptr1].i = NUMBER;
|
||||
stack1[stackptr1++].d = atof_spice(n);
|
||||
}
|
||||
else {
|
||||
else { /* SPICE_NODE */
|
||||
idx = get_raw_index(n);
|
||||
if(idx == -1) {
|
||||
dbg(1, "plot_raw_custom_data(): no data found: %s\n", n);
|
||||
|
|
@ -1034,13 +1034,13 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
|
|||
stack2[stackptr2 - 1] = exp(stack2[stackptr2 - 1]);
|
||||
break;
|
||||
case LN:
|
||||
stack2[stackptr2 - 1] = log(stack2[stackptr2 - 1]);
|
||||
stack2[stackptr2 - 1] = mylog(stack2[stackptr2 - 1]);
|
||||
break;
|
||||
case LOG10:
|
||||
stack2[stackptr2 - 1] = log10(stack2[stackptr2 - 1]);
|
||||
stack2[stackptr2 - 1] = mylog10(stack2[stackptr2 - 1]);
|
||||
break;
|
||||
case DB20:
|
||||
stack2[stackptr2 - 1] = 20 * log10(stack2[stackptr2 - 1]);
|
||||
stack2[stackptr2 - 1] = 20 * mylog10(stack2[stackptr2 - 1]);
|
||||
break;
|
||||
case SGN:
|
||||
stack2[stackptr2 - 1] = stack2[stackptr2 - 1] > 0.0 ? 1 :
|
||||
|
|
|
|||
|
|
@ -1305,6 +1305,7 @@ extern char *my_strtok_r(char *str, const char *delim, const char *quote, char *
|
|||
extern int my_strncpy(char *d, const char *s, size_t n);
|
||||
extern int my_strcasecmp(const char *s1, const char *s2);
|
||||
extern double mylog10(double x);
|
||||
extern double mylog(double x);
|
||||
extern int my_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
extern char* strtolower(char* s);
|
||||
extern char* strtoupper(char* s);
|
||||
|
|
|
|||
Loading…
Reference in New Issue