// Copyright 2015-2023 The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0

= Math Test

This file (vkmath.adoc) contains all the latexmath blocks and inlines in the
Vulkan spec and style guide, so we can see how they are rendered with
different methods and output formats.

== File chapters/fundamentals.adoc

=== latexmath block 1

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = { c \over { 2^b - 1 } }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 2

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = \max\left( {c \over {2^{b-1} - 1}}, -1.0 \right)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

== File chapters/interfaces.adoc

=== latexmath inline 1

latexmath:[(x,y,z,\frac{1}{w})]

=== latexmath inline 2

latexmath:[\frac{1}{w}]

== File chapters/primsrast.adoc

=== latexmath block 3

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
s = {1 \over 2} + { \left( x_p - x_f \right) \over \text{size} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
t = {1 \over 2} + { \left( y_p - y_f \right) \over \text{size} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 4

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
t = {{( \mathbf{p}_r - \mathbf{p}_a ) \cdot ( \mathbf{p}_b - \mathbf{p}_a )}
    \over {\| \mathbf{p}_b - \mathbf{p}_a \|^2 }}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 5

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = {{ (1-t) {f_a / w_a} + t { f_b / w_b} } \over
    {(1-t) / w_a + t / w_b }}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 6

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a = -{1 \over 2}\sum_{i=0}^{n-1}
      x_f^i y_f^{i \oplus 1} -
      x_f^{i \oplus 1} y_f^i
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath inline 3

latexmath:[x_f^i] and latexmath:[y_f^i]

=== latexmath block 7

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a = {{\mathrm{A}(p p_b p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad
b = {{\mathrm{A}(p p_a p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad
c = {{\mathrm{A}(p p_a p_b)} \over {\mathrm{A}(p_a p_b p_c)}},
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 8

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = { a {f_a / w_a} + b {f_b / w_b} + c {f_c / w_c} } \over
    { {a / w_a} + {b / w_b} + {c / w_c} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

== File chapters/fundamentals.adoc

=== latexmath block 9

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = { c \over { 2^b - 1 } }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 10

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = \max\left( {c \over {2^{b-1} - 1}}, -1.0 \right)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

== File chapters/interfaces.adoc

=== latexmath inline 4

latexmath:[(x,y,z,\frac{1}{w})]

=== latexmath inline 5

latexmath:[\frac{1}{w}].

== File chapters/primsrast.adoc

=== latexmath block 11

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
s = {1 \over 2} + { \left( x_p - x_f \right) \over \text{size} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
t = {1 \over 2} + { \left( y_p - y_f \right) \over \text{size} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 12

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
t = {{( \mathbf{p}_r - \mathbf{p}_a ) \cdot ( \mathbf{p}_b - \mathbf{p}_a )}
    \over {\| \mathbf{p}_b - \mathbf{p}_a \|^2 }}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 13

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = {{ (1-t) {f_a / w_a} + t { f_b / w_b} } \over
    {(1-t) / w_a + t / w_b }}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 14

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a = -{1 \over 2}\sum_{i=0}^{n-1}
      x_f^i y_f^{i \oplus 1} -
      x_f^{i \oplus 1} y_f^i
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath inline 6

latexmath:[x_f^i] and latexmath:[y_f^i]

=== latexmath block 15

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
a = {{\mathrm{A}(p p_b p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad
b = {{\mathrm{A}(p p_a p_c)} \over {\mathrm{A}(p_a p_b p_c)}}, \quad
c = {{\mathrm{A}(p p_a p_b)} \over {\mathrm{A}(p_a p_b p_c)}},
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 16

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = { a {f_a / w_a} + b {f_b / w_b} + c {f_c / w_c} } \over
    { {a / w_a} + {b / w_b} + {c / w_c} }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 17

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = \sum_{i=1}^{n} a_i f_i
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath inline 7

latexmath:[\sum_{i=1}^{n}a_i = 1].

=== latexmath block 18

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
m = \sqrt{ \left({{\partial z_f} \over {\partial x_f}}\right)^2
        +  \left({{\partial z_f} \over {\partial y_f}}\right)^2}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 19

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
m = \max\left( \left| {{\partial z_f} \over {\partial x_f}} \right|,
               \left| {{\partial z_f} \over {\partial y_f}} \right| \right)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 20

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
o =
\begin{cases}
    m \times depthBiasSlopeFactor +
         r \times depthBiasConstantFactor  & depthBiasClamp = 0\ or\ NaN \\
    \min(m \times depthBiasSlopeFactor +
         r \times depthBiasConstantFactor,
         depthBiasClamp)                   & depthBiasClamp > 0  \\
    \max(m \times depthBiasSlopeFactor +
         r \times depthBiasConstantFactor,
         depthBiasClamp)                   & depthBiasClamp < 0  \\
\end{cases}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

== File chapters/tessellation.adoc

=== latexmath inline 8

latexmath:[\frac{1}{n}, \frac{2}{n}, \ldots, \frac{n-1}{n}]

== File chapters/textures.adoc

=== latexmath block 21

[latexmath]
+++++++++++++++++++
\begin{aligned}
N               & = 9  & \text{number of mantissa bits per component} \\
B               & = 15 & \text{exponent bias} \\
E_{max}         & = 31 & \text{maximum possible biased exponent value} \\
sharedexp_{max} & = \frac{(2^N-1)}{2^N} \times 2^{(E_{max}-B)}
\end{aligned}
+++++++++++++++++++

=== latexmath block 22

[latexmath]
+++++++++++++++++++
\begin{aligned}
exp' =
  \begin{cases}
    \left \lfloor \log_2(max_{clamped}) \right \rfloor + (B+1)
      & \text{for}\  max_{clamped} > 2^{-(B+1)} \\
    0
      & \text{for}\  max_{clamped} \leq 2^{-(B+1)}
  \end{cases}
\end{aligned}
+++++++++++++++++++

=== latexmath block 23

[latexmath]
+++++++++++++++++++
\begin{aligned}
max_{shared} =
\left \lfloor
\frac{max_{clamped}}{2^{(exp'-B-N)}}+\frac{1}{2}
\right \rfloor
\end{aligned}
+++++++++++++++++++

=== latexmath block 24

[latexmath]
+++++++++++++++++++
\begin{aligned}
exp_{shared} =
  \begin{cases}
    exp'   & \text{for}\  0 \leq max_{shared} < 2^N \\
    exp'+1 & \text{for}\  max_{shared} = 2^N
  \end{cases}
\end{aligned}
+++++++++++++++++++

=== latexmath block 25

[latexmath]
+++++++++++++++++++
\begin{aligned}
red_{shared} & =
    \left \lfloor
    \frac{red_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2}
    \right \rfloor \\
green_{shared} & =
    \left \lfloor
    \frac{green_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2}
    \right \rfloor \\
blue_{shared} & =
    \left \lfloor
    \frac{blue_{clamped}}{2^{(exp_{shared}-B-N)}}+ \frac{1}{2}
    \right \rfloor
\end{aligned}
+++++++++++++++++++

=== latexmath block 26

[latexmath]
+++++++++++++++++++
\begin{aligned}
D & = 1.0 &
  \begin{cases}
    D_{ref} \leq D & \text{for LEQUAL}   \\
    D_{ref} \geq D & \text{for GEQUAL}   \\
    D_{ref} < D    & \text{for LESS}     \\
    D_{ref} > D    & \text{for GREATER}  \\
    D_{ref} = D    & \text{for EQUAL}    \\
    D_{ref} \neq D & \text{for NOTEQUAL} \\
    true           & \text{for ALWAYS}   \\
    false          & \text{for NEVER}
  \end{cases} \\
D & = 0.0 & \text{otherwise}
\end{aligned}
+++++++++++++++++++

=== latexmath block 27

[latexmath]
+++++++++++++++++++
\begin{aligned}
C'_{rgba}[R] & =
  \begin{cases}
    C_{rgba}[R] & \text{for RED swizzle}   \\
    C_{rgba}[G] & \text{for GREEN swizzle} \\
    C_{rgba}[B] & \text{for BLUE swizzle}  \\
    C_{rgba}[A] & \text{for ALPHA swizzle} \\
    0           & \text{for ZERO swizzle}  \\
    one         & \text{for ONE swizzle} \\
    C_{rgba}[R] & \text{for IDENTITY swizzle}
  \end{cases}
\end{aligned}
+++++++++++++++++++

=== latexmath block 28

[latexmath]
+++++++++++++++++++
\begin{aligned}
C_{rgba}[R] & \text{is the RED component} \\
C_{rgba}[G] & \text{is the GREEN component} \\
C_{rgba}[B] & \text{is the BLUE component} \\
C_{rgba}[A] & \text{is the ALPHA component} \\
one         & = 1.0\text{f}  & \text{for floating point components} \\
one         & = 1              & \text{for integer components}
\end{aligned}
+++++++++++++++++++

=== latexmath block 29

[latexmath]
+++++++++++++++++++
\begin{aligned}
dPdx_{i_1,j_0} & = dPdx_{i_0,j_0} & = P_{i_1,j_0} - P_{i_0,j_0}  \\
dPdx_{i_1,j_1} & = dPdx_{i_0,j_1} & = P_{i_1,j_1} - P_{i_0,j_1}  \\
\\
dPdy_{i_0,j_1} & = dPdy_{i_0,j_0} & = P_{i_0,j_1} - P_{i_0,j_0}  \\
dPdy_{i_1,j_1} & = dPdy_{i_1,j_0} & = P_{i_1,j_1} - P_{i_1,j_0}
\end{aligned}
+++++++++++++++++++

=== latexmath block 30

[latexmath]
+++++++++++++++++++
\begin{aligned}
dPdx & =
  \begin{cases}
    dPdx_{i_0,j_0} & \text{preferred}\\
    dPdx_{i_0,j_1}
  \end{cases} \\
dPdy & =
  \begin{cases}
    dPdy_{i_0,j_0} & \text{preferred}\\
    dPdy_{i_1,j_0}
  \end{cases}
\end{aligned}
+++++++++++++++++++

=== latexmath block 31

[latexmath]
+++++++++++++++++++
\begin{aligned}
s       & = \frac{s}{q},       & \text{for 1D, 2D, or 3D image} \\
\\
t       & = \frac{t}{q},       & \text{for 2D or 3D image} \\
\\
r       & = \frac{r}{q},       & \text{for 3D image} \\
\\
D_{ref} & = \frac{D_{ref}}{q}, & \text{if provided}
\end{aligned}
+++++++++++++++++++


=== latexmath block 32

[latexmath]
+++++++++++++++++++
\begin{aligned}
\partial{s}/\partial{x} & = dPdx(s), & \partial{s}/\partial{y} & = dPdy(s), & \text{for 1D, 2D, Cube, or 3D image} \\
\partial{t}/\partial{x} & = dPdx(t), & \partial{t}/\partial{y} & = dPdy(t), & \text{for 2D, Cube, or 3D image} \\
\partial{u}/\partial{x} & = dPdx(u), & \partial{u}/\partial{y} & = dPdy(u), & \text{for Cube or 3D image}
\end{aligned}
+++++++++++++++++++

=== latexmath block 33

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
s_{face} & =
    \frac{1}{2} \times \frac{s_c}{|r_c|} + \frac{1}{2} \\
t_{face} & =
    \frac{1}{2} \times \frac{t_c}{|r_c|} + \frac{1}{2} \\
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 34

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\frac{\partial{s_{face}}}{\partial{x}} &=
    \frac{\partial}{\partial{x}} \left ( \frac{1}{2} \times \frac{s_{c}}{|r_{c}|}
    + \frac{1}{2}\right ) \\
\frac{\partial{s_{face}}}{\partial{x}} &=
    \frac{1}{2} \times \frac{\partial}{\partial{x}}
    \left ( \frac{s_{c}}{|r_{c}|}  \right ) \\
\frac{\partial{s_{face}}}{\partial{x}} &=
    \frac{1}{2} \times
    \left (
    \frac{
      |r_{c}| \times \partial{s_c}/\partial{x}
      -s_c \times {\partial{r_{c}}}/{\partial{x}}}
    {\left ( r_{c} \right )^2}
    \right )
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 35

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\frac{\partial{s_{face}}}{\partial{y}} &=
    \frac{1}{2} \times
    \left (
    \frac{
      |r_{c}| \times \partial{s_c}/\partial{y}
      -s_c \times {\partial{r_{c}}}/{\partial{y}}}
    {\left ( r_{c} \right )^2}
    \right )\\
\frac{\partial{t_{face}}}{\partial{x}} &=
    \frac{1}{2} \times
    \left (
    \frac{
      |r_{c}| \times \partial{t_c}/\partial{x}
      -t_c \times {\partial{r_{c}}}/{\partial{x}}}
    {\left ( r_{c} \right )^2}
    \right ) \\
\frac{\partial{t_{face}}}{\partial{y}} &=
    \frac{1}{2} \times
    \left (
    \frac{
       |r_{c}| \times \partial{t_c}/\partial{y}
      -t_c \times {\partial{r_{c}}}/{\partial{y}}}
    {\left ( r_{c} \right )^2}
    \right )
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 36

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\rho_{x} & = \sqrt{ m_{ux} ^{2} + m_{vx} ^{2} + m_{wx} ^{2} } \\
\rho_{y} & = \sqrt{ m_{uy} ^{2} + m_{vy} ^{2} + m_{wy} ^{2} }
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 37

  {empty}:: [eq]#f~x~# is continuous and monotonically increasing in each of
     [eq]#m~ux~#, [eq]#m~vx~#, and [eq]#m~wx~#
  {empty}:: [eq]#f~y~# is continuous and monotonically increasing in each of
     [eq]#m~uy~#, [eq]#m~vy~#, and [eq]#m~wy~#
  {empty}:: [eq]#max({vert}m~ux~{vert}, {vert}m~vx~{vert},
     {vert}m~wx~{vert}) {leq} f~x~ {leq} {vert}m~ux~{vert} {plus}
     {vert}m~vx~{vert} {plus} {vert}m~wx~{vert}#
  {empty}:: [eq]#max({vert}m~uy~{vert}, {vert}m~vy~{vert},
     {vert}m~wy~{vert}) {leq} f~y~ {leq} {vert}m~uy~{vert} {plus}
     {vert}m~vy~{vert} {plus} {vert}m~wy~{vert}#

=== latexmath block 38

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
N & = \min \left (\left \lceil \frac{\rho_{max}}{\rho_{min}}  \right \rceil ,max_{Aniso} \right )
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 39

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\lambda_{base}(x,y) & =
  \begin{cases}
    shaderOp.Lod                                 & \text{(from optional SPIR-V operand)} \\
    \log_2 \left ( \frac{\rho_{max}}{N} \right ) & \text{otherwise}
  \end{cases} \\
\lambda'(x,y)       & = \lambda_{base} + \mathbin{clamp}(sampler.bias + shaderOp.bias,-maxSamplerLodBias,maxSamplerLodBias) \\
\lambda             & =
  \begin{cases}
    lod_{max}, & \lambda' > lod_{max} \\
    \lambda',  & lod_{min} \leq \lambda' \leq lod_{max} \\
    lod_{min}, & \lambda' < lod_{min} \\
    undefined, & lod_{min} > lod_{max} \\
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 40

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
sampler.bias       & = mipLodBias & \text{(from sampler descriptor)} \\
shaderOp.bias      & =
  \begin{cases}
    Bias & \text{(from optional SPIR-V operand)} \\
    0    & \text{otherwise}
  \end{cases} \\
sampler.lod_{min}  & = minLod & \text{(from sampler descriptor)} \\
shaderOp.lod_{min} & =
  \begin{cases}
    MinLod & \text{(from optional SPIR-V operand)} \\
    0      & \text{otherwise}
  \end{cases} \\
\\
lod_{min}          & = \max(sampler.lod_{min}, shaderOp.lod_{min}) \\
lod_{max}          & = maxLod & \text{(from sampler descriptor)}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 41

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
d =
  \begin{cases}
    level_{base},     & \lambda \leq \frac{1}{2} \\[.5em]
    nearest(\lambda), & \lambda > \frac{1}{2},
                        level_{base} + \lambda \leq
                        q + \frac{1}{2} \\[.5em]
    q,                & \lambda > \frac{1}{2},
                        level_{base} + \lambda > q + \frac{1}{2}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 42

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
nearest(\lambda) & =
  \begin{cases}
    \left \lceil level_{base}+\lambda + \frac{1}{2}\right \rceil - 1, &
        \text{preferred} \\
    \left \lfloor level_{base}+\lambda + \frac{1}{2}\right \rfloor,   &
        \text{alternative}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 43

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
d_{hi} & =
  \begin{cases}
    q,                                                 & level_{base} + \lambda \geq q \\
    \left \lfloor level_{base}+\lambda \right \rfloor, & \text{otherwise}
  \end{cases} \\
d_{lo} & =
  \begin{cases}
    q,        & level_{base} + \lambda \geq q \\
    d_{hi}+1, & \text{otherwise}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 44

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
u(x,y) & = s(x,y) \times width_{level} \\
v(x,y) & =
  \begin{cases}
    0                         & \text{for 1D images} \\
    t(x,y) \times height_{level} & \text{otherwise}
  \end{cases} \\
w(x,y) & =
  \begin{cases}
    0                         & \text{for 2D or Cube images} \\
    r(x,y) \times depth_{level}  & \text{otherwise}
  \end{cases} \\
\\
a(x,y) & =
  \begin{cases}
    a(x,y)                    & \text{for array images} \\
    0                         & \text{otherwise}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 45

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\mathbin{RNE}(a) & =
  \begin{cases}
    \mathbin{roundTiesToEven}(a)                  & \text{preferred, from IEEE Std 754-2008 Floating-Point Arithmetic} \\
    \left \lfloor a + \frac{1}{2} \right \rfloor & \text{alternative}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 46

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
i &=
  \begin{cases}
    i \bmod size                                & \text{for repeat} \\
    (size-1) - \mathbin{mirror}
        ((i \bmod (2 \times size)) - size)      & \text{for mirrored repeat} \\
    \mathbin{clamp}(i,0,size-1)                  & \text{for clamp to edge} \\
    \mathbin{clamp}(i,-1,size)                   & \text{for clamp to border} \\
    \mathbin{clamp}(\mathbin{mirror}(i),0,size-1) & \text{for mirror clamp to edge}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++


=== latexmath block 47

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
& \mathbin{mirror}(n) =
  \begin{cases}
    n      & \text{for}\  n \geq 0 \\
    -(1+n) & \text{otherwise}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 48

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau[R] &= \tau_{i0j1}[level_{base}][comp] \\
\tau[G] &= \tau_{i1j1}[level_{base}][comp] \\
\tau[B] &= \tau_{i1j0}[level_{base}][comp] \\
\tau[A] &= \tau_{i0j0}[level_{base}][comp]
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 49

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau[level_{base}][comp] &=
  \begin{cases}
    \tau[level_{base}][R], & \text{for}\  comp = 0 \\
    \tau[level_{base}][G], & \text{for}\  comp = 1 \\
    \tau[level_{base}][B], & \text{for}\  comp = 2 \\
    \tau[level_{base}][A], & \text{for}\  comp = 3
  \end{cases}\\
comp & \,\text{from SPIR-V operand Component}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 50

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau[level] &=
  \begin{cases}
     \tau_{ijk}[level], & \text{for 3D image} \\
     \tau_{ij}[level],  & \text{for 2D or Cube image} \\
     \tau_{i}[level],   & \text{for 1D image}
   \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 51

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau_{3D}[level] & = (1-\alpha)(1-\beta)(1-\gamma)\tau_{i0j0k0}[level] \\
          & \, + (\alpha)(1-\beta)(1-\gamma)\tau_{i1j0k0}[level] \\
          & \, + (1-\alpha)(\beta)(1-\gamma)\tau_{i0j1k0}[level] \\
          & \, + (\alpha)(\beta)(1-\gamma)\tau_{i1j1k0}[level]   \\
          & \, + (1-\alpha)(1-\beta)(\gamma)\tau_{i0j0k1}[level] \\
          & \, + (\alpha)(1-\beta)(\gamma)\tau_{i1j0k1}[level]   \\
          & \, + (1-\alpha)(\beta)(\gamma)\tau_{i0j1k1}[level]   \\
          & \, + (\alpha)(\beta)(\gamma)\tau_{i1j1k1}[level]
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 52

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau_{2D}[level] & = (1-\alpha)(1-\beta)\tau_{i0j0}[level] \\
          & \, + (\alpha)(1-\beta)\tau_{i1j0}[level] \\
          & \, + (1-\alpha)(\beta)\tau_{i0j1}[level] \\
          & \, + (\alpha)(\beta)\tau_{i1j1}[level]
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 53

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau_{1D}[level] & = (1-\alpha)\tau_{i0}[level] \\
          & \, + (\alpha)\tau_{i1}[level]
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 54

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau[level] &=
  \begin{cases}
     \tau_{3D}[level], & \text{for 3D image} \\
     \tau_{2D}[level], & \text{for 2D or Cube image} \\
     \tau_{1D}[level], & \text{for 1D image}
   \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 55

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau &=
  \begin{cases}
    \tau[d], & \text{for mip mode BASE or NEAREST} \\
    (1-\delta)\tau[d_{hi}]+\delta\tau[d_{lo}], & \text{for mip mode LINEAR}
  \end{cases}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 56

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau_{2Daniso} & =
     \frac{1}{N}\sum_{i=1}^{N}
     {\tau_{2D}\left (
       u \left ( x - \frac{1}{2} + \frac{i}{N+1} , y \right ),
         \left ( v \left (x-\frac{1}{2}+\frac{i}{N+1} \right ), y
\right )
     \right )},
     & \text{when}\  \rho_{x} > \rho_{y} \\
\tau_{2Daniso} &=
     \frac{1}{N}\sum_{i=1}^{N}
     {\tau_{2D}\left (
        u \left  ( x, y - \frac{1}{2} + \frac{i}{N+1} \right ),
          \left ( v \left (x,y-\frac{1}{2}+\frac{i}{N+1} \right )
\right )
     \right )},
     & \text{when}\  \rho_{y} \geq \rho_{x}
\end{aligned}
++++++++++++++++++++++++

== File chapters/vertexpostproc.adoc

=== latexmath block 57

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\begin{array}{c}
-w_c \leq x_c \leq w_c \\
-w_c \leq y_c \leq w_c \\
0 \leq z_c \leq w_c
\end{array}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 58

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\left(\begin{array}{c}
x_c \\
y_c \\
z_c \\
w_c
\end{array}\right)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath block 59

[latexmath]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\left(
        \begin{array}{c}
                x_d \\
                y_d \\
                z_d
        \end{array}
\right) =
\left(
        \begin{array}{c}
                \frac{x_c}{w_c} \\
                \frac{y_c}{w_c} \\
                \frac{z_c}{w_c}
        \end{array}
\right)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

=== latexmath inline 12

latexmath:[\frac{k}{2^m - 1}]

== File chapters/VK_IMG_filter_cubic/filter_cubic_texel_filtering.adoc

=== latexmath block 60

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
cinterp(\tau_0, \tau_1, \tau_2, \tau_3, \omega) =
\frac{1}{2}
\begin{bmatrix}1 & \omega & \omega^2 & \omega^3 \end{bmatrix}
\times
\begin{bmatrix}
 0 &  2 &  0 &  0 \\
-1 &  0 &  1 &  0 \\
 2 & -5 &  4 &  1 \\
-1 &  3 & -3 &  1
\end{bmatrix}
\times
\begin{bmatrix}
\tau_0 \\
\tau_1 \\
\tau_2 \\
\tau_3
\end{bmatrix}
\end{aligned}
++++++++++++++++++++++++

=== latexmath block 61

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
\tau[level] &=
  \begin{cases}
     \tau_{2D}[level], & \text{for 2D image} \\
     \tau_{1D}[level], & \text{for 1D image}
   \end{cases}
\end{aligned}
++++++++++++++++++++++++

== File chapters/VK_IMG_filter_cubic/filter_cubic_texel_selection.adoc

=== latexmath block 62

[latexmath]
++++++++++++++++++++++++
\begin{aligned}
i_{0}  & = \left \lfloor u - \frac{3}{2} \right \rfloor & i_{1} & = i_{0} + 1 & i_{2} & = i_{1} + 1 & i_{3} & = i_{2} + 1 \\[1em]
j_{0}  & = \left \lfloor u - \frac{3}{2} \right \rfloor & j_{1} & = j_{0} + 1 & j_{2} & = j_{1} + 1 & j_{3} & = j_{2} + 1 \\
\\
\alpha & = \mathbin{frac} \left ( u - \frac{1}{2} \right ) \\[1em]
\beta  & = \mathbin{frac} \left ( v - \frac{1}{2} \right )
\end{aligned}
++++++++++++++++++++++++

== File style/writing.adoc

=== latexmath inline 13

latexmath:[[0,1\]]

=== latexmath inline 14

latexmath:[\frac{1 - \frac{x}{2}}{x - 1}]

=== latexmath inline 15

latexmath:[\mathbf{c} = t \mathbf{c}_1 + (1-t) \mathbf{c}_2.]

=== latexmath block 63

[latexmath]
+++++++++++++++++++
\begin{aligned}
c_{RGB} & =
  \begin{cases}
    \frac{c_{sRGB}}{12.92}                              & \text{for}\  c_{sRGB} \leq 0.04045 \\
    \left ( \frac{c_{sRGB}+0.055}{1.055} \right )^{2.4} & \text{for}\  c_{sRGB} > 0.04045
  \end{cases}
\end{aligned}
+++++++++++++++++++

=== latexmath block 64

[latexmath]
+++++++++++++++++++
V =
  \begin{cases}
    (-1)^S \times 0.0,                      & E = 0, M = 0     \\
    (-1)^S \times 2^{-14} \times { M \over 2^{10} },
                                            & E = 0,  M \neq 0 \\
    (-1)^S \times 2^{E-15} \times { \left( 1 + { M \over 2^{10} } \right) },
                                            & 0 < E < 31       \\
    (-1)^S \times Inf,             & E = 31, M = 0             \\
    NaN,                           & E = 31, M \neq 0
  \end{cases}
+++++++++++++++++++
