Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blkdiagM only supports square matrices #2

Closed
aminya opened this issue Aug 15, 2019 · 2 comments
Closed

blkdiagM only supports square matrices #2

aminya opened this issue Aug 15, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@aminya
Copy link
Member

aminya commented Aug 15, 2019

blkdiagM uses BlockDiagonals to generate Arrays fast, however now, it only supports square matrices.

Different tasks of this to do plan:

  1. Creating an issue in BlockDiagonals

Achievement check:

A1 = ones(2,2);
A2 = 2*ones(3,2);
A3 = 3*ones(2,3);
B = blkdiagM(A1,A2,A3)

B = 7×7

     1     1     0     0     0     0     0
     1     1     0     0     0     0     0
     0     0     2     2     0     0     0
     0     0     2     2     0     0     0
     0     0     2     2     0     0     0
     0     0     0     0     3     3     3
     0     0     0     0     3     3     3
@aminya
Copy link
Member Author

aminya commented Aug 15, 2019

Manual blkdiagM was written with non-square support. Until BlockDiagonals adds returning Arrays and also supports non-square matrices

function blkdiagM(in...)

    argNum=length(in)

    inSize1=collect( size.(in,1) )
    outSize1 = vcat( [0], cumsum(inSize1,dims=1) )

    inSize2=collect( size.(in,2) )
    outSize2 = vcat( [0], cumsum(inSize2,dims=1) )

    out = zeros(last(outSize1),last(outSize2));
    for k=1:argNum
        out[outSize1[k]+1:outSize1[k+1],outSize2[k]+1:outSize2[k+1]] = in[k];
    end

    return out
end

@aminya
Copy link
Member Author

aminya commented Aug 18, 2019

Is fixed in a57a52e using https://github.com/aminya/BlockDiagonals.jl

@aminya aminya closed this as completed Aug 18, 2019
@aminya aminya added the enhancement New feature or request label Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant