Multiplying two complex SparseArray objects, yielding empty SparseArray crashes kernel
This seemed to work for me...
test1 = DiagonalMatrix[SparseArray[{1. + 0. I, 0. I}]];
test2 = DiagonalMatrix[SparseArray[{0. I, 1. I}]];
test1.test2
Using N[...]
didn't work for me either. If you can tolerate the really tiny error on the order of $10^{-308}$ then here's a workaround which adds the $MinMachineNumber
to the first matrix elements:
test1 = SparseArray[DiagonalMatrix[{1., 0} + $MinMachineNumber]]
test2 = SparseArray[DiagonalMatrix[{0, I}]]
test1.test2
This seems to work, and returns an empty SparseArray
as desired
test1 = SparseArray[DiagonalMatrix[SetPrecision[{1., 0}, $MachinePrecision]]]
test2 = SparseArray[DiagonalMatrix[{0, I}]]
test1.test2