0

I'm using a function from scipy to construct block-diagonal matrices, which takes as an argument several matrices and returns the desired result, i.e.,

block_diag(A,B,C)

returns the associated block-diagonal form. My code naturally computes these matrices and returns them in a list in the following format and can be converted to a block diagonal matrix as follows:

ops = [A, B, C]
block_diag(ops[0],ops[1],ops[2])

Unfortunately the form

block_diag(ops)

throws an error. The problem is that I want this to work for an arbitrary number of operators, so I need a way to call the block diagonal function which doesn't require me to enumerate terms of the form op[j]. Is there a simple way to do this?

Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91
miggle
  • 101

0 Answers0