Magnetic forces between arrays of cylindrical permanent magnets