import { anyComplex } from './complex.js' export default function create(pmath) { const complex = pmath('complex') const resolve = pmath.config.resolveComplex return pmath('add', [anyComplex, // naive, but this is just a P-o-C (...addends) => { let sum = complex(addends[0]) for (let i = 1; i < addends.length; ++i) { const addend = complex(addends[i]) sum.re += addend.re sum.im += addend.im } if (resolve && Math.abs(sum.im/sum.re) < 1e-10) return sum.re return sum }], create, pmath) // register ourselves for invalidation and reconfiguration }