yahoo

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 block multiplication manually to preserve ZeroMatrix objects
168 from sympy.matrices.immutable import ImmutableDenseMatrix
169
170 self_blocks = self.blocks
171 other_blocks = other.blocks
172
173 # Get block dimensions
174 m, n = self_blocks.shape # self has m rows, n cols of blocks
175 n2, p = other_blocks.shape # other has n2 rows, p cols of blocks
176
177 # Create result matrix
178 result_blocks = []
179 for i in range(m):
180 row = []
181 for j in range(p):
182 # Compute block (i,j) as sum of products
183 block_sum = None
184 for k in range(n):
185 block_a = self_blocks[i, k]
186 block_b = other_blocks[k, j]
187
188 # Multiply the blocks
189 product = block_a * block_b
190
191 # If the result is a scalar Zero, convert it back to ZeroMatrix
192 if product == 0 and not hasattr(product, 'rows'):
193 # Determine the correct dimensions for the ZeroMatrix
194 rows = block_a.rows
195 cols = block_b.cols
196 product = ZeroMatrix(rows, cols)
197
198 if block_sum is None:
199 block_sum = product
200 else:
201 block_sum = block_sum + product
202 row.append(block_sum)
203 result_blocks.append(row)
204
205 return BlockMatrix(result_blocks)
168206
169207 return self * other
170208
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.