@@ -150,7 +150,10 @@ julia> sB\x
150150 -1.1086956521739126
151151 -1.4565217391304346
152152```
153- The ` \ ` operation here performs the linear solution. The left-division operator is pretty powerful and it's easy to write compact, readable code that is flexible enough to solve all sorts of systems of linear equations.
153+
154+ The ` \ ` operation here performs the linear solution. The left-division operator is pretty
155+ powerful and it's easy to write compact, readable code that is flexible enough to solve all
156+ sorts of systems of linear equations.
154157
155158## Special matrices
156159
@@ -309,6 +312,94 @@ Adjoints and transposes of [`Factorization`](@ref) objects are lazily wrapped in
309312` AdjointFactorization ` and ` TransposeFactorization ` objects, respectively. Generically,
310313transpose of real ` Factorization ` s are wrapped as ` AdjointFactorization ` .
311314
315+ ## [ Orthogonal matrices (` AbstractQ ` )] (@id man-linalg-abstractq)
316+
317+ Some matrix factorizations generate orthogonal/unitary "matrix" factors. These
318+ factorizations include QR-related factorizations obtained from calls to [ ` qr ` ] ( @ref ) , i.e.,
319+ ` QR ` , ` QRCompactWY ` and ` QRPivoted ` , the Hessenberg factorization obtained from calls to
320+ [ ` hessenberg ` ] ( @ref ) , and the LQ factorization obtained from [ ` lq ` ] ( @ref ) . While these
321+ orthogonal/unitary factors admit a matrix representation, their internal representation
322+ is, for performance and memory reasons, different. Hence, they should be rather viewed as
323+ matrix-backed, function-based linear operators. In particular, reading, for instance, a
324+ column of its matrix representation requires running "matrix"-vector multiplication code,
325+ rather than simply reading out data from memory (possibly filling parts of the vector with
326+ structural zeros). Another clear distinction from other, non-triangular matrix types is
327+ that the underlying multiplication code allows for in-place modification during multiplication.
328+ Furthermore, objects of specific ` AbstractQ ` subtypes as those created via [ ` qr ` ] ( @ref ) ,
329+ [ ` hessenberg ` ] ( @ref ) and [ ` lq ` ] ( @ref ) can behave like a square or a rectangular matrix
330+ depending on context:
331+
332+ ``` julia
333+ julia> using LinearAlgebra
334+
335+ julia> Q = qr (rand (3 ,2 )). Q
336+ 3 × 3 LinearAlgebra. QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}
337+
338+ julia> Matrix (Q)
339+ 3 × 2 Matrix{Float64}:
340+ - 0.320597 0.865734
341+ - 0.765834 - 0.475694
342+ - 0.557419 0.155628
343+
344+ julia> Q* I
345+ 3 × 3 Matrix{Float64}:
346+ - 0.320597 0.865734 - 0.384346
347+ - 0.765834 - 0.475694 - 0.432683
348+ - 0.557419 0.155628 0.815514
349+
350+ julia> Q* ones (2 )
351+ 3 - element Vector{Float64}:
352+ 0.5451367118802273
353+ - 1.241527373086654
354+ - 0.40179067589600226
355+
356+ julia> Q* ones (3 )
357+ 3 - element Vector{Float64}:
358+ 0.16079054743832022
359+ - 1.674209978965636
360+ 0.41372375588835797
361+
362+ julia> ones (1 ,2 ) * Q'
363+ 1 × 3 Matrix{Float64}:
364+ 0.545137 - 1.24153 - 0.401791
365+
366+ julia> ones (1 ,3 ) * Q'
367+ 1 × 3 Matrix{Float64}:
368+ 0.160791 - 1.67421 0.413724
369+ ```
370+
371+ Due to this distinction from dense or structured matrices, the abstract ` AbstractQ ` type
372+ does not subtype ` AbstractMatrix ` , but instead has its own type hierarchy. Custom types
373+ that subtype ` AbstractQ ` can rely on generic fallbacks if the following interface is satisfied.
374+ For example, for
375+
376+ ``` julia
377+ struct MyQ{T} <: LinearAlgebra.AbstractQ{T}
378+ # required fields
379+ end
380+ ```
381+
382+ provide overloads for
383+
384+ ``` julia
385+ Base. size (Q:: MyQ ) # size of corresponding square matrix representation
386+ Base. convert (:: Type{AbstractQ{T}} , Q:: MyQ ) # eltype promotion [optional]
387+ LinearAlgebra. lmul! (Q:: MyQ , x:: AbstractVecOrMat ) # left-multiplication
388+ LinearAlgebra. rmul! (A:: AbstractMatrix , Q:: MyQ ) # right-multiplication
389+ ```
390+
391+ If ` eltype ` promotion is not of interest, the ` convert ` method is unnecessary, since by
392+ default ` convert(::Type{AbstractQ{T}}, Q::AbstractQ{T}) ` returns ` Q ` itself.
393+ Adjoints of ` AbstractQ ` -typed objects are lazily wrapped in an ` AdjointQ ` wrapper type,
394+ which requires its own ` LinearAlgebra.lmul! ` and ` LinearAlgebra.rmul! ` methods. Given this
395+ set of methods, any ` Q::MyQ ` can be used like a matrix, preferably in a multiplicative
396+ context: multiplication via ` * ` with scalars, vectors and matrices from left and right,
397+ obtaining a matrix representation of ` Q ` via ` Matrix(Q) ` (or ` Q*I ` ) and indexing into the
398+ matrix representation all work. In contrast, addition and subtraction as well as more
399+ generally broadcasting over elements in the matrix representation fail because that would
400+ be highly inefficient. For such use cases, consider computing the matrix representation
401+ up front and cache it for future reuse.
402+
312403## Standard functions
313404
314405Linear algebra functions in Julia are largely implemented by calling functions from [ LAPACK] ( http://www.netlib.org/lapack/ ) .
@@ -505,38 +596,42 @@ four methods defined, for [`Float32`](@ref), [`Float64`](@ref), [`ComplexF32`](@
505596and [ ` ComplexF64 ` ] (@ref Complex) arrays.
506597
507598### [ BLAS character arguments] (@id stdlib-blas-chars)
599+
508600Many BLAS functions accept arguments that determine whether to transpose an argument (` trans ` ),
509601which triangle of a matrix to reference (` uplo ` or ` ul ` ),
510602whether the diagonal of a triangular matrix can be assumed to
511603be all ones (` dA ` ) or which side of a matrix multiplication
512604the input argument belongs on (` side ` ). The possibilities are:
513605
514606#### [ Multiplication order] (@id stdlib-blas-side)
607+
515608| ` side ` | Meaning |
516609| :-------| :--------------------------------------------------------------------|
517610| ` 'L' ` | The argument goes on the * left* side of a matrix-matrix operation. |
518611| ` 'R' ` | The argument goes on the * right* side of a matrix-matrix operation. |
519612
520613#### [ Triangle referencing] (@id stdlib-blas-uplo)
614+
521615| ` uplo ` /` ul ` | Meaning |
522616| :------------| :------------------------------------------------------|
523617| ` 'U' ` | Only the * upper* triangle of the matrix will be used. |
524618| ` 'L' ` | Only the * lower* triangle of the matrix will be used. |
525619
526620#### [ Transposition operation] (@id stdlib-blas-trans)
621+
527622| ` trans ` /` tX ` | Meaning |
528623| :-------------| :--------------------------------------------------------|
529624| ` 'N' ` | The input matrix ` X ` is not transposed or conjugated. |
530625| ` 'T' ` | The input matrix ` X ` will be transposed. |
531626| ` 'C' ` | The input matrix ` X ` will be conjugated and transposed. |
532627
533628#### [ Unit diagonal] (@id stdlib-blas-diag)
629+
534630| ` diag ` /` dX ` | Meaning |
535631| :------------| :----------------------------------------------------------|
536632| ` 'N' ` | The diagonal values of the matrix ` X ` will be read. |
537633| ` 'U' ` | The diagonal of the matrix ` X ` is assumed to be all ones. |
538634
539-
540635``` @docs
541636LinearAlgebra.BLAS
542637LinearAlgebra.BLAS.set_num_threads
@@ -582,6 +677,7 @@ and define matrix-vector operations.
582677[ Dongarra-1988 ] : https://dl.acm.org/doi/10.1145/42288.42291
583678
584679** return a vector**
680+
585681``` @docs
586682LinearAlgebra.BLAS.gemv!
587683LinearAlgebra.BLAS.gemv(::Any, ::Any, ::Any, ::Any)
@@ -611,6 +707,7 @@ LinearAlgebra.BLAS.trsv
611707```
612708
613709** return a matrix**
710+
614711``` @docs
615712LinearAlgebra.BLAS.ger!
616713# xGERU
0 commit comments