forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have been observing a small number of sizes of array-like data. So I am trying to make these Array s i.e. with static size. But this is difficult. I plan to replace these with Vec. This commit starts this.
- Loading branch information
Showing
4 changed files
with
345 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,286 @@ | ||
// from paths.py | ||
|
||
use crate::xx_decompose::polytopes::{ Polytope, AlcoveDetails, AF}; | ||
|
||
/// Assembles a coordinate in the system used by `xx_region_polytope`. | ||
fn get_augmented_coordinate(target_coordinate: &[f64; 3], strengths: &[f64]) -> Vec<f64> { | ||
let (beta, strengths) = strengths.split_last().unwrap(); | ||
let mut strengths = Vec::from(strengths); | ||
strengths.extend([0., 0.]); | ||
strengths.sort_by(|a, b| a.partial_cmp(b).unwrap()); | ||
let ssum: f64 = strengths.iter().sum(); | ||
let n = strengths.len(); | ||
let interaction_coordinate = [ssum, strengths[n-1], strengths[n-2], *beta]; | ||
let mut target_coordinate = Vec::from(target_coordinate); | ||
target_coordinate.extend(interaction_coordinate); | ||
target_coordinate | ||
} | ||
|
||
fn make_polys1() { | ||
let xx_lift_polytope: Vec<Polytope<'static, MLIFT>> = | ||
vec! [ | ||
Polytope { | ||
ineqs: &LIFT_INEQ1, | ||
eqs: Some(&LIFT_EQ1), | ||
alcove_details: Some((AlcoveDetails::Unreflected, AF::B3)) | ||
}, | ||
Polytope { | ||
ineqs: &LIFT_INEQ2, | ||
eqs: Some(&LIFT_EQ2), | ||
alcove_details: Some((AlcoveDetails::Unreflected, AF::B1)) | ||
}, | ||
Polytope { | ||
ineqs: &LIFT_INEQ3, | ||
eqs: Some(&LIFT_EQ3), | ||
alcove_details: Some((AlcoveDetails::Reflected, AF::B1)) | ||
}, | ||
Polytope { | ||
ineqs: &LIFT_INEQ4, | ||
eqs: Some(&LIFT_EQ4), | ||
alcove_details: Some((AlcoveDetails::Reflected, AF::B3)) | ||
}, | ||
]; | ||
|
||
let xx_region_polytope: Vec<Polytope<'static, MREGION>> = | ||
vec! [ | ||
Polytope { | ||
ineqs: ®ION_INEQ1, | ||
eqs: None, | ||
alcove_details: Some((AlcoveDetails::Unreflected, AF::B3)) | ||
}, | ||
Polytope { | ||
ineqs: ®ION_INEQ2, | ||
eqs: None, | ||
alcove_details: Some((AlcoveDetails::Reflected, AF::B3)) | ||
}, | ||
Polytope { | ||
ineqs: ®ION_INEQ3, | ||
eqs: None, | ||
alcove_details: Some((AlcoveDetails::Unreflected, AF::B1)) | ||
}, | ||
Polytope { | ||
ineqs: ®ION_INEQ4, | ||
eqs: None, | ||
alcove_details: Some((AlcoveDetails::Reflected, AF::B1)) | ||
}, | ||
]; | ||
} | ||
|
||
const MLIFT: usize = 11; | ||
|
||
static LIFT_INEQ1: [[i32; MLIFT]; 29] = [ | ||
[0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0], | ||
[0, -1, -1, -1, 0, 0, 0, 1, 0, 0, 0], | ||
[0, 1, -1, -1, 0, 0, 0, 1, -2, 0, 0], | ||
[0, 0, -1, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, -1, -1, -1, 1, 0, 0, 1], | ||
[0, 0, 0, 0, 1, -1, -1, 1, -2, 0, 1], | ||
[0, 0, 0, 0, 1, -1, -1, 1, 0, 0, -1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, -1, -1, 0, 1, 1, 0, 0, 0, 0, 1], | ||
[2, -1, -1, 0, -1, -1, 0, 0, 0, 0, -1], | ||
[0, 1, 1, 0, -1, -1, 0, 0, 0, 0, 1], | ||
[0, -1, 1, 0, 1, -1, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, -1, 1, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 1, -1, 0, 0, 0, 0, -1], | ||
]; | ||
|
||
static LIFT_EQ1: [[i32; MLIFT]; 1] = [[0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0]]; | ||
// equalities=[[0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0]], | ||
|
||
|
||
static LIFT_INEQ2: [[i32; MLIFT]; 29] = [ | ||
[0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0], | ||
[0, -1, -1, -1, 0, 0, 0, 1, 0, 0, 0], | ||
[0, -1, -1, 1, 0, 0, 0, 1, -2, 0, 0], | ||
[0, 0, -1, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, -1, -1, -1, 1, 0, 0, 1], | ||
[0, 0, 0, 0, 1, -1, -1, 1, -2, 0, 1], | ||
[0, 0, 0, 0, 1, -1, -1, 1, 0, 0, -1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, -1, -1, 0, 0, 1, 1, 0, 0, 0, 1], | ||
[2, -1, -1, 0, 0, -1, -1, 0, 0, 0, -1], | ||
[0, 1, 1, 0, 0, -1, -1, 0, 0, 0, 1], | ||
[0, -1, 1, 0, 0, 1, -1, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, -1, 1, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 1, -1, 0, 0, 0, -1], | ||
]; | ||
|
||
static LIFT_EQ2: [[i32; MLIFT]; 1] = [[0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0]]; | ||
|
||
|
||
static LIFT_INEQ3: [[i32; MLIFT]; 29] = [ | ||
[0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, -1, 0, 0, 0, 1, -2, 0, 0], | ||
[-1, -1, -1, 1, 0, 0, 0, 1, 0, 0, 0], | ||
[0, 0, -1, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0], | ||
[-1, 0, 0, 0, 1, -1, -1, 1, 0, 0, 1], | ||
[1, 0, 0, 0, -1, -1, -1, 1, 0, 0, -1], | ||
[1, 0, 0, 0, -1, -1, -1, 1, -2, 0, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, -1, -1, 0, 0, 1, 1, 0, 0, 0, 1], | ||
[2, -1, -1, 0, 0, -1, -1, 0, 0, 0, -1], | ||
[0, 1, 1, 0, 0, -1, -1, 0, 0, 0, 1], | ||
[0, -1, 1, 0, 0, 1, -1, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, -1, 1, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 1, -1, 0, 0, 0, -1], | ||
]; | ||
|
||
static LIFT_EQ3: [[i32; MLIFT]; 1] = [[0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0]]; | ||
|
||
static LIFT_INEQ4: [[i32; MLIFT]; 29] = [ | ||
[0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, 0, -1, 0, 0, 0, 0, 0, 0, 0], | ||
[1, -1, -1, -1, 0, 0, 0, 1, -2, 0, 0], | ||
[-1, 1, -1, -1, 0, 0, 0, 1, 0, 0, 0], | ||
[0, 0, -1, 0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0], | ||
[-1, 0, 0, 0, 1, -1, -1, 1, 0, 0, 1], | ||
[1, 0, 0, 0, -1, -1, -1, 1, 0, 0, -1], | ||
[1, 0, 0, 0, -1, -1, -1, 1, -2, 0, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, -1, -1, 0, 1, 1, 0, 0, 0, 0, 1], | ||
[2, -1, -1, 0, -1, -1, 0, 0, 0, 0, -1], | ||
[0, 1, 1, 0, -1, -1, 0, 0, 0, 0, 1], | ||
[0, -1, 1, 0, 1, -1, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, -1, 1, 0, 0, 0, 0, 1], | ||
[0, 1, -1, 0, 1, -1, 0, 0, 0, 0, -1], | ||
]; | ||
|
||
static LIFT_EQ4: [[i32; MLIFT]; 1] = [[0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0]]; | ||
|
||
const MREGION: usize = 8; | ||
|
||
static REGION_INEQ1: [[i32; MREGION]; 15] = [ | ||
[0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, -1, -1, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0], | ||
[0, -1, -1, -1, 1, 0, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 1, -1, -1, 1, -2, 0, 1], | ||
[0, 1, -1, -1, 1, 0, 0, -1], | ||
[0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, 0, -1, 0, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, 0, 1], | ||
]; | ||
|
||
static REGION_INEQ2: [[i32; MREGION]; 15] = [ | ||
[0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 0, 1, -1, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, -1, -1, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0], | ||
[1, -1, -1, -1, 1, -2, 0, 1], | ||
[0, 1, -1, 0, 0, 0, 0, 0], | ||
[-1, 1, -1, -1, 1, 0, 0, 1], | ||
[1, -1, -1, -1, 1, 0, 0, -1], | ||
[0, 0, 0, -1, 1, -1, 0, 0], | ||
[0, 0, -1, 0, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, 0, 1], | ||
]; | ||
|
||
static REGION_INEQ3: [[i32; MREGION]; 16] = [ | ||
[0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, -1, -1, 0], | ||
[0, 1, -1, -1, 1, -2, 0, 1], | ||
[0, -1, -1, -1, 1, 0, 0, 1], | ||
[0, 0, 1, -1, 0, 0, 0, 0], | ||
[1, -1, 1, -1, 0, 0, 0, -1], | ||
[0, 1, 1, -1, 1, -2, 0, -1], | ||
[0, -1, 1, -1, 1, 0, 0, -1], | ||
[0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, 0, 1], | ||
|
||
]; | ||
|
||
static REGION_INEQ4: [[i32; MREGION]; 16] = [ | ||
[0, 0, 0, 0, 0, 1, -1, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0], | ||
[1, 0, 0, 0, 0, -2, 0, 0], | ||
[1, 0, 0, 0, 0, 0, 0, -2], | ||
[0, 1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 1, 0, 0, 0, 0], | ||
[1, -1, -1, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, -1, -1, 0], | ||
[-1, 1, -1, -1, 1, 0, 0, 1], | ||
[1, -1, -1, -1, 1, -2, 0, 1], | ||
[0, 0, 1, -1, 0, 0, 0, 0], | ||
[1, -1, 1, -1, 0, 0, 0, -1], | ||
[-1, 1, 1, -1, 1, 0, 0, -1], | ||
[1, -1, 1, -1, 1, -2, 0, -1], | ||
[0, 0, 0, -1, 1, -1, -1, 1], | ||
[0, 0, 0, 0, 0, 0, 0, 1], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.