How can I merge two trees, t
and s
, so as to form a square matrix below, where both trees starts from top-left (as shown), and occupy lower and upper triangular forms (in a transpose fashion). Trees can get larger. Diagonal contains zeros, but I will store some other information there later. Up to transpose, it doesn't matter which tree is on the bottom.
t = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}}
s = 10 t
output
{{0, 10, 10, 10, 10}, {1, 0, 20, 20, 20}, {1, 2, 0, 30, 30}, {1, 2, 3, 0, 40}, {1, 2, 3, 4, 0}}
or in matrix form:
ArrayPad[PadRight@t, {{1, 0}, {0, 1}}]
and the same fors
$\endgroup$