accumulate

XSLT accumulate

跟風遠走 提交于 2019-12-11 03:00:52
问题 I have a parent variable and two child variables for accumulate I would like to use those two child variables to select two different values I can only hardcode it to make it works like all other tutorial for example: $parent[1]/Price and $parent[1]/Quantity but insteads I want the following: $parent[1]/$child1 where $parent[1] = orders[1]/order and $child1 = price $parent[1]/$child2 where $parent[1] = orders[1]/order and $child2 = quantity <xsl:call-template name="total"> <xsl:with-param

How to accumulate data-sets?

邮差的信 提交于 2019-12-10 15:18:51
问题 I have vector with values between 1 and N > 1 . Some values COULD occur multiple times consecutively. Now I want to have a second row which counts the consecutively entries and remove all those consecutively occuring entries, e.g.: A = [1 2 1 1 3 2 4 4 1 1 1 2]' would lead to: B = [1 1; 2 1; 1 2; 3 1; 2 1; 4 2; 1 3; 2 1] (you see, the second column contains the number of consecutively entries! I came across accumarray() in MATLAB recently but I can't find any solution with it for this task

How to fold/accumulate a numpy matrix product (dot)?

会有一股神秘感。 提交于 2019-12-07 10:09:04
问题 With using python library numpy, it is possible to use the function cumprod to evaluate cumulative products, e.g. a = np.array([1,2,3,4,2]) np.cumprod(a) gives array([ 1, 2, 6, 24, 48]) It is indeed possible to apply this function only along one axis. I would like to do the same with matrices (represented as numpy arrays), e.g. if I have S0 = np.array([[1, 0], [0, 1]]) Sx = np.array([[0, 1], [1, 0]]) Sy = np.array([[0, -1j], [1j, 0]]) Sz = np.array([[1, 0], [0, -1]]) and b = np.array([S0, Sx,

How to fold/accumulate a numpy matrix product (dot)?

☆樱花仙子☆ 提交于 2019-12-05 16:19:45
With using python library numpy, it is possible to use the function cumprod to evaluate cumulative products, e.g. a = np.array([1,2,3,4,2]) np.cumprod(a) gives array([ 1, 2, 6, 24, 48]) It is indeed possible to apply this function only along one axis. I would like to do the same with matrices (represented as numpy arrays), e.g. if I have S0 = np.array([[1, 0], [0, 1]]) Sx = np.array([[0, 1], [1, 0]]) Sy = np.array([[0, -1j], [1j, 0]]) Sz = np.array([[1, 0], [0, -1]]) and b = np.array([S0, Sx, Sy, Sz]) then I would like to have a cumprod -like function which gives np.array([S0, S0.dot(Sx), S0

column vector with row means — with std::accumulate?

左心房为你撑大大i 提交于 2019-12-04 08:36:29
In an effort to be as lazy as possible I read in a matrix as vector< vector<double> > data ( rows, vector<double> ( columns ) ); and try to use as many STL goodies as I can. One thing I need to do next is to compute the row means. In C-style programming that would be vector<double> rowmeans( data.size() ); for ( int i=0; i<data.size(); i++ ) for ( int j=0; j<data[i].size(); j++ ) rowmeans[i] += data[i][j]/data[i].size(); In In C++, how to compute the mean of a vector of integers using a vector view and gsl_stats_mean? it is explained that for a vector of numbers you can compute a vector mean

Is it possible to use std::accumulate with std::min?

邮差的信 提交于 2019-12-03 11:08:46
问题 I am trying to combine std::accumulate with std::min . Something like this (won't compile): vector<int> V{2,1,3}; cout << accumulate(V.begin()+1, V.end(), V.front(), std::min<int>); Is it possible? Is it possible to do without writing wrapper functor for std::min ? I know that I can do this with lambdas: vector<int> V{2,1,3}; cout << std::accumulate( V.begin()+1, V.end(), V.front(), [](int a,int b){ return min(a,b);} ); And I know there is std::min_element . I am not trying to find min

Is it possible to use std::accumulate with std::min?

只愿长相守 提交于 2019-12-03 01:36:11
I am trying to combine std::accumulate with std::min . Something like this (won't compile): vector<int> V{2,1,3}; cout << accumulate(V.begin()+1, V.end(), V.front(), std::min<int>); Is it possible? Is it possible to do without writing wrapper functor for std::min ? I know that I can do this with lambdas: vector<int> V{2,1,3}; cout << std::accumulate( V.begin()+1, V.end(), V.front(), [](int a,int b){ return min(a,b);} ); And I know there is std::min_element . I am not trying to find min element, I need to combine std::accumulate with std::min (or ::min ) for my library which allows function

Implementing “Accumulate” Function in Scheme

荒凉一梦 提交于 2019-12-02 16:49:55
问题 I've been hung on trying to implement an Accumulate function for a couple weeks, now. I have properly implemented a "Map" function, that iterates across a list and runs a function on each element. I am using this function to implement "Accumulate" (define accumulate (lambda (op base func ls) (if(null? ls) ls (cond (not (null? (cdr ls)) (op base (map func ls) (accumulate op base func (cdr ls)))) (op base (map func ls) (op base (func(car ls)))) ) ))) ;It gets to a point (the last element) after

pandas - cumulative median

痞子三分冷 提交于 2019-12-02 01:19:27
I was wondering if there is any pandas equivalent to cumsum() or cummax() etc. for median: e.g. cummedian() . So that if I have, for example this dataframe: a 1 5 2 7 3 6 4 4 what I want is something like: df['a'].cummedian() which should output: 5 6 6 5.5 You can use expanding.median - df.a.expanding().median() 1 5.0 2 6.0 3 6.0 4 5.5 Name: a, dtype: float64 Timings df = pd.DataFrame({'a' : np.arange(1000000)}) %timeit df['a'].apply(cummedian()) 1 loop, best of 3: 1.69 s per loop %timeit df.a.expanding().median() 1 loop, best of 3: 838 ms per loop The winner is expanding.median by a huge

numpy.bitwise_and.reduce behaving unexpectedly?

两盒软妹~` 提交于 2019-12-01 07:32:40
问题 The ufunc.reduce for numpy.bitwise_and.reduce does not appear to behave properly... am I misusing it? >>> import numpy as np >>> x = [0x211f,0x1013,0x1111] >>> np.bitwise_or.accumulate(x) array([ 8479, 12575, 12575]) >>> np.bitwise_and.accumulate(x) array([8479, 19, 17]) >>> '%04x' % np.bitwise_or.reduce(x) '311f' >>> '%04x' % np.bitwise_and.reduce(x) '0001' The result of reduce() should be the last value of accumulate() and it's not. What am I missing here? For the moment, I can work around