quara.objects.effective_lindbladian module
- class EffectiveLindbladian(c_sys, hs, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
Bases:
quara.objects.gate.GateConstructor
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
hs (np.ndarray) – HS representation of this EffectiveLindbladian.
is_physicality_required (bool, optional) –
checks whether the EffectiveLindbladian is physically wrong, by default True. if at least one of the following conditions is
False, the EffectiveLindbladian is physically wrong:EffectiveLindbladian is TP(trace-preserving map).
EffectiveLindbladian is CP(Complete-Positivity-Preserving).
If you want to ignore the above requirements and create a EffectiveLindbladian object, set
is_physicality_requiredtoFalse.is_estimation_object (bool) –
on_para_eq_constraint (bool) –
on_algo_eq_constraint (bool) –
on_algo_ineq_constraint (bool) –
mode_proj_order (str) –
eps_proj_physical (float) –
eps_truncate_imaginary_part (float) –
- Raises
ValueError – HS representation is not square matrix.
ValueError – dim of HS representation is not square number.
ValueError – HS representation is not real matrix.
ValueError – dim of HS representation does not equal dim of CompositeSystem.
ValueError –
is_physicality_requiredisTrueand the gate is not physically correct.
- calc_d_part(mode_basis='hermitian_basis')[source]
calculates d part of this EffectiveLindbladian.
mode_basis allows the following values: - hermitian_basis - comp_basis
- Parameters
mode_basis (str, optional) – basis for calculating d part, by default “hermitian_basis”
- Returns
d part of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_gradient(var_index)[source]
calculates gradient of QOperation.
this function must be implemented in the subclass.
- Parameters
var_index (int) – index of variables to calculate gradient.
- Returns
gradient of QOperation.
- Return type
- Raises
NotImplementedError – this function does not be implemented in the subclass.
- calc_h_mat()[source]
calculates h matrix of this EffectiveLindbladian.
- Returns
h matrix of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_h_part(mode_basis='hermitian_basis')[source]
calculates h part of this EffectiveLindbladian.
mode_basis allows the following values: - hermitian_basis - comp_basis
- Parameters
mode_basis (str, optional) – basis for calculating h part, by default “hermitian_basis”
- Returns
h part of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_j_mat()[source]
calculates j matrix of this EffectiveLindbladian.
- Returns
j matrix of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_j_part(mode_basis='hermitian_basis')[source]
calculates j part of this EffectiveLindbladian.
mode_basis allows the following values: - hermitian_basis - comp_basis
- Parameters
mode_basis (str, optional) – basis for calculating j part, by default “hermitian_basis”
- Returns
j part of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_k_mat()[source]
calculates k matrix of this EffectiveLindbladian.
- Returns
k matrix of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_k_part(mode_basis='hermitian_basis')[source]
calculates k part of this EffectiveLindbladian.
mode_basis allows the following values: - hermitian_basis - comp_basis
- Parameters
mode_basis (str, optional) – basis for calculating k part, by default “hermitian_basis”
- Returns
k part of this EffectiveLindbladian.
- Return type
np.ndarray
- calc_proj_eq_constraint()[source]
calculates the projection of QOperation on equal constraint.
- Returns
the projection of QOperation on equal constraint.
- Return type
- calc_proj_ineq_constraint()[source]
calculates the projection of QOperation on inequal constraint.
- Returns
the projection of QOperation on inequal constraint.
- Return type
- is_cp(atol=None)[source]
returns whether effective Lindbladian is CP(Complete-Positivity-Preserving).
- Parameters
atol (float, optional) – the absolute tolerance parameter, uses
get_atol()by default. this function ignores eigenvalues close zero.- Returns
True where the effective Lindbladian is CP, False otherwise.
- Return type
bool
- is_tp(atol=None)[source]
returns whether the effective Lindbladian is TP(trace-preserving map).
- Parameters
atol (float, optional) – the absolute tolerance parameter, uses
get_atol()by default. this function checksabsolute(trace after mapped - trace before mapped) <= atol.- Returns
True where the effective Lindbladian is TP, False otherwise.
- Return type
bool
- to_gate()[source]
returns the Gate corresponding to this EffectiveLindbladian.
- Returns
the Gate corresponding to this EffectiveLindbladian.
- Return type
- to_kraus_matrices()[source]
returns Kraus matrices of EffectiveLindbladian.
if \(A\) is Hermitian preserve matrix, then \(A(X) = \sum_i a_i A_i X A_i^{\dagger}\), where \(a_i\) are real numbers and \(A_i\) are complex square matrices. this function returns the list of \((a_i, A_i)\) sorted in descending order by \(a_i\).
- Returns
Kraus matrices of EffectiveLindbladian.
- Return type
List[Tuple[np.float64, np.ndarray]]
- calc_gradient_from_effective_lindbladian(c_sys, hs, var_index, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
calculates gradient from EffectiveLindbladian.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this gate.
hs (np.ndarray) – HS representation of this gate.
var_index (int) – variable index.
on_para_eq_constraint (bool, optional) – uses equal constraints, by default True.
eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()is_estimation_object (bool) –
on_algo_eq_constraint (bool) –
on_algo_ineq_constraint (bool) –
eps_proj_physical (Optional[float]) –
- Returns
EffectiveLindbladian with gradient as hs.
- Return type
- convert_effective_lindbladian_index_to_var_index(c_sys, effective_lindbladian_index, on_para_eq_constraint=True)[source]
converts effective_lindbladian_index index to variable index.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
effective_lindbladian_index (Tuple[int, int]) – index of EffectiveLindbladian. first value of tuple is row number of HS representation of this EffectiveLindbladian. second value of tuple is column number of HS representation of this EffectiveLindbladian.
on_para_eq_constraint (bool, optional) – uses equal constraints, by default True.
- Returns
variable index.
- Return type
int
- convert_effective_lindbladian_to_var(c_sys, hs, on_para_eq_constraint=True)[source]
converts hs of EffectiveLindbladian to vec of variables.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
hs (np.ndarray) – HS representation of this EffectiveLindbladian.
on_para_eq_constraint (bool, optional) – uses equal constraints, by default True.
- Returns
vec of variables.
- Return type
np.ndarray
- convert_var_index_to_effective_lindbladian_index(c_sys, var_index, on_para_eq_constraint=True)[source]
converts variable index to EffectiveLindbladian index.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
var_index (int) – variable index.
on_para_eq_constraint (bool, optional) – uses equal constraints, by default True.
- Returns
index of EffectiveLindbladian. first value of tuple is row number of HS representation of this EffectiveLindbladian. second value of tuple is column number of HS representation of this EffectiveLindbladian.
- Return type
Tuple[int, int]
- convert_var_to_effective_lindbladian(c_sys, var, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
converts vec of variables to EffectiveLindbladian.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
var (np.ndarray) – vec of variables.
on_para_eq_constraint (bool, optional) – uses equal constraints, by default True.
eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()is_physicality_required (bool) –
is_estimation_object (bool) –
on_algo_eq_constraint (bool) –
on_algo_ineq_constraint (bool) –
eps_proj_physical (Optional[float]) –
- Returns
converted EffectiveLindbladian.
- Return type
- generate_d_part_cb_from_jump_operators(jump_operators)[source]
generates d part of EffectiveLindbladian from jump operators.
this d part is represented by computational basis.
- Parameters
jump_operators (List[np.ndarray]) – jump_operators to generate d part.
- Returns
d part of EffectiveLindbladian.
- Return type
np.ndarray
- generate_d_part_gb_from_jump_operators(jump_operators, basis, eps_truncate_imaginary_part=None)[source]
generates d part of EffectiveLindbladian from jump operators.
this d part is represented by general basis.
- Parameters
jump_operators (List[np.ndarray]) – jump operators to generate d part.
basis (MatrixBasis) – MatrixBasis to present d part.
eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
d part of EffectiveLindbladian.
- Return type
np.ndarray
- generate_effective_lindbladian_from_h(c_sys, h_mat, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
generates EffectiveLindbladian from h matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
is_physicality_required (bool, optional) – whether this QOperation is physicality required, by default True
is_estimation_object (bool, optional) – whether this QOperation is estimation object, by default True
on_para_eq_constraint (bool, optional) – whether this QOperation is on parameter equality constraint, by default True
on_algo_eq_constraint (bool, optional) – whether this QOperation is on algorithm equality constraint, by default True
on_algo_ineq_constraint (bool, optional) – whether this QOperation is on algorithm inequality constraint, by default True
mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”
eps_proj_physical (float, optional) – epsilon that is projection algorithm error threshold for being physical, by default
get_atol()/ 10.0eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
EffectiveLindbladian.
- Return type
np.ndarray
- generate_effective_lindbladian_from_hjk(c_sys, h_mat, j_mat, k_mat, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
generates EffectiveLindbladian from h matrix, j matrix and k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
j_mat (np.ndarray) – j matrix.
k_mat (np.ndarray) – k matrix.
is_physicality_required (bool, optional) – whether this QOperation is physicality required, by default True
is_estimation_object (bool, optional) – whether this QOperation is estimation object, by default True
on_para_eq_constraint (bool, optional) – whether this QOperation is on parameter equality constraint, by default True
on_algo_eq_constraint (bool, optional) – whether this QOperation is on algorithm equality constraint, by default True
on_algo_ineq_constraint (bool, optional) – whether this QOperation is on algorithm inequality constraint, by default True
mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”
eps_proj_physical (float, optional) – epsilon that is projection algorithm error threshold for being physical, by default
get_atol()/ 10.0eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
EffectiveLindbladian.
- Return type
np.ndarray
- generate_effective_lindbladian_from_hk(c_sys, h_mat, k_mat, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
generates EffectiveLindbladian from h matrix and k matrix.
j matrix is calculated from k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
k_mat (np.ndarray) – k matrix.
is_physicality_required (bool, optional) – whether this QOperation is physicality required, by default True
is_estimation_object (bool, optional) – whether this QOperation is estimation object, by default True
on_para_eq_constraint (bool, optional) – whether this QOperation is on parameter equality constraint, by default True
on_algo_eq_constraint (bool, optional) – whether this QOperation is on algorithm equality constraint, by default True
on_algo_ineq_constraint (bool, optional) – whether this QOperation is on algorithm inequality constraint, by default True
mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”
eps_proj_physical (float, optional) – epsilon that is projection algorithm error threshold for being physical, by default
get_atol()/ 10.0eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
EffectiveLindbladian.
- Return type
np.ndarray
- generate_effective_lindbladian_from_jump_operators(c_sys, jump_operators, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
generates EffectiveLindbladian from jump operators.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
jump_operators (List[np.ndarray]) – jump operators to generate EffectiveLindbladian.
is_physicality_required (bool, optional) – whether this QOperation is physicality required, by default True
is_estimation_object (bool, optional) – whether this QOperation is estimation object, by default True
on_para_eq_constraint (bool, optional) – whether this QOperation is on parameter equality constraint, by default True
on_algo_eq_constraint (bool, optional) – whether this QOperation is on algorithm equality constraint, by default True
on_algo_ineq_constraint (bool, optional) – whether this QOperation is on algorithm inequality constraint, by default True
mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”
eps_proj_physical (float, optional) – epsilon that is projection algorithm error threshold for being physical, by default
get_atol()/ 10.0eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
EffectiveLindbladian.
- Return type
np.ndarray
- generate_effective_lindbladian_from_k(c_sys, k_mat, is_physicality_required=True, is_estimation_object=True, on_para_eq_constraint=True, on_algo_eq_constraint=True, on_algo_ineq_constraint=True, mode_proj_order='eq_ineq', eps_proj_physical=None, eps_truncate_imaginary_part=None)[source]
generates EffectiveLindbladian from k matrix.
j matrix is calculated from k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
k_mat (np.ndarray) – k matrix.
is_physicality_required (bool, optional) – whether this QOperation is physicality required, by default True
is_estimation_object (bool, optional) – whether this QOperation is estimation object, by default True
on_para_eq_constraint (bool, optional) – whether this QOperation is on parameter equality constraint, by default True
on_algo_eq_constraint (bool, optional) – whether this QOperation is on algorithm equality constraint, by default True
on_algo_ineq_constraint (bool, optional) – whether this QOperation is on algorithm inequality constraint, by default True
mode_proj_order (str, optional) – the order in which the projections are performed, by default “eq_ineq”
eps_proj_physical (float, optional) – epsilon that is projection algorithm error threshold for being physical, by default
get_atol()/ 10.0eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
EffectiveLindbladian.
- Return type
np.ndarray
- generate_hs_from_h(c_sys, h_mat, eps_truncate_imaginary_part=None)[source]
generates HS matrix of EffectiveLindbladian from h matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
eps_truncate_imaginary_part (Optional[float]) –
- Returns
HS matrix of EffectiveLindbladian.
- Return type
np.ndarray
- generate_hs_from_hjk(c_sys, h_mat, j_mat, k_mat, eps_truncate_imaginary_part=None)[source]
generates HS matrix of EffectiveLindbladian from h matrix, j matrix and k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
j_mat (np.ndarray) – j matrix.
k_mat (np.ndarray) – k matrix.
eps_truncate_imaginary_part (Optional[float]) –
- Returns
HS matrix of EffectiveLindbladian.
- Return type
np.ndarray
- generate_hs_from_hk(c_sys, h_mat, k_mat, eps_truncate_imaginary_part=None)[source]
generates HS matrix of EffectiveLindbladian from h matrix and k matrix.
j matrix is calculated from k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
h_mat (np.ndarray) – h matrix.
k_mat (np.ndarray) – k matrix.
eps_truncate_imaginary_part (Optional[float]) –
- Returns
HS matrix of EffectiveLindbladian.
- Return type
np.ndarray
- generate_hs_from_k(c_sys, k_mat, eps_truncate_imaginary_part=None)[source]
generates HS matrix of EffectiveLindbladian from k matrix.
j matrix is calculated from k matrix.
- Parameters
c_sys (CompositeSystem) – CompositeSystem of this EffectiveLindbladian.
k_mat (np.ndarray) – k matrix.
eps_truncate_imaginary_part (Optional[float]) –
- Returns
HS matrix of EffectiveLindbladian.
- Return type
np.ndarray
- generate_j_part_cb_from_jump_operators(jump_operators)[source]
generates j part of EffectiveLindbladian from jump operators.
this j part is represented by computational basis.
- Parameters
jump_operators (List[np.ndarray]) – jump operators to generate j part.
- Returns
j part of EffectiveLindbladian.
- Return type
np.ndarray
- generate_j_part_gb_from_jump_operators(jump_operators, basis, eps_truncate_imaginary_part=None)[source]
generates j part of EffectiveLindbladian from jump operators.
this j part is represented by general basis.
- Parameters
jump_operators (List[np.ndarray]) – jump operators to generate j part.
basis (MatrixBasis) – MatrixBasis to present j part.
eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
j part of EffectiveLindbladian.
- Return type
np.ndarray
- generate_k_part_cb_from_jump_operators(jump_operators)[source]
generates k part of EffectiveLindbladian from jump operators.
this k part is represented by computational basis.
- Parameters
jump_operators (List[np.ndarray]) – jump operators to generate k part.
- Returns
k part of EffectiveLindbladian.
- Return type
np.ndarray
- generate_k_part_gb_from_jump_operators(jump_operators, basis, eps_truncate_imaginary_part=None)[source]
generates k part of EffectiveLindbladian from jump operators.
this k part is represented by general basis.
- Parameters
jump_operators (List[np.ndarray]) – jump operators to generate k part.
basis (MatrixBasis) – MatrixBasis to present k part.
eps_truncate_imaginary_part (float, optional) – threshold to truncate imaginary part, by default
get_atol()
- Returns
k part of EffectiveLindbladian.
- Return type
np.ndarray