Skip to content

Support having blocks with different eltypes #62

@nickrobinson251

Description

@nickrobinson251

Currently, in BlockDiagonal{T,V}, T is the eltype of the blocks and we require all blocks to have the same eltype (i.e.all(eltype.(blocks) .=== T)).

However, we could allow blocks to have different eltypes, with T being the common eltype. (i.e.all(eltype.(blocks) .<: T)), with T = promote_type(map(eltype, blocks)...)`).

(suggested at https://github.com/invenia/BlockDiagonals.jl/pull/56/files#r576718519)

This is similar in spirit to #56 which generalises the V type parameters, but unlike #56, generalising T would be non-breaking as it'd only affects cases that are currently errors (and unlike #56 it doesn't change the meaning of T)

The main downside seems to be that this causes inference problems for rrules, which presumably has a performance cost for code using AD. See https://github.com/invenia/BlockDiagonals.jl/pull/56/files#r577136826

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions