= Julia LinearAlgebra = The '''`LinearAlgebra`''' package provides reference implementations of [[LinearAlgebra#Decompositions_and_Factorizations|matrix decompositions]] and related utilities. <> ---- == Example == {{{ julia> using LinearAlgebra; julia> A = [1 2 3; 4 1 6; 7 8 1] 3×3 Matrix{Int64}: 1 2 3 4 1 6 7 8 1 julia> tr(A) 3 julia> det(A) 104.0 }}} ---- == Functions == In the following calls, note that: * `a` and `b` are column vectors of equal size * `m` and `n` are matrices These functions return a scalar value. ||'''Function Call'''||'''Meaning''' || ||`det(m)` ||[[LinearAlgebra/Determinant|determinant]] || ||`dot(a,b)` ||[[Calculus/VectorOperations#Dot_Product|dot product]] || ||`eigmax(m)` ||largest [[LinearAlgebra/EigenvaluesAndEigenvectors|eigenvalue]]|| ||`eigmin(m)` ||smallest eigenvalue || ||`norm(a)` ||[[Calculus/Distance|norm]] || ||`rank(m)` ||[[LinearAlgebra/Rank|rank]] || ||`tr(a)` ||[[LinearAlgebra/Trace|trace]] || These functions return a column vector. ||'''Function Call'''||'''Meaning''' ||Notes || ||`cross(a,b)` ||[[Calculus/VectorOperations#Cross_Product|cross product]]||`a` and `b` must be 3-dimensional|| ||`diag(m)` ||diagonal of the matrix || || ||`eigvals(m)` ||eigenvalues || || ||`normalize(a)` ||normalize to a [[Calculus/Distance|distance]] of 1 || || These functions return a matrix. ||'''Function Call'''||'''Meaning''' || ||`bunchkaufman(m)` ||Bunch-Kaufman factorization || ||`cholesky(m)` ||Cholesky factorization || ||`diagm(a)` ||diagonal matrix with this diagonal || ||`eigen(m)` ||Eigen decomposition || ||`eigvecs(m)` ||[[LinearAlgebra/EigenvaluesAndEigenvectors|eigenvetors]] || ||`hessenberg(m)` ||Hessenberg factorization || ||`lq(m)` ||LQ decomposition || ||`lu(m)` ||[[LinearAlgebra/LUDecomposition|LU decomposition]] || ||`qr(m)` ||[[LinearAlgebra/Orthonormalization#QR_Decomposition|QR decomposition]] || ||`schur(m)` ||Schur factorization || ||`svd(m)` ||[[LinearAlgebra/SingularValueDecomposition|singular value decomposition]]|| There is also the [[LinearAlgebra/PositiveDefiniteness|positive definiteness]] test function, `isposdef`. === Eigen Decomposition === Note that the `eigen` function returns an object where the eigenvectors are accessible by the `vectors` property and the eigenvalues are accessible by the `values` property. {{{ julia> F = eigen([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0]) Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}} values: 3-element Vector{Float64}: 1.0 3.0 18.0 vectors: 3×3 Matrix{Float64}: 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 julia> F.values 3-element Vector{Float64}: 1.0 3.0 18.0 julia> F.vectors 3×3 Matrix{Float64}: 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 julia> vals, vecs = F; # destructuring via iteration }}} ---- == Constructors == Rather than exposing an `eye` function, this package exposes `LinearAlgebra.I`. Note that this is a sparse matrix, and must be type cast to fill it. {{{ julia> using LinearAlgebra; julia> I(3) 3×3 Diagonal{Bool, Vector{Bool}}: 1 ⋅ ⋅ ⋅ 1 ⋅ ⋅ ⋅ 1 julia> Matrix{Int}(I(3)) 3×3 Matrix{Int64}: 1 0 0 0 1 0 0 0 1 }}} Note also that this follows the pattern established by other direct matrix constructors. {{{ julia> d = Diagonal([1, 10, 100]) 3×3 Diagonal{Int64, Vector{Int64}}: 1 ⋅ ⋅ ⋅ 10 ⋅ ⋅ ⋅ 100 }}} ---- CategoryRicottone