Results 1 to 4 of 4

Math Help - Flop counting

  1. #1
    Junior Member
    Joined
    Aug 2008
    Posts
    44

    Flop counting

    I need to know how many flops does this code have and where

    function s=kahan(x)
    n=length(x); sm=0; dif=0;
    for k=1:n;
    y=x(k)-dif;
    temp=sm;
    sm=temp+y;
    dif=(sm-temp) - y;
    end
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie Grich's Avatar
    Joined
    Aug 2008
    From
    Sydney
    Posts
    12
    first, what language is it?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Grich View Post
    first, what language is it?
    Matlab

    RonL
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Juancd08 View Post
    I need to know how many flops does this code have and where

    function s=kahan(x)
    n=length(x); sm=0; dif=0;
    for k=1:n;
    y=x(k)-dif;
    temp=sm;
    sm=temp+y;
    dif=(sm-temp) - y;
    end
    There are 3 fp assignments before the loop, and an, then for each itteration of the loop there are 4 assignments and 4 additions, plus whatever overhead there is for the loop increment and test.

    So the flpop count is approximatly 4n possibly as much as 5n.

    Of course this function does nothing as the return value is never assigned.

    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. counting 1
    Posted in the Statistics Forum
    Replies: 1
    Last Post: September 8th 2011, 09:01 AM
  2. odds of having a flop in poker with at least 10 or higher
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: May 1st 2011, 11:32 AM
  3. Counting
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: May 9th 2010, 05:34 AM
  4. Counting
    Posted in the Algebra Forum
    Replies: 2
    Last Post: August 10th 2009, 06:32 PM
  5. Replies: 5
    Last Post: February 21st 2009, 10:54 AM

Search Tags


/mathhelpforum @mathhelpforum