I essentially would like to do the opposite of this question. I have two matrixes that have been split with np.tril or np.triu and I want to recombine them into a single matrix.
A = array([[ 0. , 0. , 0. ],
[ 0.1, 0. , 0. ],
[ 0.6, 0.5, 0. ]])
B = array([[ 0. , 0.4, 0.8],
[ 0. , 0. , 0.3],
[ 0. , 0. , 0. ]])
And what I want it to look like is
array([[ 0. , 0.4, 0.8],
[ 0.1, 0. , 0.3],
[ 0.6, 0.5, 0. ]])
Is there an inbuilt numpy function to do this?
You mean A+B ?
import numpy
A = numpy.array([[ 0. , 0. , 0. ],
[ 0.1, 0. , 0. ],
[ 0.6, 0.5, 0. ]])
B = numpy.array([[ 0. , 0.4, 0.8],
[ 0. , 0. , 0.3],
[ 0. , 0. , 0. ]])
print A+B
returns
array([[ 0. , 0.4, 0.8],
[ 0.1, 0. , 0.3],
[ 0.6, 0.5, 0. ]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With