Search found 2 matches

by qazwsx
10 Oct 2024, 05:34
Forum: HowTos and FAQ for TeNPy
Topic: How to convert between npc.Array and one dimension np.array efficiently?
Replies: 3
Views: 46197

Re: How to convert between npc.Array and one dimension np.array efficiently?

Thank you for your advice. I am trying to optimize a translation invariant MPS with internal Zn symmetry using variational method. Since the MPS is translation invariant, it is constructed from some same tensors M. With the help of np_conserved, I have built the cost function and gradient function f...
by qazwsx
09 Oct 2024, 05:25
Forum: HowTos and FAQ for TeNPy
Topic: How to convert between npc.Array and one dimension np.array efficiently?
Replies: 3
Views: 46197

How to convert between npc.Array and one dimension np.array efficiently?

In my code, I need to convert between npc.Array and one dimension np.array frequently. This code is my implementation. How can this be made more efficient? def Array_to_nparray(M): Arrayshape=M.shape Mlegs=M.legs flat_array = [] block_shapes = [] slices_list = [] for block, blockslices, charges, qin...