示例#1
0
 def d(x, rho_2):
     # x specifies rho = T T^
     rho_1 = np.matmul(np.array([[x[0], 0], [x[1] + 1j * x[2], x[3]]]),
                       np.array([[x[0], x[1] - 1j * x[2]], [0, x[3]]]))
     distance = sts.distance_trace(rho_1, rho_2)
     return distance
示例#2
0
        # Step 6: Estimate density matrix
        #
        # Compute linear estimator using
        # the M1, M2, M3 measurements
        #
        dens_est = estimation.linear_estimate_adapt(M1_data, M2_data, M3_data,
                                                    M1, M2, M3)

        # Step 4: Compute and the distances
        #
        # Compute distances between the estimated
        # and true density matrix using the
        # different distance fuctions.
        #
        dist_op[n] = stats.distance_op(dens, dens_est)
        dist_trace[n] = stats.distance_trace(dens, dens_est)
        dist_fid[n] = stats.distance_fid(dens, dens_est)

        # Count the number of non-physical matrices
        #
        eigenvalues = np.linalg.eigvals(dens_est)
        if eigenvalues[0] < 0 or eigenvalues[1] < 0:
            non_physical_count = non_physical_count + 1

    # Step 5: Average the distances
    #
    # Average the distances for each value of x
    #
    av_distances[k, :] = [
        np.mean(dist_op),
        np.mean(dist_trace),