add idx() function (return index of point, 0, 1, 2, ...). doc updates about new wave processor functions

This commit is contained in:
stefan schippers 2024-02-24 22:35:54 +01:00
parent 203cf38e1e
commit 5a2891e4de
2 changed files with 21 additions and 2 deletions

View File

@ -188,12 +188,22 @@ p{padding: 15px 30px 10px;}
<li><kbd>sin()</kbd> Trig. sin function</li>
<li><kbd>cos()</kbd> Trig. cos function</li>
<li><kbd>tan()</kbd> Trig. tan function</li>
<li><kbd>sinh()</kbd> Hyp. sin function</li>
<li><kbd>cosh()</kbd> Hyp. cos function</li>
<li><kbd>tanh()</kbd> Hyp. tan function</li>
<li><kbd>asinh()</kbd> Inv hyp. sin function</li>
<li><kbd>acosh()</kbd> Inv hyp. cos function</li>
<li><kbd>atanh()</kbd> Inv hyp. tan function</li>
<li><kbd>asin()</kbd> Inverse trig. sin function</li>
<li><kbd>acos()</kbd> Inverse trig. cos function</li>
<li><kbd>atan()</kbd> Inverse trig. tan function</li>
<li><kbd>sqrt()</kbd> Square root</li>
<li><kbd>sgn()</kbd> Sign</li>
<li><kbd>abs()</kbd> Absolute value</li>
<li><kbd>exp()</kbd> Base-e Exponentiation</li>
<li><kbd>ln()</kbd> Base-e logarithm</li>
<li><kbd>log10()</kbd> Base 10 logarithm</li>
<li><kbd>idx()</kbd> point number (0, 1, 2, ...) in vector</li>
<li><kbd>db20()</kbd> Value in deciBel (20 * log10(n))</li>
<li><kbd>avg()</kbd> Average</li>
<li><kbd>prev()</kbd> Delay waveform by one point (at any x-axis position take the previous value)</li>

View File

@ -1459,6 +1459,7 @@ static double ravg_store(int what , int i, int p, int last, double value)
#define ATANH 35
#define ACOSH 36
#define ASINH 37
#define IDX 38 /* index of point in raw file (0, 1, 2, ...) */
#define ORDER_DERIV 1 /* 1 or 2: 1st order or 2nd order differentiation. 1st order is faster */
@ -1525,6 +1526,7 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c
else if(!strcmp(n, "asinh()")) stack1[stackptr1++].i = ASINH;
else if(!strcmp(n, "exp()")) stack1[stackptr1++].i = EXP;
else if(!strcmp(n, "ln()")) stack1[stackptr1++].i = LN;
else if(!strcmp(n, "idx()")) stack1[stackptr1++].i = IDX;
else if(!strcmp(n, "log10()")) stack1[stackptr1++].i = LOG10;
else if(!strcmp(n, "integ()")) {
if(first > 0) first--;
@ -1589,7 +1591,6 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c
else if(stack1[i].i == SPICE_NODE && stack1[i].idx < xctx->raw->nvars) { /* spice node */
stack2[stackptr2++] = xctx->raw->values[stack1[i].idx][p];
}
if(stackptr2 > 1) { /* 2 argument operators */
switch(stack1[i].i) {
case PLUS:
@ -1681,7 +1682,7 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c
break;
} /* switch(...) */
} /* if(stackptr2 > 1) */
if(stackptr2 > 0) { /* 1 argument operators */
else if(stackptr2 > 0) { /* 1 argument operators */
switch(stack1[i].i) {
case AVG:
if( p == first ) {
@ -1880,6 +1881,9 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c
case LOG10:
stack2[stackptr2 - 1] = mylog10(stack2[stackptr2 - 1]);
break;
case IDX:
stack2[stackptr2 - 1] = (double)p;
break;
case DB20:
stack2[stackptr2 - 1] = 20 * mylog10(stack2[stackptr2 - 1]);
break;
@ -1889,6 +1893,11 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr, c
break;
} /* switch(...) */
} /* if(stackptr2 > 0) */
else if(stackptr2 == 0) {
if(stack1[i].i == IDX) {
stack2[stackptr2] = (double)p;
}
}
} /* for(i = 0; i < stackptr1; ++i) */
y[p] = (SPICE_DATA)stack2[0];
} /* for(p = first ...) */