As I can use the "Reduce" function to add 4 matrices copies (diff_table), which were declared using the "zeros" function?. Here my code in SAGE
from mpi4py import MPI from numpy import* comm = MPI.COMM_WORLD rank = comm.rank rol = lambda val, r_bits, max_bits: \ (val << r_bits%max_bits) & (2**max_bits-1) | \ ((val & (2**max_bits-1)) >> (max_bits-(r_bits%max_bits))) ror = lambda val, r_bits, max_bits: \ ((val & (2**max_bits-1)) >> r_bits%max_bits) | \ (val << (max_bits-(r_bits%max_bits)) & (2**max_bits-1)) max_bits = 4 # For fun, try 2, 17 or other arbitrary (positive!) values def functionF(x): return (rol(x, 8, max_bits) & rol(x, 1, max_bits))^(rol(x, 2, max_bits)) diff_table = zeros((2**max_bits,2**max_bits),dtype ='int16') comm.Bcast([diff_table, MPI.DOUBLE], root=0) np = 4 for x1 in range(np*rank,np*rank+4): for dx in range(2**(max_bits)): x2 = x1 ^ dx; dy = functionF(x1) ^ functionF(x2); diff_table[dx,dy] = diff_table[dx,dy]+1; print diff_table #comm.Reduce([diff_table, MPI.DOUBLE], None, op=MPI.SUM, root=0) PROBLEM -- --------------------------------------------------------------------- MSc. Juan del Carmen Grados Vásquez Laboratório Nacional de Computação Científica Tel: +55 24 2233-6260 (http://www.lncc.br/) http://juaninf.blogspot.com --------------------------------------------------------------------- -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.