Skip to content

Commit

Permalink
Adjusting one int type to long int + corrected doc
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvandeth committed Aug 26, 2024
1 parent 290da62 commit 69fd412
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/qiskit_qec/analysis/combinations.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Combinations
public:
Combinations(int n_, int k_);
bool next_combination(std::vector<int> &state);
int size(void);
long int size(void);
};

#endif
9 changes: 4 additions & 5 deletions src/qiskit_qec/analysis/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ def minimum_distance(
Restrictions:
Partition: Current methods require n < 63 for python versions and
n < 64 for C versions.
Partition: Current methods require n-k < 63
Enumerate: None, although very slow for larger n
Expand All @@ -269,15 +268,15 @@ def minimum_distance(
if method == method_enumerate:
distance = _c_minimum_distance(inputform1, inputform2, max_weight)
elif method == method_partition:
if method == method_partition and not stabilizer.shape[0] < 64:
raise QiskitQECError(f"Compiled method {method} does not support n > 63.")
if method == method_partition and not stabilizer.shape[0] < 63:
raise QiskitQECError(f"Compiled method {method} only supports n-k < 63.")
distance = _minimum_distance_2_compiled(stabilizer, gauge, max_weight)
else:
logger.exception("from compiled extension was not loaded: switching to no compiled")
if method == method_enumerate:
distance = _minimum_distance_1_python(stabilizer, gauge, max_weight)
elif method == method_partition:
if method == method_partition and not stabilizer.shape[0] < 63:
raise QiskitQECError(f"Python method {method} does not support n > 62.")
raise QiskitQECError(f"Python method {method} only supports n-k < 63.")
distance = _minimum_distance_2_python(stabilizer, gauge, max_weight)
return distance
4 changes: 2 additions & 2 deletions src/qiskit_qec/analysis/intern/combinations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ bool Combinations::next_combination(std::vector<int> &state)
return true;
}

int Combinations::size(void)
long int Combinations::size(void)
{
int k0 = k;
if(2*k > n) k0 = n - k;
int result = n;
long int result = n;
for(int i=2; i<=k0; i++)
{
result *= (n-i+1);
Expand Down
2 changes: 1 addition & 1 deletion src/qiskit_qec/analysis/intern/distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool distance_test(std::vector<std::vector<int> > &symplectic_vectors,
{
int n = symplectic_vectors[0].size() / 2; // num. qubits
int m = symplectic_vectors.size();
assert(m<64 && "n-k must be < 64 for this version not to overflow.");
assert(m<63 && "n-k must be < 63 for this version not to overflow.");
std::vector<uint64_t> pow2;
for (int i = 0; i < m+1; i++)
pow2.push_back(static_cast<uint64_t>(1) << i);
Expand Down
2 changes: 1 addition & 1 deletion src/qiskit_qec/analysis/intern/faultenumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::vector<FaultPath> FaultEnumerator::enumerate(int blocksize)
// Reset if the state is empty
if(_state.size() == 0) { _index = 0; _done = false; }
Combinations c(_faulty_ops_indices.size(), _order);
int initial_index = _index;
long int initial_index = _index;
while(c.next_combination(_state))
{
std::vector<int> indices;
Expand Down

0 comments on commit 69fd412

Please sign in to comment.