Rewrite Rulesphysics/diagonalmatrix-to-dmat

physics/diagonalmatrix-to-dmat

Collapse diagonalmatrix to the shorter dmat helper.

Rewrite patterns#

  1. diagonalmatrix-braced\diagonalmatrix{#1}\dmat{#1}
  2. diagonalmatrix-bare\diagonalmatrix\dmat

Examples#

Each example shows this rule applied in isolation. A complete normalization profile may make additional changes.

dmat diagonal spectrum#

Before

D=\mqty(\diagonalmatrix{\lambda_1,\lambda_2,\lambda_3})

After this rule

D=\mqty(\dmat{\lambda_1,\lambda_2,\lambda_3})

Rendering verified with the declared packages.

dmat bare no elements#

Before

D_0=\mqty(\diagonalmatrix)

After this rule

D_0=\mqty(\dmat)

Rendering verified with the declared packages.

Same family#

Notes#

Alias rewrite: diagonalmatrix and dmat share the same physics DiagonalMatrix handler and argspec, so the braced and bare forms are preserved by renaming the command.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["physics/diagonalmatrix-to-dmat"])
new TransformEngine({ profile: 'corpus', disableRules: ['physics/diagonalmatrix-to-dmat'] })

Open in Playground