# shz_mat4x4_inverse_block_triangular

Source: https://sh4zam.com/api/matrix/shz_mat4x4_inverse_block_triangular/

```c
void shz_mat4x4_inverse_block_triangular(const shz_mat4x4_t* mtx, shz_mat4x4_t* out) SHZ_NOEXCEPT;
```

Computes the inverse of a 4x4 matrix in block-triangular form.

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `mtx` | `const shz_mat4x4_t *` |  |
| `out` | `shz_mat4x4_t *` |  |

## Returns

Nothing (`void`).

## Details

This is a special-case faster optimization for 4x4 matrices which take the form:

```text
A = [ M   b ]
    [ 0   w ]
```

Where A is 4x4, M is 3x3, b is 3x1, and the bottom row is (0, 0, 0, w) with w != 0. For this block-triangular form, det(A) = det(M) \* w. Then

```text
inv(A) = [ inv(M)        -inv(M) * b / w ]
         [   0                 1/w       ]
```

## Notes

- A regular 3D transform matrix is already in this form.
- `shz_mat4x4_inverse()` will dynamically check whether to use this optimization.

## Naming and requirements

- `shz_mat4x4_t` and `shz_mat2x2_t` arguments must be 8-byte aligned. Unaligned data goes through the `float[16]` parameters of the `_unaligned` routines.

## Availability

- **C++ equivalent:** [`shz::mat4x4::inverse_block_triangular`](https://sh4zam.com/api/cpp/mat4x4/#inverse_block_triangular)
- **Type-generic form:** none
- **Back-ends:** SH4: shared C implementation · SW: portable C · SPU: shared C implementation
- **Defined in:** [`sh4zam/shz_matrix.h:844`](https://github.com/gyrovorbis/sh4zam/blob/ba1e30c88d49df0311870b229e1dd860ef26c477/include/sh4zam/shz_matrix.h#L844)
- **Module:** [Matrix](https://sh4zam.com/api/matrix/), section "Miscellaneous"
