let it go

Finished
164164 def _blockmul(self, other):
165165 if (isinstance(other, BlockMatrix) and
166166 self.colblocksizes == other.rowblocksizes):
167 return BlockMatrix(self.blocks*other.blocks)
167 # Perform the block multiplication
168 result_blocks = self.blocks * other.blocks
169
170 # Convert any scalar zeros back to ZeroMatrix objects
171 # to preserve the matrix structure needed for block operations
172 from sympy.matrices.immutable import ImmutableDenseMatrix
173 from sympy.core.numbers import Zero
174
175 # Create a new matrix with the same structure but convert zeros
176 new_data = []
177 for i in range(result_blocks.rows):
178 row = []
179 for j in range(result_blocks.cols):
180 element = result_blocks[i, j]
181 # If we have a scalar zero, convert it back to ZeroMatrix
182 # with appropriate dimensions
183 if isinstance(element, Zero):
184 # Get the dimensions from the original blocks
185 # Row dimension from self's row block i
186 row_dim = self.rowblocksizes[i]
187 # Col dimension from other's col block j
188 col_dim = other.colblocksizes[j]
189 row.append(ZeroMatrix(row_dim, col_dim))
190 else:
191 row.append(element)
192 new_data.append(row)
193
194 return BlockMatrix(new_data)
168195
169196 return self * other
170197
Test NameStatus
test_zero_matrix_add
Fail
test_issue_17624
Pass
test_bc_matmul
Pass
test_bc_matadd
Pass
test_bc_transpose
Pass
test_bc_dist_diag
Pass
test_block_plus_ident
Pass
test_BlockMatrix
Pass
test_block_collapse_explicit_matrices
Pass
test_BlockMatrix_trace
Pass
test_BlockMatrix_Determinant
Pass
test_squareBlockMatrix
Pass
test_BlockDiagMatrix
Pass
test_blockcut
Pass
test_reblock_2x2
Pass
test_deblock
Pass
test_sort_key
Pass
test_matadd_sympify
Pass
test_matadd_of_matrices
Pass
test_doit_args
Pass
test_generic_identity
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.