feanor_math/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(rustdoc::private_intra_doc_links)]
#![warn(
// missing_debug_implementations,
unused_extern_crates,
unused_import_braces,
// unused_qualifications,
unused_results,
// missing_docs
)]
#![feature(associated_type_defaults)]
#![feature(btree_cursors)]
#![feature(test)]
#![feature(min_specialization)]
#![feature(maybe_uninit_slice)]
#![feature(allocator_api)]
#![feature(fn_traits)]
#![feature(iter_advance_by)]
#![feature(mapped_lock_guards)]
#![feature(unboxed_closures)]
#![feature(ptr_alignment_type)]
#![feature(never_type)]
#![feature(array_chunks)]
#![feature(doc_cfg)]
#![feature(int_roundings)]
#![doc = include_str!("../Readme.md")]
#[cfg(test)]
extern crate test;
const MAX_PROBABILISTIC_REPETITIONS: usize = 30;
const DEFAULT_PROBABILISTIC_REPETITIONS: usize = 30;
#[cfg(test)]
const RANDOM_TEST_INSTANCE_COUNT: usize = 10;
macro_rules! static_assert_impls {
($type:ty: $trait:tt) => {
{
fn assert_impls<T>() where T: ?Sized + $trait {}
assert_impls::<$type>();
}
};
}
///
/// Contains [`unstable_sealed::UnstableSealed`] to mark a trait "sealed" on stable.
///
#[stability::unstable(feature = "enable")]
pub mod unstable_sealed {
///
/// Marks a trait as "sealed" on stable. In other words, using this trait
/// as supertrait for another trait within `feanor-math` means that implementing
/// the subtrait for new types is unstable, and only available when `unstable-enable`
/// is active.
///
pub trait UnstableSealed {}
}
mod unsafe_any;
///
/// Contains [`computation::ComputationController`] to observe long-running computations.
///
#[macro_use]
pub mod computation;
///
/// Contains the core traits of the library - [`ring::RingBase`] and [`ring::RingStore`].
///
#[macro_use]
pub mod ring;
///
/// Contains the trait [`delegate::DelegateRing`] that simplifies implementing the
/// newtype-pattern for rings.
///
pub mod delegate;
///
/// Contains different traits for sequences of elements, namely [`seq::VectorView`] and [`seq::VectorFn`].
/// They all have some functional overlap with [`ExactSizeIterator`], but differ in how they allow
/// access to the elements of the sequence.
///
pub mod seq;
///
/// Contains the trait [`divisibility::DivisibilityRing`] for rings that provide information
/// about divisibility of their elements.
///
pub mod divisibility;
///
/// Contains the trait [`field::Field`] for rings that are fields.
///
pub mod field;
///
/// Contains the trait [`pid::PrincipalIdealRing`] for rings in whom every ideal is principal.
/// Also contains [`pid::EuclideanRing`], which is the simplest way how a ring can become a
/// principal idea ring.
///
pub mod pid;
///
/// Contains the core of `feanor-math`'s (currently) minimalistic approach to matrices. In particular,
/// we use [`matrix::Submatrix`] and [`matrix::SubmatrixMut`] for matrices that don't own their data.
///
pub mod matrix;
///
/// Contains the trait [`ordered::OrderedRing`] for rings with a total ordering that is compatible
/// with the ring operations.
///
pub mod ordered;
///
/// Provides the ring implementation [`primitive_int::StaticRing`] that represents the integer ring
/// with arithmetic given by the primitive integer types ``i8` to `i128`.
///
pub mod primitive_int;
///
/// Contains the trait [`integer::IntegerRing`] for rings that represent the ring of integers `Z`.
///
pub mod integer;
///
/// A collection of all number-theoretic algorithms that are currently implemented in
/// this crate.
///
pub mod algorithms;
///
/// A collection of various more complicated ring traits and implementations, in particular
/// arbitrary-precision integer rings, the integer quotients `Z/nZ` or polynomial rings.
///
pub mod rings;
///
/// Ccontains the struct [`wrapper::RingElementWrapper`] that contains an element together with its ring,
/// and thus can provide ring operations without explicit access to the ring.
///
/// Using this is for example necessary if you want to use elements of a [`crate::ring::HashableElRing`]-ring
/// as elements in a [`std::collections::HashSet`].
/// ```
/// # use feanor_math::ring::*;
/// # use feanor_math::homomorphism::*;
/// # use feanor_math::wrapper::*;
/// # use feanor_math::integer::*;
/// # use std::collections::HashSet;
///
/// let mut set = HashSet::new();
/// set.insert(RingElementWrapper::new(BigIntRing::RING, BigIntRing::RING.int_hom().map(3)));
/// assert!(set.contains(&RingElementWrapper::new(BigIntRing::RING, BigIntRing::RING.int_hom().map(3))));
/// ```
///
pub mod wrapper;
///
/// Contains the trait [`homomorphism::Homomorphism`], [`homomorphism::CanHomFrom`] and
/// others that are the foundation of the homomorphism framework, that enables mapping
/// elements between different rings.
///
pub mod homomorphism;
///
/// Contains implementations of various iterators and combinators, like [`iters::powerset()`]
/// or [`iters::multi_cartesian_product`].
///
pub mod iters;
///
/// Contains the trait [`local::PrincipalLocalRing`] for principal ideal rings that additionally are local,
/// i.e. they have a unique maximal ideal (which then is generated by a single element).
///
pub mod local;
///
/// Contains the trait [`serialization::SerializableElementRing`] for rings whose elements can be serialized
/// by using `serde`.
///
pub mod serialization;
///
/// Contains a workaround for specialization.
///
pub mod specialization;
///
/// Contains the trait [`compute_locally::EvaluatePolyLocallyRing`] and related traits for computing
/// the evaluation of a polynomial over a ring via its evaluations modulo different prime ideals.
///
/// Note that here (and in `feanor-math` generally), the term "local" is used to refer to algorithms
/// that work modulo prime ideals (or their powers), which is different from the mathematical concept
/// of localization.
///
pub mod compute_locally;