loops - Python: Partial sum of a set in a matrix by columns -


i have 2 large matrices (1800l;1800c), epeq , triax, have columns like:

epeq=
0
1
1
2
1
0
3
3
1
1
0
2
1
1
1

triax=
-1
1
3
1
-2
-3
-1
1
2
3
2
1
-1
-3
-1
1

as can see, triax columns have cycles of positive , negative elements. want cumulative sum in epeq in beginning of each cycle in triax , value stay constant during cycle, this:

epeq_cr=
0
1
1
1
1
1
1
11
11
11
11
11
11
11
11
17

and apply procedure columns of epeq matrix. have code miss.

epeq_cr = np.copy(epeq) g in range(1,len(epeq_cr)):     h in range(len(epeq_cr[g])):         if (triax[g-1][h]<0 , triax[g][h]>0):             epeq_cr[g][h] = np.cumsum()... 

i've run out of time @ i'd start figuring out cycles start in triax:

epeq = np.array([1, 1, 2, 1, 0, 3, 3, 1, 1, 0, 2, 1, 1, 1]) triax = np.array([-1, 1, 3, 1, -2, -3, -1, 1, 2, 3, 2, 1, -1, -3, -1, 1])  t_shift = np.roll(triax, 1) t_shift[0] = 0 cycle_starts = np.argwhere((triax > 0) & (t_shift < 0)).flatten() array([ 1,  7, 15]) 

so position, i, in epeq_cr need find largest number less in cycle_starts , sum(epeq[:position]).


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -