Band[{i,j}]
represents the sequence of positions on the diagonal band that starts with {i,j} in a sparse array.
Band[{imin,jmin,…},{imax,jmax,…}]
represents the positions between {imin,jmin,…} and {imax,jmax,…}.
Band[{imin,jmin,…},{imax,jmax,…},{di,dj,…}]
represents positions starting with {imin,jmin,…} and then moving with step {di,dj,…}.
Band
Band[{i,j}]
represents the sequence of positions on the diagonal band that starts with {i,j} in a sparse array.
Band[{imin,jmin,…},{imax,jmax,…}]
represents the positions between {imin,jmin,…} and {imax,jmax,…}.
Band[{imin,jmin,…},{imax,jmax,…},{di,dj,…}]
represents positions starting with {imin,jmin,…} and then moving with step {di,dj,…}.
Details
- Band[pos]->v represents values v that repeat along the diagonal band starting at pos.
- Band[pos]->{v1,v2,…} represents a sequence of values vn along the diagonal band starting at pos.
- With an array a of the same rank as the whole sparse array, Band[start]->a by default inserts a at the position specified by start.
- With arrays an of the same rank as the whole sparse array, Band[pos]->{a1,a2,…} represents a sequence of non-overlapping subarrays.
- Band[start] is effectively equivalent to Band[start,{-1,-1,…}].
- For scalar values, Band[start,end] is equivalent to Band[start,end,{1,1,…}].
- Band[start,end,step] stops when any coordinate first exceeds its value in end.
- Band[start,end]->{v1,v2,…} takes the values vn to repeat cyclically until end is reached.
- Band[start,Automatic,step]->a continues until the edge of the array is reached.
- Band[start,Automatic,step]->{v1,v2,…} continues until the vi are exhausted.
Examples
open all close allBasic Examples (1)
Scope (11)
Mix Band with other SparseArray element specifications:
SparseArray[{Band[{1, 1}] -> x, {3, 5} -> b}, {5, 5}]//MatrixFormGive explicit values to fill in on the band:
SparseArray[Band[{1, 1}] -> {x, y, z}, {5, 5}]//MatrixFormSparseArray[Band[{1, 1}, {5, 5}] -> {x, y, z}, {5, 5}]//MatrixFormStart the band at any position in the matrix:
SparseArray[Band[{3, 2}] -> x, {5, 5}]//MatrixFormSpecify any start and end locations:
SparseArray[Band[{1, 2}, {3, 4}] -> x, {5, 5}]//MatrixFormStep by 2 between elements on the band:
SparseArray[Band[{1, 1}, {5, 5}, 2] -> x, {5, 5}]//MatrixFormSparseArray[Band[{1, 1}, {5, 5}, {1, 2}] -> x, {5, 5}]//MatrixFormAutomatically continue the band to the edge of the array:
SparseArray[Band[{1, 1}, Automatic, {1, 2}] -> x, {5, 5}]//MatrixFormSpecify a band that is part of a row:
SparseArray[Band[{3, 3}, Automatic, {0, 1}] -> x, {5, 5}]//MatrixFormSpecify an anti-diagonal matrix:
SparseArray[Band[{1, 5}, Automatic, {1, -1}] -> x, {5, 5}]//MatrixFormInsert a submatrix beginning at position 3, 3:
SparseArray[Band[{3, 3}] -> {{a, b}, {c, d}}, {5, 5}]//MatrixFormCyclically repeat the submatrix:
SparseArray[Band[{1, 1}, {5, 5}] -> {{{a, b}, {c, d}}}, {5, 5}]//MatrixFormAlternate the submatrix with a single element:
SparseArray[Band[{1, 1}, {5, 5}] -> {{{a, b}, {c, d}}, {{x}}}, {5, 5}]//MatrixFormGeneralizations & Extensions (2)
Band works in sparse arrays of any rank:
Graphics3D[Cuboid /@ Position[Normal[SparseArray[Band[{1, 1, 1}] -> x, {10, 10, 10}]], x]]Graphics3D[Cuboid /@ Position[Normal[SparseArray[Band[{1, 1, 1}, Automatic, {1, 2, 3}] -> x, {30, 30, 30}]], x]]Fill in a plane of values into a 3D sparse array:
Graphics3D[Cuboid /@ Position[Normal[SparseArray[Band[{1, 1, 1}] -> Table[x, {10}, {10}]]], x]]Applications (2)
Properties & Relations (2)
Band works in SparseArray; use Normal to convert to normal lists:
SparseArray[{Band[{1, 1}] -> x, Band[{2, 1}] -> y}, {5, 5}]Normal[%]The simplest case of Band is equivalent to DiagonalMatrix:
DiagonalMatrix[{a, b, c, d, e}]//MatrixFormSparseArray[Band[{1, 1}] -> {a, b, c, d, e}]//MatrixFormSee Also
ArrayFlatten ArrayPad SparseArray Minors DiagonalMatrix Take Span Diagonal LowerTriangularize UpperTriangularize Extract
Function Repository: TridiagonalInverse
Tech Notes
Related Guides
History
Text
Wolfram Research (2007), Band, Wolfram Language function, https://reference.wolfram.com/language/ref/Band.html.
CMS
Wolfram Language. 2007. "Band." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Band.html.
APA
Wolfram Language. (2007). Band. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Band.html
BibTeX
@misc{reference.wolfram_2026_band, author="Wolfram Research", title="{Band}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Band.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_band, organization={Wolfram Research}, title={Band}, year={2007}, url={https://reference.wolfram.com/language/ref/Band.html}, note=[Accessed: 12-June-2026]}