Cycles

Struct Cycles 

Source
pub struct Cycles<V> { /* private fields */ }

Implementations§

Source§

impl<V> Cycles<V>

Source

pub fn iter(&self) -> impl Iterator<Item = (usize, &V)>

Examples found in repository?
examples/z2reduce.rs (line 122)
10fn main() {
11    println!("# All-in-one complex example");
12    let mut comp: Complex<IndexedVec<_>, _> = Complex::new();
13
14    comp.push(simplex![0]).unwrap();
15    comp.push(simplex![1]).unwrap();
16    comp.push(simplex![2]).unwrap();
17    comp.push(simplex![0, 1]).unwrap();
18    comp.push(simplex![0, 2]).unwrap();
19    comp.push(simplex![1, 2]).unwrap();
20    comp.push(simplex![0, 1, 2]).unwrap();
21
22    println!("");
23    println!("## Complex::boundaries()");
24    for chain in comp.boundaries::<Z2VectorVec>() {
25        println!("{:?}", chain);
26    }
27
28    println!("");
29
30    //let reduce = Z2ColumnReduce::<Z2VectorVec>::from_complex(&comp).unwrap();
31    let reduce =
32        Z2ColumnReduce::<Z2Chain<Z2VectorVec>>::from_complex_with(&comp, |index, image| {
33            Z2Chain::new(index, image)
34        })
35        .unwrap();
36
37    println!("{:?}", reduce);
38    println!("");
39
40    println!("## cycles");
41    for c in reduce.cycles() {
42        println!("{:?}", c);
43    }
44    println!("");
45
46    println!("## Z2Pair");
47    for pers in Pair::new(&reduce, reduce.cycles()) {
48        println!("{:?}", pers);
49    }
50
51    println!("");
52
53    println!("# Separated complex example");
54
55    let mut comp0 = Complex::<IndexedVec<_>, Simplex>::new();
56    comp0.push(simplex![0]).unwrap();
57    comp0.push(simplex![1]).unwrap();
58    comp0.push(simplex![2]).unwrap();
59    comp0.push(simplex![3]).unwrap();
60
61    let mut comp1 = Complex::<IndexedVec<_>, Simplex>::with_prev(&comp0);
62    comp1.push(simplex![0, 1]).unwrap();
63    comp1.push(simplex![0, 2]).unwrap();
64    comp1.push(simplex![0, 3]).unwrap();
65    comp1.push(simplex![1, 2]).unwrap();
66    comp1.push(simplex![1, 3]).unwrap();
67    comp1.push(simplex![2, 3]).unwrap();
68
69    let mut comp2 = Complex::<IndexedVec<_>, Simplex>::with_prev(&comp1);
70    comp2.push(simplex![0, 1, 2]).unwrap();
71    comp2.push(simplex![0, 1, 3]).unwrap();
72    comp2.push(simplex![0, 2, 3]).unwrap();
73    comp2.push(simplex![1, 2, 3]).unwrap();
74
75    println!("");
76    println!("## Complex 0");
77    for simp in comp0.basis.iter() {
78        println!("{:?}", simp);
79    }
80
81    println!("");
82    println!("## Complex 1");
83    for simp in comp1.basis.iter() {
84        println!("{:?}", simp);
85    }
86
87    println!("");
88    println!("## Complex 2");
89    for simp in comp2.basis.iter() {
90        println!("{:?}", simp);
91    }
92
93    println!("");
94    println!("## Complex 1's boundaries from complex 0");
95    for chain in comp1.boundaries_from::<Z2VectorVec, _>(&comp0) {
96        println!("{:?}", chain);
97    }
98
99    println!("");
100    println!("## Complex 2's boundaries from complex 1");
101    for chain in comp2.boundaries_from::<Z2VectorVec, _>(&comp1) {
102        println!("{:?}", chain);
103    }
104
105    println!("");
106
107    let reduce0 = Z2ColumnReduce::<Z2VectorVec>::from_complex(&comp0).unwrap();
108
109    println!("{:?}", reduce0);
110
111    let reduce1 = Z2ColumnReduce::<Z2VectorVec>::from_complexes(&comp1, &comp0).unwrap();
112
113    println!("{:?}", reduce1);
114
115    let reduce2 = Z2ColumnReduce::<Z2VectorVec>::from_complexes(&comp2, &comp1).unwrap();
116
117    println!("{:?}", reduce2);
118
119    println!("");
120    println!("## pairing of dim0 and dim1");
121    let cycles0 = reduce0.into_cycles();
122    for pers in Pair::new(&reduce1, cycles0.iter()) {
123        println!("    {:?}", pers);
124    }
125
126    println!("");
127    println!("## pairing of dim1 and dim2");
128    let cycles1 = reduce1.into_cycles();
129    for pers in Pair::new(&reduce2, cycles1.iter()) {
130        println!("    {:?}", pers);
131    }
132
133    println!("");
134    println!("## cycles of dim2");
135    for pers in Pair::new(&reduce2, reduce2.cycles()) {
136        println!("    {:?}", pers);
137    }
138}

Auto Trait Implementations§

§

impl<V> Freeze for Cycles<V>

§

impl<V> RefUnwindSafe for Cycles<V>
where V: RefUnwindSafe,

§

impl<V> Send for Cycles<V>
where V: Send,

§

impl<V> Sync for Cycles<V>
where V: Sync,

§

impl<V> Unpin for Cycles<V>
where V: Unpin,

§

impl<V> UnwindSafe for Cycles<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.