cumsum

Hello

I want to generate a vector that is the cumulative sum of another vector without using a loop. My vector is more than 10 ^ 6 length and a loop takes forever. I use cumsum in matlab, but could not find something similar in labview.

Thank you!

It works for a 1 d of 1 million items table... you need to mod a little for a 2d array but it takes hardly any time at all to run. You must have an inefficiency in your code. If you make columns or lines, I can mod a bit for you, but you should try it on your own first using this example.

Tags: NI Software

Similar Questions

  • multiple windows

    I have a question about the terms of fenestration.
    Given a simple table abc (id integer, integer id_size) with values like
    1 17
    2 117
    3 0
    4 100
    ...

    My question is: would you please give me all the min (id) where the sum (id_size) > n * 100.
    So for the values indicated above, the result would be 2 4...

    My first approach was this:
    with get_cumsum as
    (select id, id_size, sum (id_size) more
    (order by id lines between unlimited above and the current line) CumSum of ABC)
    Select min (id) in the get_cumsum where cumsum > UNION 100
    Select min (id) in the get_cumsum where cumsum > union 200
    ...

    But unfortunately I do not know in advance up to what amount will my data.

    Are there any ideas how to solve this problem (both in Oracle 11 and Oracle 9).
    Thanks for your help, Hannes

    Hello

    Use GROUP BY aggregation: it is how many groups there is and gives you a separate result for each of them.

    WITH  s  AS
    (
        ...  -- Your original query
    )
    SELECT    100 * FLOOR (comsum / 100)  AS grp_num
    ,         MIN (id)
    FROM      s
    GROUP BY  FLOOR (comsum / 100)
    ORDER BY  FLOOR (comsum / 100);
    

    Or calculate

    100 * FLOOR (comsum / 100) AS grp_num
    

    in a second subquery and use grp_num of the main request.

Maybe you are looking for