Conversation
|
can you explain why these modifications are needed ? is it to save on memory ? as mentioned before, since some functions need to be instantiated in order to initialize the matrix, so the modification you propose cannot be done for all native gates, and I'm not super convinced regarding doing the change only in the cases it doesn't pose problem. (and the memory savings are likely negligeable?) I'm open to be convinced otherwise :) |
|
@Henri-ColibrITD The motivation isn't memory, it's semantic alignment and avoiding redundant work. Every other fixed property of these gates (qlm_aqasm_keyword, qiskit_string, braket_gate, qiskit_gate, cirq_gate) is already class-level. The matrix of X or H is just as intrinsic to the type as its qiskit_string. it felt inconsistent imo for matrix to be the odd one out rebuilt in every init call. Moreover, the parametrized gates (Rx, Ry, P, etc.) never use self.matrix at all; they override to_canonical_matrix() with parameter-dependent logic. Same for T, CNOT, CZ, TOF. The only gates that use the matrix attribute are these 8 constant-matrix ones (Id, X, Y, Z, H, S, S†, SWAP), so the split isn't ad-hoc, it follows the existing inheritance structure. That said, this is more of a "nice-to-have" cleanup than a critical fix. If the change seems unnecessary or less readable, I'm happy to roll it back! If I'm missing something in my logic please do tell me! I'm open to discuss :) |
No description provided.