# physics/diagonalmatrix-to-dmat

Collapse diagonalmatrix to the shorter dmat helper.

https://texform.dev/rules/physics/diagonalmatrix-to-dmat

## Metadata

| Field | Value |
| --- | --- |
| Key | physics/diagonalmatrix-to-dmat |
| Level | authoring |
| Fidelity | render |
| Enabled by packages | physics |
| Profiles | Authoring, Faithful, Corpus, Equiv |

## Rewrite patterns

### diagonalmatrix-braced

From:

```latex
\diagonalmatrix{#1}
```

To:

```latex
\dmat{#1}
```

### diagonalmatrix-bare

From:

```latex
\diagonalmatrix
```

To:

```latex
\dmat
```

## Examples

Examples show the rule in isolation, not a complete normalization profile.

### dmat diagonal spectrum

Before:

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

After this rule:

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

Packages: base, physics.

Rendering verified with the declared packages.

### dmat bare no elements

Before:

```latex
D_0=\mqty(\diagonalmatrix)
```

After this rule:

```latex
D_0=\mqty(\dmat)
```

Packages: base, physics.

Rendering verified with the declared packages.

## Triggers

- [\\diagonalmatrix](https://texform.dev/latex/commands/diagonalmatrix)

## Eliminates

- [\\diagonalmatrix](https://texform.dev/latex/commands/diagonalmatrix)

## Produces

- [\\dmat](https://texform.dev/latex/commands/dmat)

## Same family

- [ams/Bmatrix-env-to-brace-matrix](https://texform.dev/rules/ams/Bmatrix-env-to-brace-matrix): Rewrite the fenced Bmatrix environment to explicit braces around a core matrix environment.
- [ams/Vmatrix-env-to-Vert-matrix](https://texform.dev/rules/ams/Vmatrix-env-to-Vert-matrix): Rewrite the fenced Vmatrix environment to explicit double bars around a core matrix environment.
- [ams/bmatrix-env-to-bracket-matrix](https://texform.dev/rules/ams/bmatrix-env-to-bracket-matrix): Rewrite the fenced bmatrix environment to explicit brackets around a core matrix environment.
- [ams/pmatrix-env-to-paren-matrix](https://texform.dev/rules/ams/pmatrix-env-to-paren-matrix): Rewrite the fenced pmatrix environment to explicit parens around a core matrix environment.
- [ams/vmatrix-env-to-vert-matrix](https://texform.dev/rules/ams/vmatrix-env-to-vert-matrix): Rewrite the fenced vmatrix environment to explicit vertical bars around a core matrix environment.
- [base/cases-to-cases-env](https://texform.dev/rules/base/cases-to-cases-env): Rewrite plain-TeX cases to the standard cases environment with row breaks.
- [base/eqalign-to-aligned-env](https://texform.dev/rules/base/eqalign-to-aligned-env): Rewrite eqalign to the standard aligned environment.
- [base/eqalignno-to-align-env](https://texform.dev/rules/base/eqalignno-to-align-env): Rewrite eqalignno to the standard align* environment.
- [base/matrix-to-matrix-env](https://texform.dev/rules/base/matrix-to-matrix-env): Rewrite plain-TeX matrix to the standard matrix environment with row breaks.
- [base/pmatrix-to-pmatrix-env](https://texform.dev/rules/base/pmatrix-to-pmatrix-env): Rewrite plain-TeX pmatrix to the standard pmatrix environment with row breaks.
- [physics/antidiagonalmatrix-to-admat](https://texform.dev/rules/physics/antidiagonalmatrix-to-admat): Collapse antidiagonalmatrix to the shorter admat helper.
- [physics/matrixdeterminant-to-mdet](https://texform.dev/rules/physics/matrixdeterminant-to-mdet): Collapse matrixdeterminant to the shorter mdet determinant helper.
- [physics/bmqty-to-mqty](https://texform.dev/rules/physics/bmqty-to-mqty): Expand bmqty to the core mqty builder with bracket fence syntax.
- [physics/mdet-to-vmqty](https://texform.dev/rules/physics/mdet-to-vmqty): Expand mdet to the vmqty determinant-style builder.
- [physics/pmqty-to-mqty](https://texform.dev/rules/physics/pmqty-to-mqty): Expand pmqty to the core mqty builder with paren fence syntax.
- [physics/zmat-to-xmat](https://texform.dev/rules/physics/zmat-to-xmat): Expand zmat to the explicit xmat zero-filled builder.

## 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

```python
TransformEngine(profile="corpus", disable_rules=["physics/diagonalmatrix-to-dmat"])
```

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

[Open in Playground](https://play.texform.dev/?input=D%3D%5Cmqty%28%5Cdiagonalmatrix%7B%5Clambda_1%2C%5Clambda_2%2C%5Clambda_3%7D%29)
