For vector A:
+A←3 4⍴1 0 1 0 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1
Divide it into composite matrices as follows:
+(⍴A)∘⍴¨⊂[2](,A)\BB⍴1,(B←+/,A)⍴0 1 0 0 0 0 0 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
How it works
First assign a number from 1 to B:
B←+/,A ⍝ 5
Create an identity matrix as described in this post: The most idiomatic way to create an identity matrix in the APL :
BB⍴1,(B←+/,A)⍴0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
Ravel source matrix:
,A ⍝ 1 0 1 0 1 0 0 0 0 1 0 1
Use a split matrix to expand the identity matrix. This creates a matrix in which each row is an uninhibited form of component matrices:
+(,A)\BB⍴1,(B←+/,A)⍴0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 0 0 0 0 1
Convert this matrix to a row vector:
+⊂[2](,A)\BB⍴1,(B←+/,A)⍴0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 0 0 0 0 1
Using the original form A (⍴A) , create the final matrices:
(⍴A)∘⍴¨⊂[2](,A)\BB⍴1,(B←+/,A)⍴0 1 0 0 0 0 0 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1