Dense core

Types and helpers in src/dense/core that the rest of NextLA builds on.

NextLAMatrix

NextLAMatrix(data) (or NextLAMatrix{T}(data)) wraps a dense matrix so that LinearAlgebra.lu! on it runs NextLA's own pivoted LU (getrf2!) for Float32, Float64, ComplexF32 and ComplexF64, and LinearAlgebra.BLAS.axpy! runs NextLA's axpy!. The BLAS calls gemm!, syrk!, herk!, syr2k! and her2k! on it pass the wrapped matrix to the system BLAS.

using NextLA, LinearAlgebra

A = rand(1024, 1024)
F = lu!(NextLAMatrix{Float64}(copy(A)))   # NextLA's getrf, with partial pivoting
F.L * F.U ≈ A[F.p, :]

# output

true
NextLA.NextLAMatrix — Type
NextLAMatrix(data::Matrix{T})
NextLAMatrix{T}(data::Matrix{T})

A wrapper around a dense Matrix that sends some LinearAlgebra calls to NextLA's own routines. It is not an AbstractMatrix. size, length, and getindex/setindex! with integer indices forward to the wrapped matrix.

Fields

  • data::Matrix{T}: the wrapped matrix. Calls on the wrapper change it in place.

Methods

  • lu!(A::NextLAMatrix) runs getrf2! for Float32, Float64, ComplexF32 and ComplexF64 with the default pivoting (RowMaximum()), and returns a LinearAlgebra.LU. Other element types, or other pivots (NoPivot(), RowNonZero(), CompletePivoting()), use NextLA's generic loop and return a NextLA.LU.
  • BLAS.axpy!(α, x::NextLAMatrix, y::NextLAMatrix) runs NextLA's axpy! on the wrapped matrices, updating y in place.
  • BLAS.gemm!, BLAS.syrk!, BLAS.herk!, BLAS.syr2k! and BLAS.her2k! on NextLAMatrix arguments pass the wrapped matrices through to the system BLAS.
source

Machine parameters

NextLA.lamch — Method
lamch(::Type{T}, cmach) where{T<: Number}

Determines single / double precision machine parameters

Arguments

  • T : type, currently only tested Float32 and Float64
  • 'cmach' : specifies the value to be returned by lamch
- = 'E': returns eps
- = 'S': returns sfmin
- = 'P': returns eps*base

- where
	- eps = relative machine precision
	- sfmin = safe min, such that 1/sfmin does not overflow
	- base = base of the machine

Examples

julia> NextLA.lamch(Float64, 'E') == eps(Float64) / 2
true

julia> NextLA.lamch(Float32, 'S') == floatmin(Float32)
true
source

Usage examples

The example stands on its own and ends with a check that prints true.

Solving a system through NextLAMatrix

For Float32, Float64, ComplexF32 and ComplexF64 with the default pivoting, lu! on a NextLAMatrix returns an ordinary LinearAlgebra.LU, so \ solves with it; other types and pivot choices return a NextLA.LU.

using NextLA, LinearAlgebra

n = 2048
A = rand(n, n)
B = rand(n, 256)

F = lu!(NextLAMatrix{Float64}(copy(A)))   # NextLA's getrf, with partial pivoting
X = F \ B
A * X ≈ B

# output

true