| 1369 | walk(e.ops[0], inv); |
| 1370 | return; |
| 1371 | } |
| 1372 | // unit factors regenerate the same product after canonical mul |
| 1373 | // (1/(d·w) → [1, d⁻¹, w⁻¹] → pull 1 → rest re-canonicalizes to u) — |
| 1374 | // skip them in either position |
| 1375 | if (e.isSame(1)) return; |
| 1376 | if (!inv) { |
| 1377 | out.push(e); |
| 1378 | return; |
| 1379 | } |
| 1380 | if (e.operator === 'Power' && e.ops) |
| 1381 | out.push(ce._fn('Power', [e.ops[0], e.ops[1].neg()])); |
| 1382 | else out.push(ce._fn('Power', [e, ce.NegativeOne])); |
| 1383 | }; |
| 1384 | walk(u, false); |
| 1385 | return out; |
| 1386 | } |
| 1387 | |
| 1388 | const productOf = (ce: ComputeEngine, fs: Expression[]): Expression => |
| 1389 | fs.length === 0 |