[FFmpeg-devel] [PATCH] eval: Add taylor series evaluation support.

Michael Niedermayer michaelni at gmx.at
Wed Feb 22 17:03:03 CET 2012


On Wed, Feb 22, 2012 at 10:16:25AM +0100, Nicolas George wrote:
> Le tridi 3 ventôse, an CCXX, Michael Niedermayer a écrit :
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  doc/eval.texi    |    7 +++++++
> >  libavutil/eval.c |   20 +++++++++++++++++++-
> >  2 files changed, 26 insertions(+), 1 deletions(-)
> > 
> > diff --git a/doc/eval.texi b/doc/eval.texi
> > index 92fdc6d..b481bfe 100644
> > --- a/doc/eval.texi
> > +++ b/doc/eval.texi
> > @@ -106,6 +106,13 @@ the evaluation of @var{y}, return 0 otherwise.
> >  @item ifnot(x, y)
> >  Evaluate @var{x}, and if the result is zero return the result of the
> >  evaluation of @var{y}, return 0 otherwise.
> > +
> > + at item taylor(expr, x)
> > +Evaluate a taylor series at x.
> > +expr represents the LD(0)-th derivates of f(x) at 0.
> 
> Could the variable id be a parameter too? Maybe optional?

should be possible, ill look into it


> 
> > +note, when you have the derivatives at y instead of 0
> > +taylor(expr, x-y) can be used
> > +When the series does not converge the results are undefined.
> 
> Do you have a practical use case in mind?

not really, it just felt like a important feature that was missing.


> 
> >  @end table
> >  
> >  The following constants are available:
> > diff --git a/libavutil/eval.c b/libavutil/eval.c
> > index 2ee3965..49079c5 100644
> > --- a/libavutil/eval.c
> > +++ b/libavutil/eval.c
> > @@ -134,7 +134,7 @@ struct AVExpr {
> >          e_squish, e_gauss, e_ld, e_isnan,
> >          e_mod, e_max, e_min, e_eq, e_gt, e_gte,
> >          e_pow, e_mul, e_div, e_add,
> > -        e_last, e_st, e_while, e_floor, e_ceil, e_trunc,
> > +        e_last, e_st, e_while, e_taylor, e_floor, e_ceil, e_trunc,
> >          e_sqrt, e_not, e_random, e_hypot, e_gcd,
> >          e_if, e_ifnot,
> >      } type;
> > @@ -181,6 +181,21 @@ static double eval_expr(Parser *p, AVExpr *e)
> >                  d=eval_expr(p, e->param[1]);
> >              return d;
> >          }
> > +        case e_taylor: {
> > +            double t = 1, d = 0, ld, v;
> > +            double x = eval_expr(p, e->param[1]);
> > +            int i;
> > +            for(i=0; i<1000; i++) {
> > +                double ld = d;
> 
> ld is defined twice.

i realized and fixed that a minute after sending the patch


> 
> > +                p->var[0] = i;
> > +                v = eval_expr(p, e->param[0]);
> > +                d += t*v;
> > +                if(ld==d && v)
> > +                    break;
> 
> I am not sure if this test is correct: v could be very small but not zero,
> and be much larger in a future evaluation.

yes, but some end condition is needed.
If you a better idea ...


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120222/e1bf57ca/attachment.asc>


More information about the ffmpeg-devel mailing list