# how to partition the matrix into blocks of different dimensions

i have a matrix

A =
{{3., -1., 0, -1., 0, -1., 0},
{-1., 2., -1., 0, 0, 0, 0},
{0, -1.,1., 0, 0, 0, 0},
{-1., 0, 0, 2., -1., 0, 0},
{0, 0, 0, -1., 1., 0, 0},
{-1., 0, 0, 0, 0, 2., -1.},
{0, 0, 0, 0, 0, -1., 1.}}


I want to partition in the form

{{A11,A12,A13,A14},
{A21,A22,A23,A24},
{A31,A32,A33,A34},
{A41,A42,A43,A44}}


where

A11={3};
A12=A13=A14={-1,0};
A21=A31=A41={{-1},{0}};
A22=A33=A44={{2,-1},{-1,1}}


and rest of the blocks are {{0,0},{0,0}}

You can use the undocumented internal function: InternalPartitionRagged:

A =
{{3, -1, 0, -1, 0, -1, 0},
{-1, 2, -1, 0, 0, 0, 0},
{0, -1, 1, 0, 0, 0, 0},
{-1, 0, 0, 2, -1, 0, 0},
{0, 0, 0, -1, 1, 0, 0},
{-1, 0, 0, 0, 0, 2, -1},
{0, 0, 0, 0, 0, -1, 1}}

output = InternalPartitionRagged[A, {{1, 2, 2, 2}, {1, 2, 2, 2}}]

{
{{{3}},{{-1,0}},{{-1,0}},{{-1,0}}},
{{{-1},{0}},{{2,-1},{-1,1}},{{0,0},{0,0}},{{0,0},{0,0}}},
{{{-1},{0}},{{0,0},{0,0}},{{2,-1},{-1,1}},{{0,0},{0,0}}},
{{{-1},{0}},{{0,0},{0,0}},{{0,0},{0,0}},{{2,-1},{-1,1}}}
}


A corresponding Grid:

Grid[A, Dividers -> {{True, {True, False}}, {True, {True, False}}}]


You can recombine the partitions with ArrayFlatten if needed:

ArrayFlatten[output] == A

True