diff --git a/doc/xschem_man/graphs.html b/doc/xschem_man/graphs.html
index fdbce825..050c5898 100644
--- a/doc/xschem_man/graphs.html
+++ b/doc/xschem_man/graphs.html
@@ -188,12 +188,22 @@ p{padding: 15px 30px 10px;}
sin() Trig. sin function
cos() Trig. cos function
tan() Trig. tan function
+ sinh() Hyp. sin function
+ cosh() Hyp. cos function
+ tanh() Hyp. tan function
+ asinh() Inv hyp. sin function
+ acosh() Inv hyp. cos function
+ atanh() Inv hyp. tan function
+ asin() Inverse trig. sin function
+ acos() Inverse trig. cos function
+ atan() Inverse trig. tan function
sqrt() Square root
sgn() Sign
abs() Absolute value
exp() Base-e Exponentiation
ln() Base-e logarithm
log10() Base 10 logarithm
+ idx() point number (0, 1, 2, ...) in vector
db20() Value in deciBel (20 * log10(n))
avg() Average
prev() Delay waveform by one point (at any x-axis position take the previous value)
diff --git a/src/save.c b/src/save.c
index c1571b43..b7cc5714 100644
--- a/src/save.c
+++ b/src/save.c
@@ -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 ...) */