PageSourceSearch

https://wgmath.rs/assets/js/2bec942f.9f9aa9e4.js

js wgmath.rs collected 2026-10-06 19:20:19 UTC 48,340 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkrapier=self.webpackChunkrapier||[]).push([[764],{8064:(s,e,a)=>{a.r(e),a.d(e,{assets:()=>h,contentTitle:()=>m,default:()=>x,frontMatter:()=>c,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"user_guides/templates/wgebra/matrix_decompositions","title":"Matrix decompositions","description":"Automatic WGSL docs generation publishable on this website is currently waiting on wgpu#6364.","source":"@site/docs/user_guides/templates/wgebra/matrix_decompositions.mdx","sourceDirName":"user_guides/templates/wgebra","slug":"/user_guides/templates/wgebra/matrix_decompositions","permalink":"/docs/user_guides/templates/wgebra/matrix_decompositions","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"id":"matrix_decompositions","title":"Matrix decompositions","sidebar_label":"Matrix decompositions"}}');var t=a(4848),i=a(8453),l=a(1470),r=a(9365);const c={id:"matrix_decompositions",title:"Matrix decompositions",sidebar_label:"Matrix decompositions"},m=void 0,h={},d=[{value:"Cholesky",id:"cholesky",level:2},{value:"QR",id:"qr",level:2},{value:"LU with partial pivoting",id:"lu-with-partial-pivoting",level:2},{value:"Eigendecomposition (symmetric matrix)",id:"eigendecomposition-symmetric-matrix",level:2},{value:"Singular Value Decomposition",id:"singular-value-decomposition",level:2}];function o(s){const e={a:"a",admonition:"admonition",annotation:"annotation",code:"code",em:"em",h2:"h2",img:"img",math:"math",mi:"mi",mn:"mn",mo:"mo",mrow:"mrow",msup:"msup",mtext:"mtext",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...s.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.admonition,{type:"warning",children:(0,t.jsxs)(e.p,{children:["Automatic WGSL docs generation publishable on this website is currently waiting on ",(0,t.jsx)(e.a,{href:"https://github.com/gfx-rs/wgpu/pull/6364",children:"wgpu#6364"}),".\nIn the meantime, refer to the WGSL sources in the ",(0,t.jsx)(e.a,{href:"https://github.com/dimforge/wgmath/tree/main/crates/wgebra",children:"wgebra repository"}),"."]})}),"\n",(0,t.jsx)(e.p,{children:"Matrix decomposition is a family of techniques that aim to represent a matrix as\nthe product of several matrices. Those factors can either allow more efficient\noperations like inversion or linear system resolution, and might provide some\ninsight regarding intrinsic properties of some data to be analysed (e.g. by\nobserving singular values, eigenvectors, etc.)"}),"\n",(0,t.jsx)(e.admonition,{type:"info",children:(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"WGebra"})," implements common matrix decompositions for low-dimensional matrices (currently ",(0,t.jsx)(e.code,{children:"mat2x2<f32>"}),", ",(0,t.jsx)(e.code,{children:"mat3x3<f32>"}),"\nand ",(0,t.jsx)(e.code,{children:"mat4x4<f32>"}),"). There is no implementation of these decomposition for large matrices yet."]})}),"\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"Decomposition"}),(0,t.jsx)(e.th,{children:"Factors"}),(0,t.jsx)(e.th,{children:"Derivable shaders"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"QR"}),(0,t.jsx)(e.td,{children:(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"Q"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsx)(e.mi,{children:"R"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q ~ R"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.00773em"},children:"R"})]})})]})}),(0,t.jsxs)(e.td,{children:[(0,t.jsx)(e.code,{children:"WgQR2"}),", ",(0,t.jsx)(e.code,{children:"WgQR3"}),", ",(0,t.jsx)(e.code,{children:"WgQR4"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"LU with partial pivoting"}),(0,t.jsx)(e.td,{children:(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"P"}),(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mo,{children:"\u2212"}),(0,t.jsx)(e.mn,{children:"1"})]})]}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsx)(e.mi,{children:"U"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"P^{-1} ~ L ~ U"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8141em"}}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.8141em"}
1,children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsxs)(e.span,{className:"mord mtight",children:[(0,t.jsx)(e.span,{className:"mord mtight",children:"\u2212"}),(0,t.jsx)(e.span,{className:"mord mtight",children:"1"})]})})]})})})})})]}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"})]})})]})}),(0,t.jsxs)(e.td,{children:[(0,t.jsx)(e.code,{children:"WgLU2"}),", ",(0,t.jsx)(e.code,{children:"WgLU3"}),", ",(0,t.jsx)(e.code,{children:"WgLU4"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"Cholesky"}),(0,t.jsx)(e.td,{children:(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"L ~ L^*"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6887em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.6887em"},children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})})]})}),(0,t.jsxs)(e.td,{children:[(0,t.jsx)(e.code,{children:"WgCholesky2"}),", ",(0,t.jsx)(e.code,{children:"WgCholesky3"}),", ",(0,t.jsx)(e.code,{children:"WgCholesky4"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"Symmetric eigendecomposition"}),(0,t.jsx)(e.td,{children:(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"U"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u039b"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"U"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"U ~ \\Lambda ~ U^*"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6887em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsx)(e.span,{className:"mord",children:"\u039b"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.6887em"},children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})})]})}),(0,t.jsxs)(e.td,{children:[(0,t.jsx)(e.code,{children:"WgSymmetricEigen2"}),", ",(0,t.jsx)(e.code,{children:"WgSymmetricEigen3"}),", ",(0,t.jsx)(e.code,{children:"WgSymmetricEigen4"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"SVD (2x2 and 3x3 only)"}),(0,t.jsx)(e.td,{children:(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"U"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u03a3"}),(0,t.jsx)(e.mtext,{children:"\xa0"}),(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"V"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"U ~ \\Sigma ~ V^*"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6887em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsx)(e.span,{className:"mord",children:"\u03a3"}),(0,t.jsx)(e.span,{className:"mspace nobreak",children:"\xa0"}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.22222em"},children:"V"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.6887em"}
1,children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})})]})}),(0,t.jsxs)(e.td,{children:[(0,t.jsx)(e.code,{children:"WgSvd2"}),", ",(0,t.jsx)(e.code,{children:"WgSvd3"})]})]})]})]}),"\n",(0,t.jsx)(e.h2,{id:"cholesky",children:"Cholesky"}),"\n",(0,t.jsxs)(e.p,{children:["The Cholesky decomposition of a ",(0,t.jsx)(e.code,{children:"n \xd7 n"})," Hermitian Definite Positive (SDP) matrix\n",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"M"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"})]})})]})," is composed of a ",(0,t.jsx)(e.code,{children:"n \xd7 n"})," lower-triangular matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"L"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"L"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"})]})})]})," such that ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"M"}),(0,t.jsx)(e.mo,{children:"="}),(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M = LL^*"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"="}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6887em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.6887em"},children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})]})]}),".\nWhere ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"L^*"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6887em"}}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",style:{height:"0.6887em"}
1,children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})})]})," designates the conjugate-transpose of ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"L"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"L"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"})]})})]}),".  If the input matrix is\nnot SDP, such a decomposition does not exist and the matrix method\n",(0,t.jsx)(e.code,{children:".cholesky(...)"})," returns ",(0,t.jsx)(e.code,{children:"None"}),". Note that the input matrix is interpreted as a\nhermitian matrix. Only its lower-triangular part (including the diagonal) is\nread by the Cholesky decomposition (its strictly upper-triangular is never\naccessed in memory). See ",(0,t.jsx)(e.a,{href:"https://en.wikipedia.org/wiki/Cholesky_decomposition",children:"the wikipedia\narticle"})," for further\ndetails about the Cholesky decomposition."]}),"\n",(0,t.jsx)(e.p,{children:"Typical uses of the Cholesky decomposition include the inversion of SDP\nmatrices and resolution of SDP linear systems."}),"\n",(0,t.jsx)("div",{style:{textAlign:"center"},children:(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://nalgebra.rs/assets/images/cholesky-75dc99e2e735888f6626
1a84cad7e63ca.svg",alt:"Cholesky decomposition of a 3x3 matrix."})})}),"\n",(0,t.jsxs)(l.A,{groupId:"wgebra",defaultValue:"rust",values:[{label:"main.rs",value:"rust"},{label:"your_shader.wgsl",value:"wgsl"}],children:[(0,t.jsx)(r.A,{value:"rust",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:'#[derive(Shader)]\n#[shader(derive(WgCholesky3), src = "your_shader.wgsl")]\nstruct YourShader;\n\n// Automatically generates a test to check with `cargo test` if `your_shader.wgsl` compiles.\nwgcore::test_shader_compilation!(YourShader);\n'})})}),(0,t.jsx)(r.A,{value:"wgsl",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:"#import wgebra::cholesky3 as Chol\n\n// Example of function running the decomposition on a 3x3 matrix.\nfn my_function(m: mat3x3<f32>) {\n    let decomposition = Chol::cholesky(m);\n}\n"})})})]}),"\n",(0,t.jsx)(e.h2,{id:"qr",children:"QR"}),"\n",(0,t.jsxs)(e.p,{children:["The QR decomposition of a general ",(0,t.jsx)(e.code,{children:"m \xd7 n"})," matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"M"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"})]})})]})," is composed of an ",(0,t.jsx)(e.code,{children:"m \xd7 min(n, m)"})," unitary matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"Q"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"})]})})]}),", and a ",(0,t.jsx)(e.code,{children:"min(n, m) \xd7 m"})," upper triangular matrix\n(or upper trapezoidal if ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"m"}),(0,t.jsx)(e.mo,{children:"<"}),(0,t.jsx)(e.mi,{children:"n"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"m < n"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.5782em",verticalAlign:"-0.0391em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"m"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"<"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.4306em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"n"})]})]})]}),") ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"R"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"R"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.00773em"},children:"R"})]})})]})," such that ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"M"}),(0,t.jsx)(e.mo,{children:"="}),(0,t.jsx)(e.mi,{children:"Q"}),(0,t.jsx)(e.mi,{children:"R"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M = QR"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"="}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.00773em"},children:"QR"})]})]})]}),". This can be used to\ncompute the inverse or a matrix or for solving linear systems. See also ",(0,t.jsx)(e.a,{href:"https://en.wikipedia.org/wiki/QR_decomposition",children:"the\nwikipedia article"})," for further\ndetails."]}),"\n",(0,t.jsx)("div",{style:{textAlign:"center"},children:(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://nalgebra.rs/assets/images/QR-c637c07671e0b3b667b54e70ea195a67.svg",alt:"QR decomposition of a 3x3 matrix."})})}),"\n",(0,t.jsxs)(l.A,{groupId:"wgebra",defaultValue:"rust",values:[{label:"main.rs",value:"rust"},{label:"your_shader.wgsl",value:"wgsl"}],children:[(0,t.jsx)(r.A,{value:"rust",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:'#[derive(Shader)]\n#[shader(derive(WgQR3), src = "your_shader.wgsl")]\nstruct YourShader;\n\n// Automatically generates a test to check with `cargo test` if `your_shader.wgsl` compiles.\nwgcore::test_shader_compilation!(YourShader);\n'})})}),(0,t.jsx)(r.A,{value:"wgsl",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:"#import wgebra::qr3 as QR\n\n// Example of function running the decomposition on a 3x3 matrix.\nfn my_function(m: mat3x3<f32>) {\n    let decomposition = QR::qr(m);\n}\n"})})})]}),"\n",(0,t.jsx)(e.h2,{id:"lu-with-partial-pivoting",children:"LU with partial pivoting"}),"\n",(0,t.jsxs)(e.p,{children:["The LU decomposition of a general ",(0,t.jsx)(e.code,{children:"m \xd7 n"})," matrix is composed of a ",(0,t.jsx)(e.code,{children:"m \xd7 min(n, m)"})," lower triangular matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"L"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"L"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"L"})]})})]})," with a diagonal filled with 1, and a ",(0,t.jsx)(e.code,{children:"min(n, m) \xd7 m"})," upper triangular matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"U"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"U"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"})]})})]})," such that ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"M"}),(0,t.jsx)(e.mo,{children:"="}),(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mi,{children:"U"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M = LU"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"="}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"LU"})]})]})]}),". This decomposition is\ntypically used for solving linear systems, compute determinants, matrix\ninverse, and matrix rank."]}),"\n",(0,t.jsxs)(e.p,{children:["WGebra implements ",(0,t.jsx)(e.code,{children:"LU"})," decomposition with partial (row) pivoting which computes additionally\nonly one permutation matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"P"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"P"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"})]})})]})," such that ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"P"}),(0,t.jsx)(e.mi,{children:"M"}),(0,t.jsx)(e.mo,{children:"="}),(0,t.jsx)(e.mi,{children:"L"}),(0,t.jsx)(e.mi,{children:"U"})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"PM = LU"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"PM"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"="}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"LU"})]})]})]}),"."]}),"\n",(0,t.jsxs)(e.p,{children:["See also ",(0,t.jsx)(e.a,{href:"https://en.wikipedia.org/wiki/LU_decomposition",children:"the wikipedia article"})," for further details."]}),"\n",(0,t.jsx)("div",{style:{textAlign:"center"},children:(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://nalgebra.rs/assets/images/LU-e0e7218e88443b27cfafe74dbb63f28b.svg",alt:"LU decomposition of a 3x3 matrix."})})}),"\n",(0,t.jsxs)(l.A,{groupId:"wgebra",defaultValue:"rust",values:[{label:"main.rs",value:"rust"},{label:"your_shader.wgsl",value:"wgsl"}],children:[(0,t.jsx)(r.A,{value:"rust",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:'#[derive(Shader)]\n#[shader(derive(WgLU3), src = "your_shader.wgsl")]\nstruct YourShader;\n\n// Automatically generates a test to check with `cargo test` if `your_shader.wgsl` compiles.\nwgcore::test_shader_compilation!(YourShader);\n'})})}),(0,t.jsx)(r.A,{value:"wgsl",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:"#import wgebra::lu3 as LU\n\n// Example of function running the decomposition on a 3x3 matrix.\nfn my_function(m: mat3x3<f32>) {\n    let decomposition = LU::lu(m);\n}\n"})})})]}),"\n",(0,t.jsx)(e.h2,{id:"eigendecomposition-symmetric-matrix",children:"Eigendecomposition (symmetric matrix)"}),"\n",(0,t.jsxs)(e.p,{children:["The eigendecomposition of a square symmetric matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"M"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"})]})})]})," is composed of an\nunitary matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"Q"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"})]})})]})," and a real diagonal matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u039b"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\Lambda"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord",children:"\u039b"})]})})]})," such that ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsxs)(e.mrow,{children:[(0,t.jsx)(e.mi,{children:"M"}),(0,t.jsx)(e.mo,{children:"="}),(0,t.jsx)(e.mi,{children:"Q"}),(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u039b"}),(0,t.jsxs)(e.msup,{children:[(0,t.jsx)(e.mi,{children:"Q"}),(0,t.jsx)(e.mo,{children:"\u2217"})]})]}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M = Q\\Lambda\nQ^*"})]})})}),(0,t.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,t.jsx)(e.span,{className:"mrel",children:"="}),(0,t.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8831em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,t.jsx)(e.span,{className:"mord",children:"\u039b"}),(0,t.jsxs)(e.span,{className:"mord",children:[(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,t.jsx)(e.span,{className:"msupsub",children:(0,t.jsx)(e.span,{className:"vlist-t",children:(0,t.jsx)(e.span,{className:"vlist-r",children:(0,t.jsx)(e.span,{className:"vlist",sty
1le:{height:"0.6887em"},children:(0,t.jsxs)(e.span,{style:{top:"-3.063em",marginRight:"0.05em"},children:[(0,t.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,t.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,t.jsx)(e.span,{className:"mbin mtight",children:"\u2217"})})]})})})})})]})]})]})]}),". The columns of ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"Q"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"})]})})]})," are called the ",(0,t.jsx)(e.em,{children:"eigenvectors"})," of ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"M"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"M"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"M"})]})})]})," and the diagonal\nelements of ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u039b"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\Lambda"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord",children:"\u039b"})]})})]})," its ",(0,t.jsx)(e.em,{children:"eigenvalues"}),"."]}),"\n",(0,t.jsxs)(e.p,{children:["The matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"Q"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",children:"Q"})]})})]})," and the eigenvalues of the decomposed matrix are respectively\naccessible as public the fields ",(0,t.jsx)(e.code,{children:"eigenvectors"})," and ",(0,t.jsx)(e.code,{children:"eigenvalues"})," of the\n",(0,t.jsx)(e.code,{children:"SymmetricEigen"})," structure."]}),"\n",(0,t.jsx)("div",{style:{textAlign:"center"},children:(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://nalgebra.rs/assets/images/symmetric_eigen-63031cc3f1a7d8e57497b26c16041f0b.svg",alt:"Eigendecomposition of a 3x3 symmetric matrix."})})}),"\n",(0,t.jsxs)(l.A,{groupId:"wgebra",defaultValue:"rust",values:[{label:"main.rs",value:"rust"},{label:"your_shader.wgsl",value:"wgsl"}],children:[(0,t.jsx)(r.A,{value:"rust",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:'#[derive(Shader)]\n#[shader(derive(WgSymmetricEigen3), src = "your_shader.wgsl")]\nstruct YourShader;\n\n// Automatically generates a test to check with `cargo test` if `your_shader.wgsl` compiles.\nwgcore::test_shader_compilation!(YourShader);\n'})})}),(0,t.jsx)(r.A,{value:"wgsl",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:"#import wgebra::eig3 as Eig\n\n// Example of function running the decomposition on a 3x3 matrix.\nfn my_function(m: mat3x3<f32>) {\n    let decomposition = Eig::symmetric_eigen(m);\n}\n"})})})]}),"\n",(0,t.jsx)(e.h2,{id:"singular-value-decomposition",children:"Singular Value Decomposition"}),"\n",(0,t.jsxs)(e.p,{children:["The Singular Value Decomposition (SVD) of a rectangular matrix is composed\nof two orthogonal matrices ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"U"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"U"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.10903em"},children:"U"})]})})]})," and ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"V"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"V"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.22222em"},children:"V"})]})})]})," and a diagonal matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{mathvariant:"normal",children:"\u03a3"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\Sigma"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord",children:"\u03a3"})]})})]})," with positive\n(or zero) components. Typical uses of the SVD are the pseudo-inverse, rank\ncomputation, and the resolution of least-square problems."]}),"\n",(0,t.jsxs)(e.p,{children:["The singular values, left singular vectors, and right singular vectors are\nrespectively stored on the public fields ",(0,t.jsx)(e.code,{children:"singular_values"}),", ",(0,t.jsx)(e.code,{children:"u"})," and ",(0,t.jsx)(e.code,{children:"v_t"}),". Note\nthat ",(0,t.jsx)(e.code,{children:"v_t"})," represents the adjoint (i.e. conjugate-transpose) of the matrix ",(0,t.jsxs)(e.span,{className:"katex",children:[(0,t.jsx)(e.span,{className:"katex-mathml",children:(0,t.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,t.jsxs)(e.semantics,{children:[(0,t.jsx)(e.mrow,{children:(0,t.jsx)(e.mi,{children:"V"})}),(0,t.jsx)(e.annotation,{encoding:"application/x-tex",children:"V"})]})})}),(0,t.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,t.jsxs)(e.span,{className:"base",children:[(0,t.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,t.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.22222em"},children:"V"})]})})]}),"."]}),"\n",(0,t.jsx)("div",{style:{textAlign:"center"},children:(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://nalgebra.rs/assets/images/SVD-a3b626297ee186a529a2f3c3284eca21.svg",alt:"SVD decomposition of a 3x3 matrix."})})}),"\n",(0,t.jsxs)(l.A,{groupId:"wgebra",defaultValue:"rust",values:[{label:"main.rs",value:"rust"},{label:"your_shader.wgsl",value:"wgsl"}],children:[(0,t.jsx)(r.A,{value:"rust",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:'#[derive(Shader)]\n#[shader(derive(WgSvd3), src = "your_shader.wgsl")]\nstruct YourShader;\n\n// Automatically generates a test to check with `cargo test` if `your_shader.wgsl` compiles.\nwgcore::test_shader_compilation!(YourShader);\n'})})}),(0,t.jsx)(r.A,{value:"wgsl",children:(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-rust",children:"#import wgebra::svd3 as Svd\n\n// Example of function running the decomposition on a 3x3 matrix.\nfn my_function(m: mat3x3<f32>) {\n    let decomposition = Svd::svd(m);\n}\n"})})})]})]})}function x(s={}){const{wrapper:e}={...(0,i.R)(),...s.components};return e?(0,t.jsx)(e,{...s,children:(0,t.jsx)(o,{...s})}):o(s)}},9365:(s,e,a)=>{a.d(e,{A:()=>l});a(6540);var n=a(8215);const t={tabItem:"tabItem_Ymn6"};var i=a(4848);function l(s){let{children:e,hidden:a,className:l}=s;return(0,i.jsx)("div",{role:"tabpanel",className:(0,n.A)(t.tabItem,l),hidden:a,children:e})}},1470:(s,e,a)=>{a.d(e,{A:()=>v});var n=a(6540),t=a(8215),i=a(3104),l=a(6347),r=a(205),c=a(7485),m=a(1682),h=a(679);function d(s){return n.Children.toArray(s).filter((s=>"\n"!==s)).map((s=>{if(!s||(0,n.isValidElement)(s)&&function(s){const{props:e}=s;return!!e&&"object"==typeof e&&"value"in e}(s))return s;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof s.type?s.type:s.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function o(s){const{values:e,children:a}=s;return(0,n.useMemo)((()=>{const s=e??function(s){return d(s).map((s=>{let{props:{value:e,label:a,attributes:n,default:t}}=s;return{value:e,label:a,attributes:n,default:t}}))}(a);return function(s){const e=(0,m.XI)(s,((s,e)=>s.value===e.value));if(e.length>0)throw new Error(`Docusaurus error: Duplicate values "${e.map((s=>s.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(s),s}),[e,a])}function x(s){let{value:e,tabValues:a}=s;return a.some((s=>s.value===e))}function p(s){let{queryString:e=!1,groupId:a}=s;const t=(0,l.W6)(),i=function(s){let{queryString:e=!1,groupId:a}=s;if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!a)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return a??null}({queryString:e,groupId:a});return[(0,c.aZ)(i),(0,n.useCallback)((s=>{if(!i)return;const e=new URLSearchParams(t.location.search);e.set(i,s),t.replace({...t.location,search:e.toString()})}),[i,t])]}function j(s){const{defaultValue:e,queryString:a=!1,groupId:t}
1=s,i=o(s),[l,c]=(0,n.useState)((()=>function(s){let{defaultValue:e,tabValues:a}=s;if(0===a.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!x({value:e,tabValues:a}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${a.map((s=>s.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}const n=a.find((s=>s.default))??a[0];if(!n)throw new Error("Unexpected error: 0 tabValues");return n.value}({defaultValue:e,tabValues:i}))),[m,d]=p({queryString:a,groupId:t}),[j,u]=function(s){let{groupId:e}=s;const a=function(s){return s?`docusaurus.tab.${s}`:null}(e),[t,i]=(0,h.Dv)(a);return[t,(0,n.useCallback)((s=>{a&&i.set(s)}),[a,i])]}({groupId:t}),g=(()=>{const s=m??j;return x({value:s,tabValues:i})?s:null})();(0,r.A)((()=>{g&&c(g)}),[g]);return{selectedValue:l,selectValue:(0,n.useCallback)((s=>{if(!x({value:s,tabValues:i}))throw new Error(`Can't select invalid tab value=${s}`);c(s),d(s),u(s)}),[d,u,i]),tabValues:i}}var u=a(2303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var N=a(4848);function w(s){let{className:e,block:a,selectedValue:n,selectValue:l,tabValues:r}=s;const c=[],{blockElementScrollPositionUntilNextRender:m}=(0,i.a_)(),h=s=>{const e=s.currentTarget,a=c.indexOf(e),t=r[a].value;t!==n&&(m(e),l(t))},d=s=>{let e=null;switch(s.key){case"Enter":h(s);break;case"ArrowRight":{const a=c.indexOf(s.currentTarget)+1;e=c[a]??c[0];break}case"ArrowLeft":{const a=c.indexOf(s.currentTarget)-1;e=c[a]??c[c.length-1];break}}e?.focus()};return(0,N.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":a},e),children:r.map((s=>{let{value:e,label:a,attributes:i}=s;return(0,N.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:s=>c.push(s),onKeyDown:d,onClick:h,...i,className:(0,t.A)("tabs__item",g.tabItem,i?.className,{"tabs__item--active":n===e}),children:a??e},e)}))})}function y(s){let{lazy:e,children:a,selectedValue:i}=s;const l=(Array.isArray(a)?a:[a]).filter(Boolean);if(e){const s=l.find((s=>s.props.value===i));return s?(0,n.cloneElement)(s,{className:(0,t.A)("margin-top--md",s.props.className)}):null}return(0,N.jsx)("div",{className:"margin-top--md",children:l.map(((s,e)=>(0,n.cloneElement)(s,{key:e,hidden:s.props.value!==i})))})}function b(s){const e=j(s);return(0,N.jsxs)("div",{className:(0,t.A)("tabs-container",g.tabList),children:[(0,N.jsx)(w,{...e,...s}),(0,N.jsx)(y,{...e,...s})]})}function v(s){const e=(0,u.A)();return(0,N.jsx)(b,{...s,children:d(s.children)},String(e))}},8453:(s,e,a)=>{a.d(e,{R:()=>l,x:()=>r});var n=a(6540);const t={},i=n.createContext(t);function l(s){const e=n.useContext(i);return n.useMemo((function(){return"function"==typeof s?s(e):{...e,...s}}),[e,s])}function r(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(t):s.components||t:l(s.components),n.createElement(i.Provider,{value:e},s.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.