calculate_t#
- iqm.qaoa.tree_calculation.generate_basis.calculate_t(v1)#
Given a vector
v1, calculate its symmetry sector.For an input vector
v1of length \(2m\), the symmetry sector \(t\) is the smallest integer, such that removing \(t\) elements from the beginning and the end ofv1makes the array symmetric with respect to flip, i.e., a palindrome. In other words, it’s the smallest integer, such that starting from the middle ofv1, the first \(m-t\) elements to the left equal the first \(m-t\) elements to the right. By definition \(t\) lies between 0 and \(m\) (included). Some examples:Input array
Half of input length \(m\)
Output \(t\)
[-1, 1, 1, 1, 1, 1]
3
1
[-1, 1, -1, -1, -1, 1]
3
2
[-1, 1, -1, -1, 1, -1]
3
0
[-1, 1, -1, 1, 1, 1]
3
3
[-1, 1, 1, 1]
2
1
[-1, 1, 1, 1, 1, 1, 1, 1]
4
1
- Parameters:
v1 (ndarray) – The array whose symmetry sector we want to calculate.
- Returns:
The symmetry sector of the input array.
- Raises:
ValueError – If
v1does not have the proper shape (1D array of even length).ValueError – If
v1contains other entries than +1 and -1
- Return type:
int64