Is there any way to speed this elementwise expression up?

Discussion in 'MATLAB' started by Mariano, Dec 25, 2009.

  1. Mariano

    Mariano Guest

    Hi, Maybe you can help me with this expression

    P = A.*exp(-B*lambda);

    where lambda is a positive real scalar, A and B are both real and
    positive vectors of size= 1800x1.
    Right now, about 360K calls of P take ~20 secs. Is there any way to
    speed it up or is this as good as it gets?
    Thanks!


    Mariano
     
    Mariano, Dec 25, 2009
    #1
    1. Advertisements

  2. Mariano

    vortse a Guest

    Perhaps if you have no further need for either A or B, perform an inplace computation, in order to save time from allocating memory to a new variable
     
    vortse a, Dec 25, 2009
    #2
    1. Advertisements

  3. Also I wonder if you are changing B on every run, otherwise you could save exp(-B.*Lambda)
     
    Matt Fetterman, Dec 25, 2009
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.