diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 0736d376..a7d0ff08 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.6","generation_timestamp":"2024-11-19T09:35:22","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.6","generation_timestamp":"2024-11-22T17:01:41","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index cd80f759..4e5acf03 100644 --- a/dev/index.html +++ b/dev/index.html @@ -9,4 +9,4 @@ 0.7732179994849591 ─────────────────── 0.8455294223894625 - 0.04250653797187476

A block array layout is specified its block sizes – a tuple of AbstractArray{Int}. The length of the tuple is equal to the dimension, the length of each block size array is the number of blocks in the corresponding dimension, and the sum of each block size is the scalar size in that dimension. For example, BlockArray{Int}(undef, [2,2,2], [2,2,2], [2,2,2]) will produce a blocked cube (an AbstractArray{Int, 3}, i.e., 3 dimensions), consisting of 27 2×2×2 blocks (3 in each dimension) and 216 values (6 in each dimension).

Manual Outline

Library Outline

Index

+ 0.04250653797187476

A block array layout is specified its block sizes – a tuple of AbstractArray{Int}. The length of the tuple is equal to the dimension, the length of each block size array is the number of blocks in the corresponding dimension, and the sum of each block size is the scalar size in that dimension. For example, BlockArray{Int}(undef, [2,2,2], [2,2,2], [2,2,2]) will produce a blocked cube (an AbstractArray{Int, 3}, i.e., 3 dimensions), consisting of 27 2×2×2 blocks (3 in each dimension) and 216 values (6 in each dimension).

Manual Outline

Library Outline

Index

diff --git a/dev/lib/internals/index.html b/dev/lib/internals/index.html index fd1f39af..0429b86b 100644 --- a/dev/lib/internals/index.html +++ b/dev/lib/internals/index.html @@ -9,7 +9,7 @@ ─ 5 6 - 7

See also BlockedUnitRange.

source
BlockArrays.BlockedUnitRangeType
BlockedUnitRange

is an AbstractUnitRange{<:Integer} that has been divided into blocks. Construction is typically via blockedrange which converts a vector of block lengths to a BlockedUnitRange.

Examples

julia> blockedrange(2, [2,2,3]) # first value and block lengths
+ 7

See also BlockedUnitRange.

source
BlockArrays.BlockedUnitRangeType
BlockedUnitRange

is an AbstractUnitRange{<:Integer} that has been divided into blocks. Construction is typically via blockedrange which converts a vector of block lengths to a BlockedUnitRange.

Examples

julia> blockedrange(2, [2,2,3]) # first value and block lengths
 3-blocked 7-element BlockedUnitRange{Int64, Vector{Int64}}:
  2
  3
@@ -19,7 +19,7 @@
  ─
  6
  7
- 8

See also BlockedOneTo.

source
BlockArrays.BlockRangeType
BlockRange(axes::Tuple{AbstractUnitRange{Int}})
+ 8

See also BlockedOneTo.

source
BlockArrays.BlockRangeType
BlockRange(axes::Tuple{AbstractUnitRange{Int}})
 BlockRange(sizes::Vararg{Integer})

Represent a Cartesian range of blocks.

The relationship between Block and BlockRange mimics the relationship between CartesianIndex and CartesianIndices.

Examples

julia> BlockRange(2:3, 3:4) |> collect
 2×2 Matrix{Block{2, Int64}}:
  Block(2, 3)  Block(2, 4)
@@ -31,7 +31,7 @@
  Block(2, 1)  Block(2, 2)
 
 julia> Block(1):Block(2)
-BlockRange(1:2)
source
BlockArrays.BlockIndexRangeType
BlockIndexRange(block, startind:stopind)

represents a cartesian range inside a block.

source
BlockArrays.BlockSliceType
BlockSlice(indices)

Represent an AbstractUnitRange of indices that attaches a block.

Upon calling to_indices(), Blocks are converted to BlockSlice objects to represent the indices over which the Block spans.

This mimics the relationship between Colon and Base.Slice.

source
BlockArrays.unblockFunction
unblock(block_sizes, inds, I)

Returns the indices associated with a block as a BlockSlice.

source
BlockArrays.SubBlockIteratorType
SubBlockIterator(subblock_lasts::Vector{Int}, block_lasts::Vector{Int})
+BlockRange(1:2)
source
BlockArrays.BlockIndexRangeType
BlockIndexRange(block, startind:stopind)

represents a cartesian range inside a block.

source
BlockArrays.BlockSliceType
BlockSlice(indices)

Represent an AbstractUnitRange of indices that attaches a block.

Upon calling to_indices(), Blocks are converted to BlockSlice objects to represent the indices over which the Block spans.

This mimics the relationship between Colon and Base.Slice.

source
BlockArrays.unblockFunction
unblock(block_sizes, inds, I)

Returns the indices associated with a block as a BlockSlice.

source
BlockArrays.SubBlockIteratorType
SubBlockIterator(subblock_lasts::Vector{Int}, block_lasts::Vector{Int})
 SubBlockIterator(A::AbstractArray, bs::NTuple{N,AbstractUnitRange{Int}} where N, dim::Integer)

Return an iterator over the BlockIndexRanges of the blocks specified by subblock_lasts. The Block index part of BlockIndexRange is determined by subblock_lasts. That is to say, the Block index first specifies one of the block represented by subblock_lasts and then the inner-block index range specifies the region within the block. Each such block corresponds to a block specified by blocklasts.

Note that the invariance subblock_lasts ⊂ block_lasts must hold and must be ensured by the caller.

Examples

julia> using BlockArrays
 
 julia> import BlockArrays: SubBlockIterator
@@ -54,7 +54,7 @@
  Block(1)[1:1]
  Block(2)[1:2]
  Block(3)[1:1]
- Block(3)[2:3]
source
BlockArrays.blockcheckbounds_indicesFunction
blockcheckbounds_indices(Bool, IA::Tuple{Vararg{BlockRange{1}}}, I::Tuple{Vararg{Integer}})

Return true if the "requested" indices in the tuple Block.(I) fall within the bounds of the "permitted" indices specified by the tuple IA. This function recursively consumes elements of these tuples in a 1-for-1 fashion.

The actual bounds-checking is performed by blockcheckindex.

Examples

julia> B = BlockArray(zeros(6,6), 1:3, 1:3);
+ Block(3)[2:3]
source
BlockArrays.blockcheckbounds_indicesFunction
blockcheckbounds_indices(Bool, IA::Tuple{Vararg{BlockRange{1}}}, I::Tuple{Vararg{Integer}})

Return true if the "requested" indices in the tuple Block.(I) fall within the bounds of the "permitted" indices specified by the tuple IA. This function recursively consumes elements of these tuples in a 1-for-1 fashion.

The actual bounds-checking is performed by blockcheckindex.

Examples

julia> B = BlockArray(zeros(6,6), 1:3, 1:3);
 
 julia> blockaxes(B)
 (BlockRange(Base.OneTo(3)), BlockRange(Base.OneTo(3)))
@@ -63,8 +63,8 @@
 true
 
 julia> BlockArrays.blockcheckbounds_indices(Bool, blockaxes(B), (4,1))
-false
source
BlockArrays.blockcheckindexFunction
blockcheckindex(Bool, inds::BlockRange{1}, index::Integer)

Return true if Block(index) is within the bounds of inds.

Examples

julia> BlockArrays.blockcheckindex(Bool, BlockRange(1:2), 1)
+false
source
BlockArrays.blockcheckindexFunction
blockcheckindex(Bool, inds::BlockRange{1}, index::Integer)

Return true if Block(index) is within the bounds of inds.

Examples

julia> BlockArrays.blockcheckindex(Bool, BlockRange(1:2), 1)
 true
 
 julia> BlockArrays.blockcheckindex(Bool, BlockRange(1:2), 3)
-false
source
+falsesource diff --git a/dev/lib/public/index.html b/dev/lib/public/index.html index d757d54a..915ba193 100644 --- a/dev/lib/public/index.html +++ b/dev/lib/public/index.html @@ -1,5 +1,5 @@ -Public Documentation · BlockArrays.jl

Public Documentation

Documentation for BlockArrays.jl's public interface.

See Internal Documentation for internal package docs covering all submodules.

Contents

Index

AbstractBlockArray interface

This sections defines the functions a subtype of AbstractBlockArray should define to be a part of the AbstractBlockArray interface. An AbstractBlockArray{T, N} is a subtype of AbstractArray{T,N} and should therefore also fulfill the AbstractArray interface.

BlockArrays.AbstractBlockArrayType
abstract AbstractBlockArray{T, N} <: AbstractArray{T, N}

The abstract type that represents a blocked array. Types that implement the AbstractBlockArray interface should subtype from this type.

** Typealiases **

  • AbstractBlockMatrix{T} -> AbstractBlockArray{T, 2}

  • AbstractBlockVector{T} -> AbstractBlockArray{T, 1}

  • AbstractBlockVecOrMat{T} -> Union{AbstractBlockMatrix{T}, AbstractBlockVector{T}}

source
BlockArrays.BlockBoundsErrorType
BlockBoundsError([A], [inds...])

Thrown when a block indexing operation into a block array, A, tried to access an out-of-bounds block, inds.

source
BlockArrays.BlockType
Block(inds...)

A Block is simply a wrapper around a set of indices or enums so that it can be used to dispatch on. By indexing a AbstractBlockArray with a Block the a block at that block index will be returned instead of a single element.

julia> A = BlockArray(ones(2,3), [1, 1], [2, 1])
+Public Documentation · BlockArrays.jl

Public Documentation

Documentation for BlockArrays.jl's public interface.

See Internal Documentation for internal package docs covering all submodules.

Contents

Index

AbstractBlockArray interface

This sections defines the functions a subtype of AbstractBlockArray should define to be a part of the AbstractBlockArray interface. An AbstractBlockArray{T, N} is a subtype of AbstractArray{T,N} and should therefore also fulfill the AbstractArray interface.

BlockArrays.AbstractBlockArrayType
abstract AbstractBlockArray{T, N} <: AbstractArray{T, N}

The abstract type that represents a blocked array. Types that implement the AbstractBlockArray interface should subtype from this type.

** Typealiases **

  • AbstractBlockMatrix{T} -> AbstractBlockArray{T, 2}

  • AbstractBlockVector{T} -> AbstractBlockArray{T, 1}

  • AbstractBlockVecOrMat{T} -> Union{AbstractBlockMatrix{T}, AbstractBlockVector{T}}

source
BlockArrays.BlockBoundsErrorType
BlockBoundsError([A], [inds...])

Thrown when a block indexing operation into a block array, A, tried to access an out-of-bounds block, inds.

source
BlockArrays.BlockType
Block(inds...)

A Block is simply a wrapper around a set of indices or enums so that it can be used to dispatch on. By indexing a AbstractBlockArray with a Block the a block at that block index will be returned instead of a single element.

julia> A = BlockArray(ones(2,3), [1, 1], [2, 1])
 2×2-blocked 2×3 BlockMatrix{Float64}:
  1.0  1.0  │  1.0
  ──────────┼─────
@@ -7,7 +7,7 @@
 
 julia> A[Block(1, 1)]
 1×2 Matrix{Float64}:
- 1.0  1.0
source
BlockArrays.BlockIndexType
BlockIndex{N}

A BlockIndex is an index which stores a global index in two parts: the block and the offset index into the block.

It can be used to index into BlockArrays in the following manner:

julia> arr = Array(reshape(1:25, (5,5)));
+ 1.0  1.0
source
BlockArrays.BlockIndexType
BlockIndex{N}

A BlockIndex is an index which stores a global index in two parts: the block and the offset index into the block.

It can be used to index into BlockArrays in the following manner:

julia> arr = Array(reshape(1:25, (5,5)));
 
 julia> a = BlockedArray(arr, [3,2], [1,4])
 2×2-blocked 5×5 BlockedMatrix{Int64}:
@@ -22,7 +22,7 @@
 11
 
 julia> a[BlockIndex((2,2), (2,3))]
-20
source
BlockArrays.blockaxesFunction
blockaxes(A::AbstractArray)

Return the tuple of valid block indices for array A.

Examples

julia> A = BlockArray([1,2,3],[2,1])
+20
source
BlockArrays.blockaxesFunction
blockaxes(A::AbstractArray)

Return the tuple of valid block indices for array A.

Examples

julia> A = BlockArray([1,2,3],[2,1])
 2-blocked 3-element BlockVector{Int64}:
  1
  2
@@ -40,7 +40,7 @@
  0.0  │  0.0  0.0  │  0.0
 
 julia> blockaxes(B)
-(BlockRange(Base.OneTo(2)), BlockRange(Base.OneTo(3)))
source
blockaxes(A::AbstractArray, d::Int)

Return the valid range of block indices for array A along dimension d.

Examples

julia> A = BlockArray([1,2,3], [2,1])
+(BlockRange(Base.OneTo(2)), BlockRange(Base.OneTo(3)))
source
blockaxes(A::AbstractArray, d::Int)

Return the valid range of block indices for array A along dimension d.

Examples

julia> A = BlockArray([1,2,3], [2,1])
 2-blocked 3-element BlockVector{Int64}:
  1
  2
@@ -53,7 +53,7 @@
 julia> blockaxes(A,1) |> collect
 2-element Vector{Block{1, Int64}}:
  Block(1)
- Block(2)
source
BlockArrays.blockisequalFunction
blockisequal(a::AbstractUnitRange{<:Integer}, b::AbstractUnitRange{<:Integer})

Check if a and b have the same block structure.

Examples

julia> b1 = blockedrange([1,2])
+ Block(2)
source
BlockArrays.blockisequalFunction
blockisequal(a::AbstractUnitRange{<:Integer}, b::AbstractUnitRange{<:Integer})

Check if a and b have the same block structure.

Examples

julia> b1 = blockedrange([1,2])
 2-blocked 3-element BlockedOneTo{Int64, Vector{Int64}}:
  1
  ─
@@ -72,7 +72,7 @@
 true
 
 julia> blockisequal(b1, b2)
-false
source
blockisequal(a::Tuple, b::Tuple)

Return if the tuples satisfy blockisequal elementwise.

source
BlockArrays.blocksizeFunction
blocksize(A::AbstractArray)
+false
source
blockisequal(a::Tuple, b::Tuple)

Return if the tuples satisfy blockisequal elementwise.

source
BlockArrays.blocksizeFunction
blocksize(A::AbstractArray)
 blocksize(A::AbstractArray, i::Int)

Return the tuple of the number of blocks along each dimension. See also size and blocksizes.

Examples

julia> A = BlockArray(ones(3,3),[2,1],[1,1,1])
 2×3-blocked 3×3 BlockMatrix{Float64}:
  1.0  │  1.0  │  1.0
@@ -84,7 +84,7 @@
 (2, 3)
 
 julia> blocksize(A,2)
-3
source
BlockArrays.blockfirstsFunction
blockfirsts(a::AbstractUnitRange{<:Integer})

Return the first index of each block of a.

Examples

julia> b = blockedrange([1,2,3])
+3
source
BlockArrays.blockfirstsFunction
blockfirsts(a::AbstractUnitRange{<:Integer})

Return the first index of each block of a.

Examples

julia> b = blockedrange([1,2,3])
 3-blocked 6-element BlockedOneTo{Int64, Vector{Int64}}:
  1
  ─
@@ -99,7 +99,7 @@
 3-element Vector{Int64}:
  1
  2
- 4
source
BlockArrays.blocklastsFunction
blocklasts(a::AbstractUnitRange{<:Integer})

Return the last index of each block of a.

Examples

julia> b = blockedrange([1,2,3])
+ 4
source
BlockArrays.blocklastsFunction
blocklasts(a::AbstractUnitRange{<:Integer})

Return the last index of each block of a.

Examples

julia> b = blockedrange([1,2,3])
 3-blocked 6-element BlockedOneTo{Int64, Vector{Int64}}:
  1
  ─
@@ -114,7 +114,7 @@
 3-element Vector{Int64}:
  1
  3
- 6
source
BlockArrays.blocklengthsFunction
blocklengths(a::AbstractUnitRange{<:Integer})

Return the length of each block of a.

Examples

julia> b = blockedrange([1,2,3])
+ 6
source
BlockArrays.blocklengthsFunction
blocklengths(a::AbstractUnitRange{<:Integer})

Return the length of each block of a.

Examples

julia> b = blockedrange([1,2,3])
 3-blocked 6-element BlockedOneTo{Int64, Vector{Int64}}:
  1
  ─
@@ -129,7 +129,7 @@
 3-element Vector{Int64}:
  1
  2
- 3
source
BlockArrays.blocksizesFunction
blocksizes(A::AbstractArray)
 blocksizes(A::AbstractArray, d::Integer)

Return an iterator over the sizes of each block. See also size and blocksize.

Examples

julia> A = BlockArray(ones(3,3),[2,1],[1,1,1])
 2×3-blocked 3×3 BlockMatrix{Float64}:
  1.0  │  1.0  │  1.0
@@ -149,7 +149,7 @@
 3-element Vector{Int64}:
  1
  1
- 1
source
BlockArrays.blocksFunction
blocks(a::AbstractArray{T,N}) :: AbstractArray{<:AbstractArray{T,N},N}

Return the array-of-arrays view to a such that

blocks(a)[i₁, i₂, ..., iₙ] == a[Block(i₁), Block(i₂), ..., Block(iₙ)]

This function does not copy the blocks and give a mutable viwe to the original array. This is an "inverse" of mortar.

Examples

julia> bs1 = permutedims(reshape([
+ 1
source
BlockArrays.blocksFunction
blocks(a::AbstractArray{T,N}) :: AbstractArray{<:AbstractArray{T,N},N}

Return the array-of-arrays view to a such that

blocks(a)[i₁, i₂, ..., iₙ] == a[Block(i₁), Block(i₂), ..., Block(iₙ)]

This function does not copy the blocks and give a mutable viwe to the original array. This is an "inverse" of mortar.

Examples

julia> bs1 = permutedims(reshape([
                1ones(1, 3), 2ones(1, 2),
                3ones(2, 3), 4ones(2, 2),
            ], (2, 2)))
@@ -179,7 +179,7 @@
  100.0  100.0  100.0  │  2.0  2.0
  ─────────────────────┼──────────
    3.0    3.0    3.0  │  4.0  4.0
-   3.0    3.0    3.0  │  4.0  4.0
source
BlockArrays.eachblockFunction
eachblock(A::AbstractBlockArray)

Create a generator that iterates over each block of an AbstractBlockArray returning views.

julia> v = Array(reshape(1:6, (2, 3)))
+   3.0    3.0    3.0  │  4.0  4.0
source
BlockArrays.eachblockFunction
eachblock(A::AbstractBlockArray)

Create a generator that iterates over each block of an AbstractBlockArray returning views.

julia> v = Array(reshape(1:6, (2, 3)))
 2×3 Matrix{Int64}:
  1  3  5
  2  4  6
@@ -193,11 +193,11 @@
 julia> sum.(eachblock(A))
 2×2 Matrix{Int64}:
  4  5
- 6  6
source
BlockArrays.blockcheckboundsFunction
blockcheckbounds(A, inds...)

Throw a BlockBoundsError if the specified block indexes are not in bounds for the given block array. Subtypes of AbstractBlockArray should specialize this method if they need to provide custom block bounds checking behaviors.

julia> A = BlockArray(rand(2,3), [1,1], [2,1]);
+ 6  6
source
BlockArrays.blockcheckboundsFunction
blockcheckbounds(A, inds...)

Throw a BlockBoundsError if the specified block indexes are not in bounds for the given block array. Subtypes of AbstractBlockArray should specialize this method if they need to provide custom block bounds checking behaviors.

julia> A = BlockArray(rand(2,3), [1,1], [2,1]);
 
 julia> blockcheckbounds(A, 3, 2)
 ERROR: BlockBoundsError: attempt to access 2×2-blocked 2×3 BlockMatrix{Float64} at block index [3,2]
-[...]
source
BlockArrays.blockcolsupportFunction
blockcolsupport(A, j)

Return an iterator containing the possible non-zero blocks in the j-th block-column of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
+[...]
source
BlockArrays.blockcolsupportFunction
blockcolsupport(A, j)

Return an iterator containing the possible non-zero blocks in the j-th block-column of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
 2×3-blocked 3×3 BlockMatrix{Int64}:
  1  │  4  │  7
  ───┼─────┼───
@@ -207,7 +207,7 @@
 julia> BlockArrays.blockcolsupport(B, 2) |> collect
 2-element Vector{Block{1, Int64}}:
  Block(1)
- Block(2)
source
BlockArrays.blockrowsupportFunction
blockrowsupport(A, k)

Return an iterator containing the possible non-zero blocks in the k-th block-row of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
+ Block(2)
source
BlockArrays.blockrowsupportFunction
blockrowsupport(A, k)

Return an iterator containing the possible non-zero blocks in the k-th block-row of A.

Examples

julia> B = BlockArray(collect(reshape(1:9, 3, 3)), [1,2], [1,1,1])
 2×3-blocked 3×3 BlockMatrix{Int64}:
  1  │  4  │  7
  ───┼─────┼───
@@ -218,7 +218,7 @@
 3-element Vector{Block{1, Int64}}:
  Block(1)
  Block(2)
- Block(3)
source
BlockArrays.blockedrangeFunction
blockedrange(blocklengths::Union{Tuple, AbstractVector})
 blockedrange(first::Integer, blocklengths::Union{Tuple, AbstractVector})

Return a blocked AbstractUnitRange{<:Integer} with the block sizes being blocklengths. If first is provided, this is used as the first value of the range. Otherwise, if only the block lengths are provided, first is assumed to be 1.

Examples

julia> blockedrange([1,2])
 2-blocked 3-element BlockedOneTo{Int64, Vector{Int64}}:
  1
@@ -231,7 +231,7 @@
  2
  ─
  3
- 4
source

BlockArray

BlockArrays.BlockArrayType
BlockArray{T, N, R<:AbstractArray{<:AbstractArray{T,N},N}, BS<:Tuple{Vararg{AbstractUnitRange{<:Integer},N}}} <: AbstractBlockArray{T, N}

A BlockArray is an array where each block is stored contiguously. This means that insertions and retrieval of blocks can be very fast and non allocating since no copying of data is needed.

In the type definition, R defines the array type that holds the blocks, for example Matrix{Matrix{Float64}}.

source
BlockArrays.BlockArrayMethod
BlockArray(::UndefBlocksInitializer, ::Type{R}, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {N,R<:AbstractArray{<:Any,N}}

Construct a N-dim BlockArray with uninitialized blocks from a block type R, with sizes defined by block_sizes. Each block must be allocated before being accessed.

Examples

julia> B = BlockArray(undef_blocks, Matrix{Float64}, [1,3], [2,2])
+ 4
source

BlockArray

BlockArrays.BlockArrayType
BlockArray{T, N, R<:AbstractArray{<:AbstractArray{T,N},N}, BS<:Tuple{Vararg{AbstractUnitRange{<:Integer},N}}} <: AbstractBlockArray{T, N}

A BlockArray is an array where each block is stored contiguously. This means that insertions and retrieval of blocks can be very fast and non allocating since no copying of data is needed.

In the type definition, R defines the array type that holds the blocks, for example Matrix{Matrix{Float64}}.

source
BlockArrays.BlockArrayMethod
BlockArray(::UndefBlocksInitializer, ::Type{R}, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {N,R<:AbstractArray{<:Any,N}}

Construct a N-dim BlockArray with uninitialized blocks from a block type R, with sizes defined by block_sizes. Each block must be allocated before being accessed.

Examples

julia> B = BlockArray(undef_blocks, Matrix{Float64}, [1,3], [2,2])
 2×2-blocked 4×4 BlockMatrix{Float64}:
  #undef  #undef  │  #undef  #undef
  ────────────────┼────────────────
@@ -247,7 +247,7 @@
 julia> B = BlockArray(undef_blocks, SparseMatrixCSC{Float64,Int}, [1,3], [2,2]);
 
 julia> typeof(blocks(B))
-Matrix{SparseMatrixCSC{Float64, Int64}} (alias for Array{SparseMatrixCSC{Float64, Int64}, 2})

See also undef_blocks, UndefBlocksInitializer

source
BlockArrays.BlockArrayMethod
BlockArray{T}(::UndefBlocksInitializer, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {T,N}

Construct a N-dim BlockArray with uninitialized blocks of type Array{T,N}, with sizes defined by block_sizes. Each block must be allocated before being accessed.

Examples

julia> B = BlockArray{Float64}(undef_blocks, [1,2], [1,2])
+Matrix{SparseMatrixCSC{Float64, Int64}} (alias for Array{SparseMatrixCSC{Float64, Int64}, 2})

See also undef_blocks, UndefBlocksInitializer

source
BlockArrays.BlockArrayMethod
BlockArray{T}(::UndefBlocksInitializer, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {T,N}

Construct a N-dim BlockArray with uninitialized blocks of type Array{T,N}, with sizes defined by block_sizes. Each block must be allocated before being accessed.

Examples

julia> B = BlockArray{Float64}(undef_blocks, [1,2], [1,2])
 2×2-blocked 3×3 BlockMatrix{Float64}:
  #undef  │  #undef  #undef
  ────────┼────────────────
@@ -280,7 +280,7 @@
  1
  ─
  2
- 3

See also undef_blocks, UndefBlocksInitializer

source
BlockArrays.BlockArrayMethod
BlockArray{T}(::UndefInitializer, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {T, N}

Construct a N-dim BlockArray with blocks of type Array{T,N}, with sizes defined by block_sizes. The blocks are allocated using similar, and the elements in each block are therefore unitialized.

Examples

julia> B = BlockArray{Int8}(undef, [1,2]);
+ 3

See also undef_blocks, UndefBlocksInitializer

source
BlockArrays.BlockArrayMethod
BlockArray{T}(::UndefInitializer, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {T, N}

Construct a N-dim BlockArray with blocks of type Array{T,N}, with sizes defined by block_sizes. The blocks are allocated using similar, and the elements in each block are therefore unitialized.

Examples

julia> B = BlockArray{Int8}(undef, [1,2]);
 
 julia> B[Block(1)] .= 2;
 
@@ -291,17 +291,17 @@
  2
  ─
  3
- 3
source
BlockArrays.undef_blocksConstant
undef_blocks

Alias for UndefBlocksInitializer(), which constructs an instance of the singleton type UndefBlocksInitializer, used in block array initialization to indicate the array-constructor-caller would like an uninitialized block array.

Examples

julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
+ 3
source
BlockArrays.undef_blocksConstant
undef_blocks

Alias for UndefBlocksInitializer(), which constructs an instance of the singleton type UndefBlocksInitializer, used in block array initialization to indicate the array-constructor-caller would like an uninitialized block array.

Examples

julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
 2×2-blocked 3×5 BlockMatrix{Float32}:
  #undef  #undef  #undef  │  #undef  #undef
  ────────────────────────┼────────────────
  #undef  #undef  #undef  │  #undef  #undef
- #undef  #undef  #undef  │  #undef  #undef
source
BlockArrays.UndefBlocksInitializerType
UndefBlocksInitializer

Singleton type used in block array initialization, indicating the array-constructor-caller would like an uninitialized block array. See also undef_blocks, an alias for UndefBlocksInitializer().

Examples

julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
+ #undef  #undef  #undef  │  #undef  #undef
source
BlockArrays.UndefBlocksInitializerType
UndefBlocksInitializer

Singleton type used in block array initialization, indicating the array-constructor-caller would like an uninitialized block array. See also undef_blocks, an alias for UndefBlocksInitializer().

Examples

julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
 2×2-blocked 3×5 BlockMatrix{Float32}:
  #undef  #undef  #undef  │  #undef  #undef
  ────────────────────────┼────────────────
  #undef  #undef  #undef  │  #undef  #undef
- #undef  #undef  #undef  │  #undef  #undef
source
BlockArrays.mortarFunction
mortar(blocks::AbstractArray)
 mortar(blocks::AbstractArray{R, N}, sizes_1, sizes_2, ..., sizes_N)
 mortar(blocks::AbstractArray{R, N}, block_sizes::Tuple{Vararg{AbstractUnitRange{<:Integer},N}})

Construct a BlockArray from blocks. block_sizes is computed from blocks if it is not given.

This is an "inverse" of blocks.

Examples

julia> arrays = permutedims(reshape([
                   fill(1.0, 1, 3), fill(2.0, 1, 2),
@@ -322,7 +322,7 @@
                   (fill(1.0, 1, 3), fill(2.0, 1, 2)),
                   (fill(3.0, 2, 3), fill(4.0, 2, 2)),
               )
-true
source
mortar((block_11, ..., block_1m), ... (block_n1, ..., block_nm))

Construct a BlockMatrix with n * m blocks. Each block_ij must be an AbstractMatrix.

source
BlockArrays.blockappend!Function
blockappend!(dest::BlockVector, sources...) -> dest

Append blocks from sources to dest. The number of blocks in dest are increased by sum(blocklength, sources).

This function avoids copying the elements of the blocks in sources when these blocks are compatible with dest. Importantly, this means that mutating sources afterwards alters the items in dest and it may even break the invariance of dest if the length of sources are changed.

The blocks in dest must not alias with sources or components of them. For example, the result of blockappend!(x, x) is undefined.

Examples

julia> using BlockArrays
+true
source
mortar((block_11, ..., block_1m), ... (block_n1, ..., block_nm))

Construct a BlockMatrix with n * m blocks. Each block_ij must be an AbstractMatrix.

source
BlockArrays.blockappend!Function
blockappend!(dest::BlockVector, sources...) -> dest

Append blocks from sources to dest. The number of blocks in dest are increased by sum(blocklength, sources).

This function avoids copying the elements of the blocks in sources when these blocks are compatible with dest. Importantly, this means that mutating sources afterwards alters the items in dest and it may even break the invariance of dest if the length of sources are changed.

The blocks in dest must not alias with sources or components of them. For example, the result of blockappend!(x, x) is undefined.

Examples

julia> using BlockArrays
 
 julia> blockappend!(mortar([[1], [2, 3]]), mortar([[4, 5]]))
 3-blocked 5-element BlockVector{Int64}:
@@ -332,7 +332,7 @@
  3
  ─
  4
- 5
source
BlockArrays.blockpush!Function
blockpush!(dest::BlockVector, blocks...) -> dest

Push blocks to the end of dest.

This function avoids copying the elements of the blocks when these blocks are compatible with dest. Importantly, this means that mutating blocks afterwards alters the items in dest and it may even break the invariance of dest if the length of blocks are changed.

Examples

julia> using BlockArrays
+ 5
source
BlockArrays.blockpush!Function
blockpush!(dest::BlockVector, blocks...) -> dest

Push blocks to the end of dest.

This function avoids copying the elements of the blocks when these blocks are compatible with dest. Importantly, this means that mutating blocks afterwards alters the items in dest and it may even break the invariance of dest if the length of blocks are changed.

Examples

julia> using BlockArrays
 
 julia> blockpush!(mortar([[1], [2, 3]]), [4, 5], [6])
 4-blocked 6-element BlockVector{Int64}:
@@ -344,7 +344,7 @@
  4
  5
  ─
- 6
source
BlockArrays.blockpushfirst!Function
blockpushfirst!(dest::BlockVector, blocks...) -> dest

Push blocks to the beginning of dest. See also blockpush!.

This function avoids copying the elements of the blocks when these blocks are compatible with dest. Importantly, this means that mutating blocks afterwards alters the items in dest and it may even break the invariance of dest if the length of blocks are changed.

Examples

julia> using BlockArrays
+ 6
source
BlockArrays.blockpushfirst!Function
blockpushfirst!(dest::BlockVector, blocks...) -> dest

Push blocks to the beginning of dest. See also blockpush!.

This function avoids copying the elements of the blocks when these blocks are compatible with dest. Importantly, this means that mutating blocks afterwards alters the items in dest and it may even break the invariance of dest if the length of blocks are changed.

Examples

julia> using BlockArrays
 
 julia> blockpushfirst!(mortar([[1], [2, 3]]), [4, 5], [6])
 4-blocked 6-element BlockVector{Int64}:
@@ -356,7 +356,7 @@
  1
  ─
  2
- 3
source
BlockArrays.blockpop!Function
blockpop!(A::BlockVector) -> block

Pop a block from the end of dest.

Examples

julia> using BlockArrays
+ 3
source
BlockArrays.blockpop!Function
blockpop!(A::BlockVector) -> block

Pop a block from the end of dest.

Examples

julia> using BlockArrays
 
 julia> A = mortar([[1], [2, 3]]);
 
@@ -367,7 +367,7 @@
 
 julia> A
 1-blocked 1-element BlockVector{Int64}:
- 1
source
BlockArrays.blockpopfirst!Function
blockpopfirst!(dest::BlockVector) -> block

Pop a block from the beginning of dest.

Examples

julia> using BlockArrays
+ 1
source
BlockArrays.blockpopfirst!Function
blockpopfirst!(dest::BlockVector) -> block

Pop a block from the beginning of dest.

Examples

julia> using BlockArrays
 
 julia> A = mortar([[1], [2, 3]]);
 
@@ -378,7 +378,7 @@
 julia> A
 1-blocked 2-element BlockVector{Int64}:
  2
- 3
source
Base.append!Function
append!(dest::BlockVector, sources...)

Append items from sources to the last block of dest.

The blocks in dest must not alias with sources or components of them. For example, the result of append!(x, x) is undefined.

Examples

julia> using BlockArrays
+ 3
source
Base.append!Function
append!(dest::BlockVector, sources...)

Append items from sources to the last block of dest.

The blocks in dest must not alias with sources or components of them. For example, the result of append!(x, x) is undefined.

Examples

julia> using BlockArrays
 
 julia> append!(mortar([[1], [2, 3]]), mortar([[4], [5]]))
 2-blocked 5-element BlockVector{Int64}:
@@ -387,7 +387,7 @@
  2
  3
  4
- 5
source
Base.push!Function
push!(dest::BlockVector, items...)

Push items to the end of the last block.

source
Base.pushfirst!Function
pushfirst!(A::BlockVector, items...)

Push items to the beginning of the first block.

source
Base.pop!Function
pop!(A::BlockVector)

Pop the last element from the last non-empty block. Remove all empty blocks at the end.

source
Base.popfirst!Function
popfirst!(A::BlockVector)

Pop the first element from the first non-empty block. Remove all empty blocks at the beginning.

source

BlockedArray

BlockArrays.BlockedArrayType
BlockedArray{T, N, R} <: AbstractBlockArray{T, N}

A BlockedArray is similar to a BlockArray except the full array is stored contiguously instead of block by block. This means that is not possible to insert and retrieve blocks without copying data. On the other hand parent on a BlockedArray is instead instant since it just returns the wrapped array.

When iteratively solving a set of equations with a gradient method the Jacobian typically has a block structure. It can be convenient to use a BlockedArray to build up the Jacobian block by block and then pass the resulting matrix to a direct solver using parent.

Examples

julia> A = zeros(Int, 2, 3);
+ 5
source
Base.push!Function
push!(dest::BlockVector, items...)

Push items to the end of the last block.

source
Base.pushfirst!Function
pushfirst!(A::BlockVector, items...)

Push items to the beginning of the first block.

source
Base.pop!Function
pop!(A::BlockVector)

Pop the last element from the last non-empty block. Remove all empty blocks at the end.

source
Base.popfirst!Function
popfirst!(A::BlockVector)

Pop the first element from the first non-empty block. Remove all empty blocks at the beginning.

source

BlockedArray

BlockArrays.BlockedArrayType
BlockedArray{T, N, R} <: AbstractBlockArray{T, N}

A BlockedArray is similar to a BlockArray except the full array is stored contiguously instead of block by block. This means that is not possible to insert and retrieve blocks without copying data. On the other hand parent on a BlockedArray is instead instant since it just returns the wrapped array.

When iteratively solving a set of equations with a gradient method the Jacobian typically has a block structure. It can be convenient to use a BlockedArray to build up the Jacobian block by block and then pass the resulting matrix to a direct solver using parent.

Examples

julia> A = zeros(Int, 2, 3);
 
 julia> B = BlockedArray(A, [1,1], [2,1])
 2×2-blocked 2×3 BlockedMatrix{Int64}:
@@ -405,7 +405,7 @@
 julia> A
 2×3 Matrix{Int64}:
  4  4  0
- 0  0  0
source
BlockArrays.BlockedVectorType
BlockedVector{T}

Alias for BlockedArray{T, 1}

julia> A = [1:6;]
 6-element Vector{Int64}:
  1
  2
@@ -423,7 +423,7 @@
  4
  5
  ─
- 6
source
BlockArrays.BlockedMatrixType
BlockedMatrix{T}

Alias for BlockedArray{T, 2}

julia> A = reshape([1:6;], 2, 3)
 2×3 Matrix{Int64}:
  1  3  5
  2  4  6
@@ -432,7 +432,7 @@
 2×2-blocked 2×3 BlockedMatrix{Int64}:
  1  │  3  5
  ───┼──────
- 2  │  4  6
source
Base.resize!Function
resize!(a::BlockVector, N::Block) -> BlockedVector

Resize a to contain the first N blocks, returning a new BlockVector sharing memory with a. If N is smaller than the current collection block length, the first N blocks will be retained. N is not allowed to be larger.

source
resize!(a::BlockedVector, N::Block) -> BlockedVector

Resize a to contain the first N blocks, returning a new BlockedVector sharing memory with a. If N is smaller than the current collection block length, the first N blocks will be retained. N is not allowed to be larger.

source

Kronecker products

BlockArrays.blockkronFunction
blockkron(A...)

Return a blocked version of kron(A...) with the natural block-structure imposed.

Examples

julia> A = reshape(1:9, 3, 3)
+ 2  │  4  6
source
Base.resize!Function
resize!(a::BlockVector, N::Block) -> BlockedVector

Resize a to contain the first N blocks, returning a new BlockVector sharing memory with a. If N is smaller than the current collection block length, the first N blocks will be retained. N is not allowed to be larger.

source
resize!(a::BlockedVector, N::Block) -> BlockedVector

Resize a to contain the first N blocks, returning a new BlockedVector sharing memory with a. If N is smaller than the current collection block length, the first N blocks will be retained. N is not allowed to be larger.

source

Kronecker products

BlockArrays.blockkronFunction
blockkron(A...)

Return a blocked version of kron(A...) with the natural block-structure imposed.

Examples

julia> A = reshape(1:9, 3, 3)
 3×3 reshape(::UnitRange{Int64}, 3, 3) with eltype Int64:
  1  4  7
  2  5  8
@@ -450,7 +450,7 @@
  ───────────┼──────────────┼────────────
  3  12  21  │   6  24  42  │   9  36  63
  6  15  24  │  12  30  48  │  18  45  72
- 9  18  27  │  18  36  54  │  27  54  81
source
BlockArrays.BlockKronType
BlockKron(A...)

Create a lazy representation of kron(A...) with the natural block-structure imposed. This is a component in blockkron(A...).

source
BlockArrays.blockvecFunction
blockvec(A::AbstractMatrix)

creates a blocked version of vec(A), with the block structure used to represent the columns.

Examples

julia> A = reshape(1:9, 3, 3)
+ 9  18  27  │  18  36  54  │  27  54  81
source
BlockArrays.BlockKronType
BlockKron(A...)

Create a lazy representation of kron(A...) with the natural block-structure imposed. This is a component in blockkron(A...).

source
BlockArrays.blockvecFunction
blockvec(A::AbstractMatrix)

creates a blocked version of vec(A), with the block structure used to represent the columns.

Examples

julia> A = reshape(1:9, 3, 3)
 3×3 reshape(::UnitRange{Int64}, 3, 3) with eltype Int64:
  1  4  7
  2  5  8
@@ -468,4 +468,4 @@
  ─
  7
  8
- 9
source
BlockArrays.khatri_raoFunction
khatri_rao(A, B)

References

  • Liu, Shuangzhe, and Gõtz Trenkler (2008) Hadamard, Khatri-Rao, Kronecker and Other Matrix Products. International J. Information and Systems Sciences 4, 160–177.
  • Khatri, C. G., and Rao, C. Radhakrishna (1968) Solutions to Some Functional Equations and Their Applications to Characterization of Probability Distributions. Sankhya: Indian J. Statistics, Series A 30, 167–180.
source
+ 9
source
BlockArrays.khatri_raoFunction
khatri_rao(A, B)

References

  • Liu, Shuangzhe, and Gõtz Trenkler (2008) Hadamard, Khatri-Rao, Kronecker and Other Matrix Products. International J. Information and Systems Sciences 4, 160–177.
  • Khatri, C. G., and Rao, C. Radhakrishna (1968) Solutions to Some Functional Equations and Their Applications to Characterization of Probability Distributions. Sankhya: Indian J. Statistics, Series A 30, 167–180.
source
diff --git a/dev/man/abstractblockarrayinterface/index.html b/dev/man/abstractblockarrayinterface/index.html index dfdbe1c3..17da0cc3 100644 --- a/dev/man/abstractblockarrayinterface/index.html +++ b/dev/man/abstractblockarrayinterface/index.html @@ -20,4 +20,4 @@ 0.620099 0.364706 │ 0.0311643 0.27895 0.73477 0.215712 0.923602 │ 0.279944 0.994497 0.383706 0.569955 0.754047 │ 0.0190392 0.548297 0.687052
julia> blockcheckbounds(A, 5, 3)
-ERROR: BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Float64}} at block index [5,3]
+ERROR: BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Float64}} at block index [5,3] diff --git a/dev/man/blockarrays/index.html b/dev/man/blockarrays/index.html index 47bca68f..e65aceb1 100644 --- a/dev/man/blockarrays/index.html +++ b/dev/man/blockarrays/index.html @@ -94,4 +94,4 @@ 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 1.0 0.0 0.0 + 0.0 0.0 1.0 0.0 0.0 diff --git a/dev/man/blockedarrays/index.html b/dev/man/blockedarrays/index.html index 50ee558c..21d42913 100644 --- a/dev/man/blockedarrays/index.html +++ b/dev/man/blockedarrays/index.html @@ -30,4 +30,4 @@ julia> view(A, Block(2)) .= [3,4]; A[Block(2)] 2-element Vector{Float64}: 3.0 - 4.0

Note that, in memory, each block is in a BLAS-Level 3 compatible format, so that algebra with blocks is highly efficient.

+ 4.0

Note that, in memory, each block is in a BLAS-Level 3 compatible format, so that algebra with blocks is highly efficient.

diff --git a/dev/objects.inv b/dev/objects.inv index 0253a508..ad3da84e 100644 Binary files a/dev/objects.inv and b/dev/objects.inv differ