diff --git a/src/lib.rs b/src/lib.rs index ca036ab..c13d168 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ pub mod display; pub mod domain; pub mod functions; pub mod mapping; +pub mod signature; pub mod tensor; pub use display::{BoxedTensor, format_boxed}; @@ -15,10 +16,11 @@ pub use functions::{ zeros, }; pub use mapping::{ - BoxedMapping, BoxedPowersetMapping, COO, Concat, Diagonal, EmptyMapping, HRectSignature, - IndexMapping, InvProjection, Permutation, Powerset, PowersetMapping, Projection, Signature, - Squeeze, Stride, Unsqueeze, Where, + BoxedMapping, BoxedPowersetMapping, COO, Concat, Diagonal, EmptyMapping, IndexMapping, + InvProjection, Permutation, Powerset, PowersetMapping, Projection, Squeeze, Stride, Unsqueeze, + Where, }; +pub use signature::{HRectSignature, Signature}; pub use tensor::{ Inf, InfReduction, JaggedTensor, LeftComposition, Physical, Product, ProductReduction, Reduction, ReductionTensor, RightComposition, Sum, SumReduction, Sup, SupReduction, Tensor, diff --git a/src/mapping.rs b/src/mapping.rs index 8619aaf..e05a246 100644 --- a/src/mapping.rs +++ b/src/mapping.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use crate::display::BoxedTensor; use crate::domain::{Domain, HRect, JaggedDomain}; +use crate::signature::{HRectSignature, Signature}; /// A set of indices, as returned by a `PowersetMapping`. pub type Powerset = HashSet>; @@ -39,29 +40,6 @@ pub trait BoxedPowersetMapping: PowersetMapping { fn hrect(&self) -> &HRect; } -/// The domain and codomain a mapping runs between. -pub struct Signature { - domain: D, - codomain: C, -} - -impl Signature { - pub fn new(domain: D, codomain: C) -> Self { - Self { domain, codomain } - } - - pub fn domain(&self) -> &D { - &self.domain - } - - pub fn codomain(&self) -> &C { - &self.codomain - } -} - -/// The signature of a mapping between two hyperrectangles. -pub type HRectSignature = Signature; - /// What a mapping from a hyperrectangle has to provide. Implementing this rather /// than `IndexMapping` gets the domain accessors and printability below for /// free, whatever the codomain; a mapping over a domain that is not a hrect @@ -557,7 +535,7 @@ impl HRectMapping for Projection { } /// The inverse of the projection dropping axis `dim`. -/// e.g. with dim=1, f(m, p) = {[m n p]^T | n in [N]} +/// e.g. with dim=1, f(m, p) = {[m n p]^T | n in \[N\]} pub struct InvProjection { signature: HRectSignature, dim: usize, diff --git a/src/signature.rs b/src/signature.rs new file mode 100644 index 0000000..ee653cd --- /dev/null +++ b/src/signature.rs @@ -0,0 +1,26 @@ +//! The domain and codomain a mapping runs between. + +use crate::domain::{Domain, HRect}; + +/// The domain and codomain a mapping runs between. +pub struct Signature { + domain: D, + codomain: C, +} + +impl Signature { + pub fn new(domain: D, codomain: C) -> Self { + Self { domain, codomain } + } + + pub fn domain(&self) -> &D { + &self.domain + } + + pub fn codomain(&self) -> &C { + &self.codomain + } +} + +/// The signature of a mapping between two hyperrectangles. +pub type HRectSignature = Signature;