function to add complex matrices using a mapping function