Skip to content

v0.6.0 — operators: * for composition, % for the direct product

Latest

Choose a tag to compare

@vukics vukics released this 10 Nov 11:23
· 2 commits to main since this release

The operator spelling of #30. Application and its results are unchanged since v0.5.0.

Breaking change

  • composition AB: A * B (was A | B)
  • direct product A⊗B: A % B (was A * B)
  • scalar multiplication: c * A, unchanged

Code that composes with | no longer compiles. A direct product left as A * B fails to compile when the two ranks differ, but between operators of equal rank it now compiles as a composition (and throws if their dimensions differ). Port in two steps, compiling in between: first every direct product to %, then every | to *.

Why

  • Precedence: | binds more loosely than +, - and ==, so A | B + C was A(B+C) and A + B | C was (A+B)C. * and % share multiplicative precedence and associate from left to right, so neither binds silently around a +. A misparse of a mixed expression such as A % B * C % D typically fails to compile, because the ranks don't match; the mixed-product law reads (A % B) * (C % D) == (A * C) % (B * D).
  • Convention: * is the operator product in Eigen, Armadillo, QuTiP and QuantumOptics.jl. C++ has no ⊗, and % keeps an infix form. Unlike Armadillo's %, it is not the element-wise product.

Consumers: request 0.6 (FIND_PACKAGE_ARGS 0.6, find_package(cppqed-multidiagonal 0.6)); an installed 0.6.x doesn't satisfy a request for 0.5 (#9). C++QED pins v0.6.0.