Skip to content

Commit

Permalink
Ok this one compiles
Browse files Browse the repository at this point in the history
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
jlapeyre committed Sep 17, 2024
1 parent 2846750 commit e7a401a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/accelerate/src/xx_decompose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pub mod utilities;
mod types;
mod weyl;
mod polytopes;
mod paths;
43 changes: 43 additions & 0 deletions crates/accelerate/src/xx_decompose/paths.rs
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
// from paths.py

use crate::xx_decompose::polytopes::{ConvexPolytopeData, PolytopeData};

static MYDATA : PolytopeData<11, 29, 11, 1, 1>
= PolytopeData
{
convex_subpolytopes: [
ConvexPolytopeData {
inequalities : [
[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.],
],
equalities : [[0., 0., 0., 1., 0., 0., -1., 0., 0., 0., 0.]],
name : "I ∩ A alcove ∩ A unreflected ∩ ah slant ∩ al frustrum ∩ B alcove ∩ B unreflected ∩ AF=B3",
},
]};
14 changes: 7 additions & 7 deletions crates/accelerate/src/xx_decompose/polytopes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ use crate::xx_decompose::utilities::EPSILON;
/// and
///
/// equalities[j][0] + sum_i equalities[j][i] * xi == 0.
struct ConvexPolytopeData<const MI:usize, const NI: usize, const ME:usize, const NE: usize> {
inequalities: [[f64; MI]; NI],
equalities: [[f64; ME]; NE],
name: String,
pub(crate) struct ConvexPolytopeData<'a, const MI:usize, const NI: usize, const ME:usize, const NE: usize> {
pub(crate) inequalities: [[f64; MI]; NI],
pub(crate) equalities: [[f64; ME]; NE],
pub(crate) name: &'a str,
}

/// The raw data of a union of convex polytopes.
struct PolytopeData<const MI:usize, const NI: usize, const ME:usize, const NE: usize> {
convex_subpolytopes: Vec<ConvexPolytopeData<MI, NI, ME, NE>>,
pub(crate) struct PolytopeData<'a, const MI:usize, const NI: usize, const ME:usize, const NE: usize, const NC: usize> {
pub(crate) convex_subpolytopes: [ConvexPolytopeData<'a, MI, NI, ME, NE>; NC],
}

// TODO: In the original, this is not a class-instance method. Could be I think.
/// Tests whether `polytope` contains `point.
fn polytope_has_element<const MI:usize, const NI: usize, const ME:usize, const NE: usize>
(polytope: ConvexPolytopeData<MI, NI, ME, NE>, point: &[f64; MI - 1]) -> bool {
(polytope: ConvexPolytopeData<MI, NI, ME, NE>, point: &Vec<f64>) -> bool {
polytope.inequalities
.iter()
.all(|ie| (-EPSILON <= ie[0] + point.iter().zip(&ie[1..]).map(|(p, i)| p * i).sum::<f64>()))
Expand Down

0 comments on commit e7a401a

Please sign in to comment.