one-indexed-vec 0.2.0

A one-based (1-indexed) wrapper around Vec<T>: element at position N is accessed via vec[N].
Documentation
//! # one-indexed-vec
//!
//! Scientific computing library with 1-based indexing.
//!
//! Built on the [`Vec1`] type — a `Vec`-like container whose first element
//! lives at index `1`, matching mathematical notation and the conventions
//! of Fortran, MATLAB, and Julia.
//!
//! ## Modules
//!
//! | Module | Feature | Description |
//! |--------|---------|-------------|
//! | [`vec1_core`] | always | The 1-based container and [`Index1`] |
//! | [`math`] | `math` | Sequences, series, Fourier analysis, orthogonal polynomials |
//! | [`numerical`] | `numerical` | Basic numeric ops, integration, ODEs, root finding |
//! | [`linear`] | `linear` | Matrices, decompositions, eigenvalues |
//! | [`signal`] | `signal` | Filters, window functions, correlation |
//! | [`stats`] | `stats` | Descriptive statistics, regression, distributions |
//! | [`physics`] | `physics` | Quantum mechanics, thermodynamics, optics |
//! | [`chemistry`] | `chemistry` | Atomic data, kinetics, thermodynamics |
//!
//! ## Quick start
//!
//! ```rust
//! use one_indexed_vec::{Vec1, vec1};
//!
//! let v = vec1![1.0, 2.0, 3.0, 4.0, 5.0];
//! assert_eq!(v[1], 1.0);
//! assert_eq!(v.sum(), 15.0);
//! assert_eq!(v.mean(), 3.0);
//! ```
//!
//! ## Migration from 0.1.x
//!
//! In `0.1.x` the container was called `VecIndexFromOne<T>`. As of `0.2.0`,
//! the canonical name is [`Vec1`]. The old name is retained as a deprecated
//! type alias for backward compatibility.
//!
//! ```rust
//! #![allow(deprecated)]
//! use one_indexed_vec::VecIndexFromOne;
//!
//! let v = VecIndexFromOne::from(vec![1, 2, 3]);
//! assert_eq!(v[1], 1);
//! ```
//!
//! Numeric algorithms that previously lived under `one_indexed_vec::ops`
//! are now available as methods on [`Vec1`], grouped under the disciplinary
//! modules. The [`ops`] module is kept as an empty deprecated placeholder.

#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]

/* #[cfg(feature = "std")]
extern crate std; */

#[cfg(not(feature = "std"))]
extern crate alloc;

// ============================================================================
// Modules
// ============================================================================

/// Core container: [`Vec1<T>`], the 1-based [`Index1`], and fundamental
/// numeric operations (`sum`, `mean`, `dot_product`, ...).
pub mod vec1_core;

/// Mathematical formulas and algorithms: sequences, series, Fourier
/// analysis, orthogonal polynomials, FFT, combinatorics.
#[cfg(feature = "math")]
pub mod math;

/// Numerical algorithms: integration, ODEs, root finding, optimization,
/// window operations, finite differences, sliding statistics.
#[cfg(feature = "numerical")]
pub mod numerical;

/// Linear algebra: matrices, LU/QR/Cholesky decompositions, eigenvalues,
/// Gaussian elimination.
#[cfg(feature = "linear")]
pub mod linear;

/// Signal processing: FIR/IIR filters, window functions, convolution,
/// correlation.
#[cfg(feature = "signal")]
pub mod signal;

/// Statistics: descriptive statistics, correlation, regression,
/// probability distributions.
#[cfg(feature = "stats")]
pub mod stats;

/// Physics: quantum mechanics, thermodynamics, optics.
#[cfg(feature = "physics")]
pub mod physics;

/// Chemistry: atomic data, reaction kinetics, thermodynamics.
#[cfg(feature = "chemistry")]
pub mod chemistry;

// ============================================================================
// Canonical names
// ============================================================================

pub use vec1_core::Vec1;
pub use vec1_core::index1::Index1;

// `vec1!` is automatically exported at the crate root by `#[macro_export]`.

// ============================================================================
// Deprecated re-exports (0.1.x → 0.2.0)
// ============================================================================

/// Deprecated alias for [`Vec1`].
///
/// The container was renamed in `0.2.0`. Update your code to use [`Vec1`].
/// The alias will be removed in `1.0`.
#[deprecated(
    since = "0.2.0",
    note = "use `Vec1` instead; `VecIndexFromOne` will be removed in 1.0"
)]
pub type VecIndexFromOne<T> = Vec1<T>;

/// Deprecated re-export of numeric algorithms.
///
/// In `0.1.x`, all numeric algorithms lived under `one_indexed_vec::ops`.
/// They have been reorganized as methods on [`Vec1`] under the disciplinary
/// modules:
///
/// | Old location | New location |
/// |--------------|--------------|
/// | `ops::prefix_sum` | [`Vec1::prefix_sum`] |
/// | `ops::moving_average` | [`Vec1::moving_average`] |
/// | `ops::sliding_window_max` | [`Vec1::sliding_window_max`] |
/// | `ops::mean` | [`Vec1::mean`] |
/// | `ops::convolve` | [`Vec1::convolve`] |
///
/// This module is intentionally empty. It is kept only so that
/// `use one_indexed_vec::ops::*;` continues to compile without error.
/// New code should import [`Vec1`] directly — all methods are available on
/// the container.
#[deprecated(since = "0.2.0", note = "methods moved to `Vec1`; import `Vec1` instead of `ops`")]
pub mod ops {
    // Intentionally empty.
    //
    // The numeric algorithms previously re-exported here are now methods
    // on `Vec1`. Because methods defined in `impl` blocks are not items
    // that can be re-exported, there is nothing left to `pub use`.
    //
    // Code that previously wrote:
    //
    //     use one_indexed_vec::ops::*;
    //
    // should now write:
    //
    //     use one_indexed_vec::Vec1;
    //
    // and call methods directly, e.g. `v.mean()`, `v.moving_average(3)`.
}

// ============================================================================
// Crate-level tests
// ============================================================================

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn canonical_name_available() {
        let v = Vec1::from(vec![1, 2, 3]);
        assert_eq!(v[1], 1);
        assert_eq!(v[3], 3);
    }

    #[test]
    #[allow(deprecated)]
    fn deprecated_alias_works() {
        let v = VecIndexFromOne::from(vec![1, 2, 3]);
        assert_eq!(v[1], 1);
    }

    #[test]
    fn vec1_macro_available_at_root() {
        let v = crate::vec1![1, 2, 3];
        assert_eq!(v.len(), 3);
    }
}