Did I find the right examples for you? yes no

All Samples(217)  |  Call(209)  |  Derive(0)  |  Import(8)

src/q/i/qit-0.11.0/qit/state.py   qit(Download)
from .lmap import tensor as lmap_tensor
from .lmap import numstr_to_array, array_to_numstr, lmap
from .utils import (_warn, vec, inv_vec, qubits, expv, rand_U, rand_SU, rand_positive, mkron,
    eighsort, spectral_decomposition, majorize, tensorbasis, assert_o)
 
                if y.ndim == 1:
                    rho = inv_vec(y, dim)  # into a matrix
                    return vec(dot(H, rho) - dot(rho, H)) # back into a vector
                else:
                    # vectorization, rows of y 
                    d = empty(y.shape, complex)
                    for k in range(len(y)):
                        rho = inv_vec(y[k], dim) # into a matrix
                        d[k] = vec(dot(H, rho) - dot(rho, H)) # back into a vector
                        ac = 0.5 * dot(A.conj().transpose(), A)
                        temp += dot(dot(A, rho), A.conj().transpose()) -dot(ac, rho) -dot(rho, ac)
                    return vec(temp) # back into a vector
                else:
                    # vectorization, rows of y
                            ac = 0.5 * dot(A.conj().transpose(), A)
                            temp += dot(dot(A, rho), A.conj().transpose()) -dot(ac, rho) -dot(rho, ac)
                        d[k] = vec(temp)  # back into a vector
                    return d