Skip to content

JuliaLinearAlgebra/BandedMatrices.jl

Folders and files

NameName
Last commit message
Last commit date
Apr 24, 2024
Dec 6, 2023
Nov 18, 2019
Jul 27, 2023
Jun 3, 2024
Jun 3, 2024
Mar 10, 2024
Apr 12, 2019
Jun 3, 2024
Mar 14, 2024
Jan 8, 2021

Repository files navigation

BandedMatrices.jl

A Julia package for representing banded matrices

Build Status codecov Aqua QA deps version pkgeval

This package supports representing banded matrices by only the entries on the bands.

One can create banded matrices of type BandedMatrix as follows:

BandedMatrix(-1=> 1:5, 2=>1:3)     # creates a 6 x 6 banded matrix version of diagm(-1=> 1:5, 2=>1:3)
BandedMatrix((-1=> 1:5, 2=>1:3), (n,m))     # creates an n x m banded matrix with 1 sub-diagonals and u super-diagonals with the specified diagonals
BandedMatrix((-1=> 1:5, 2=>1:3), (n,m), (l,u))     # creates an n x m banded matrix with l sub-diagonals and u super-diagonals with the specified diagonals
BandedMatrix(FillArrays.Zeros(m,n), (l,u))    # creates a banded matrix of zeros, with l sub-diagonals and u super-diagonals
BandedMatrix(FillArrays.Ones(m,n), (l,u))     # creates a banded matrix of ones, with l sub-diagonals and u super-diagonals
BandedMatrix(FillArrays.Eye(n), (l,u))        # creates a banded  n x n identity matrix, with l sub-diagonals and u super-diagonals
brand(m,n,l,u)     # creates a random banded matrix, with l sub-diagonals and u super-diagonals

For more examples, see the documentation.

Specialized algebra routines are overriden, include * and \:

A = brand(10000,10000,4,3)  # creates a 10000 x 10000 matrix with 4 sub-diagonals
                            # and 3 super-diagonals
b = randn(10000)
A*b  #   Calls optimized matrix*vector routine
A*A  #   Calls optimized matrix*matrix routine
A\b  #   Calls optimized matrix\vector routine