Browse code

eval: add support for pow() function

It is a more search-friendly alternative to the ^ operator.

Stefano Sabatini authored on 2011/06/06 22:00:25
Showing 3 changed files
... ...
@@ -79,6 +79,10 @@ Compute the square root of @var{expr}. This is equivalent to
79 79
 
80 80
 @item not(expr)
81 81
 Return 1.0 if @var{expr} is zero, 0.0 otherwise.
82
+
83
+@item pow(x, y)
84
+Compute the power of @var{x} elevated @var{y}, it is equivalent to
85
+"(@var{x})^(@var{y})".
82 86
 @end table
83 87
 
84 88
 Note that:
... ...
@@ -41,7 +41,7 @@
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 51
43 43
 #define LIBAVUTIL_VERSION_MINOR  6
44
-#define LIBAVUTIL_VERSION_MICRO  0
44
+#define LIBAVUTIL_VERSION_MICRO  1
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
47 47
                                                LIBAVUTIL_VERSION_MINOR, \
... ...
@@ -290,6 +290,7 @@ static int parse_primary(AVExpr **e, Parser *p)
290 290
     else if (strmatch(next, "trunc" )) d->type = e_trunc;
291 291
     else if (strmatch(next, "sqrt"  )) d->type = e_sqrt;
292 292
     else if (strmatch(next, "not"   )) d->type = e_not;
293
+    else if (strmatch(next, "pow"   )) d->type = e_pow;
293 294
     else {
294 295
         for (i=0; p->func1_names && p->func1_names[i]; i++) {
295 296
             if (strmatch(next, p->func1_names[i])) {
... ...
@@ -643,6 +644,10 @@ int main(void)
643 643
         "not(1)",
644 644
         "not(NAN)",
645 645
         "not(0)",
646
+        "pow(0,1.23)",
647
+        "pow(PI,1.23)",
648
+        "PI^1.23",
649
+        "pow(-1,1.23)",
646 650
         NULL
647 651
     };
648 652