column-major-order

How to keep major-order when copying or groupby-ing a pandas DataFrame?

寵の児 提交于 2021-01-28 07:02:56
问题 How can I use or manipulate (monkey-patch) pandas in order, to keep always the same major-order on the resulting object for copy and groupby aggregations? I use pandas.DataFrame as datastructure within a business application (risk model) and need fast aggregation of multidimensional data. Aggregation with pandas depends crucially on the major-ordering scheme in use on the underlying numpy array. Unfortunatly, pandas (version 0.23.4) changes the major-order of the underlying numpy array when I

Using Gatherv for 2d Arrays in Fortran

我与影子孤独终老i 提交于 2020-01-14 02:02:28
问题 I have a number of 2d arrays of size = (2,9) on different processes, which I want to concatenate using MPI_Gatherv in a global array of size = (2*nProcs,9) on the root process. For this I'm trying to adapt this post: Sending 2D arrays in Fortran with MPI_Gather But I do really understand what they are doing and my example isn't working: program testing use mpi implicit none integer(4), allocatable :: local(:,:) integer(4), allocatable :: global(:,:), displs(:), counts(:) integer(4) :: me,

Python row major to column major order vector

こ雲淡風輕ζ 提交于 2019-12-17 20:27:32
问题 Having a matrix like ma = [[0.343, 0.351, 0.306], [0.145, 0.368, 0.487]] I want to get a vector like: [0.343, 0.145, 0.351, 0.368, 0.306, 0.487] To try to get it, I am using numpy and reshape but it is not working. a = np.array(ma) >>> print a.shape (2, 3) But I am getting: c = a.reshape(3, 2, order='F') >>> print c array([[ 0.343, 0.368], [ 0.145, 0.306], [ 0.351, 0.487]]) What would be the best way to do it for any matrix size? I mean, for example, if matrix is not squared like: [[0.404, 0

Using Gatherv for 2d Arrays in Fortran

烈酒焚心 提交于 2019-12-06 10:09:40
I have a number of 2d arrays of size = (2,9) on different processes, which I want to concatenate using MPI_Gatherv in a global array of size = (2*nProcs,9) on the root process. For this I'm trying to adapt this post: Sending 2D arrays in Fortran with MPI_Gather But I do really understand what they are doing and my example isn't working: program testing use mpi implicit none integer(4), allocatable :: local(:,:) integer(4), allocatable :: global(:,:), displs(:), counts(:) integer(4) :: me, nProcs, ierr, i integer(4), parameter :: root = 3 integer :: loc_size(2), glob_size(2), newtype, int_size,

what causes different in array sum along axis for C versus F ordered arrays in numpy

纵然是瞬间 提交于 2019-12-01 10:18:59
问题 I am curious if anyone can explain what exactly leads to the discrepancy in this particular handling of C versus Fortran ordered arrays in numpy . See the code below: system: Ubuntu 18.10 Miniconda python 3.7.1 numpy 1.15.4 def test_array_sum_function(arr): idx=0 val1 = arr[idx, :].sum() val2 = arr.sum(axis=(1))[idx] print('axis sums:', val1) print(' ', val2) print(' equal:', val1 == val2) print('total sum:', arr.sum()) n = 2_000_000 np.random.seed(42) rnd = np.random.random(n) print('Fortran

Python row major to column major order vector

本小妞迷上赌 提交于 2019-11-28 12:38:27
Having a matrix like ma = [[0.343, 0.351, 0.306], [0.145, 0.368, 0.487]] I want to get a vector like: [0.343, 0.145, 0.351, 0.368, 0.306, 0.487] To try to get it, I am using numpy and reshape but it is not working. a = np.array(ma) >>> print a.shape (2, 3) But I am getting: c = a.reshape(3, 2, order='F') >>> print c array([[ 0.343, 0.368], [ 0.145, 0.306], [ 0.351, 0.487]]) What would be the best way to do it for any matrix size? I mean, for example, if matrix is not squared like: [[0.404, 0.571, 0.025], [0.076, 0.694, 0.230], [0.606, 0.333, 0.061], [0.595, 0.267, 0.138]] I would like to get: