9.3 Array functions

mpi_sum( x)

Sum elements of array x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_sum.py
[0] : [0 1 2]
[1] : [3 4 5]
[0] : 15
[1] : 15

mpi_min( x)

Minimum element of array x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_minmax.py
[0] : [0 1 2]
[1] : [3 4 5]
[0] : min= 0
[1] : min= 0
[0] : max= 5

mpi_max( x)

Maximum element of array x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_minmax.py
[0] : [0 1 2]
[1] : [3 4 5]
[0] : min= 0
[1] : min= 0
[0] : max= 5

mpi_mean( x)

Mean of elements of array x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_mean.py
[0] : [ 0.  1.  2.]
[1] : [ 3.  4.  5.]
[0] : mean= 2.5
[1] : mean= 2.5

mpi_len( x)

Lenght of array x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_len.py
[0] : [0 1 2]
[1] : [3 4 5]
[0] : len= 6
[1] : len= 6

mpi_arange( n)

Create an integer array containing elements from 0 to n spreaded over all nodes.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_arange.py
[0] : [10 11 12 13 14 15 16 17 18 19]
[1] : [0 1 2 3 4 5 6 7 8 9]

mpi_arange( nall)

Create an integer array containing elements from 0 to n spreaded over all nodes. The repartition of elements and type of elements over nodes is given by the array nall.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_sarange.py
[0] : [ 5  6  8  9 10]
[1] : [0 1 2 3 4 7]

mpi_argmax( x)

Find arument of the maximum value in x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
\begin{verbatim}
[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
[0] : [3 0 4]
[1] : [2 5 6]
[0] : (0, 1)
[1] : (0, 1)
[0] : (1, 2)
[1] : (1, 2)
[0] : 0
[1] : 0
[0] : 6
[1] : 6

mpi_argmin( x)

Find arument of the mimimum value in x.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
\begin{verbatim}
[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
[0] : [3 0 4]
[1] : [2 5 6]
[0] : (0, 1)
[1] : (0, 1)
[0] : (1, 2)
[1] : (1, 2)
[0] : 0
[1] : 0
[0] : 6
[1] : 6

mpi_getval( x,idx)

Return the value of array x corresponding to the index idx.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
\begin{verbatim}
[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_argfind.py
[0] : [3 0 4]
[1] : [2 5 6]
[0] : (0, 1)
[1] : (0, 1)
[0] : (1, 2)
[1] : (1, 2)
[0] : 0
[1] : 0
[0] : 6
[1] : 6

mpi_histogram( x,binx)

Return an histogram of vector x binned using binx.

[lunix@lunix ~/examples]$ mpirun -np 2 python scripts/mpi_histogram.py
[0] : [ 0.84406817  0.36298877  0.97603917  0.93461412  0.79251379
  0.34625384  0.68936312  0.34766984  0.00754931  0.18829931]
[1] : [ 0.84404922  0.59192866  0.99656236  0.06286281  0.48847792
  0.51723957  0.44006979  0.10298632  0.3450942   0.56593537]
[0] : [ 0.    0.25  0.5   0.75]
[1] : [ 0.    0.25  0.5   0.75]
[0] : [4 6 4 6]
[1] : [4 6 4 6]

See About this document... for information on suggesting changes.