Docs.rs
  • numeric-array-0.6.1
    • numeric-array 0.6.1
    • Permalink
    • Docs.rs crate page
    • MIT OR Apache-2.0
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • novacrazy
    • Dependencies
      • generic-array ^1.1.0 normal
      • num-traits ^0.2 normal
      • serde ^1.0 normal optional
      • serde_json ^1.0 dev
    • Versions
    • 100% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate numeric_array

numeric_array0.6.1

  • All Items

Sections

  • numeric-array

Crate Items

  • Re-exports
  • Modules
  • Macros
  • Structs
  • Traits

Crates

  • numeric_array

Crate numeric_array

Source
Expand description

§numeric-array

crates.io Documentation MIT/Apache-2 licensed

numeric-array is a wrapper around generic-array that adds efficient numeric trait implementations, designed to encourage LLVM to autovectorize expressions into SIMD instructions and perform compile-time evaluation.

All stable core::ops traits are implemented for NumericArray itself, plus the thin NumericConstant type, which is required to differeniate constant values from NumericArray itself.

Additionally, most of num_traits are implemented, including Num itself. So you can even use a whole array as a generic number.

Example:

use num_traits::Float;
use numeric_array::{NumericArray, narr};

fn main() {
    let a = narr![1.0, 2.0, 3.0, 4.0];
    let b = narr![5.0, 6.0, 7.0, 8.0];
    let c = narr![9.0, 1.0, 2.0, 3.0];

    // Compiles to a single vfmadd213ps instruction on my machine
    let d = a.mul_add(b, c);

    assert_eq!(d, narr![14.0, 13.0, 23.0, 35.0]);
}

When used with RUSTFLAGS = "-C opt-level=3 -C target-cpu=native", then Rust and LLVM are smart enough to autovectorize almost all operations into SIMD instructions, or even just evaluate them at compile time. The above example is actually evaluated at compile time, so if you were to view the assembly it would show the result only.

This is ideal for situations where simple component-wise operations are required for arrays.

Re-exports§

pub extern crate generic_array;
pub use generic_array::typenum;

Modules§

geometry
impls
Implementation notes
simd
Context-sensitive SIMD operations

Macros§

narr
Sugar for NumericArray::new(arr![...])
nconstant
Creates a new NumericConstant from the given expression.

Structs§

NumericArray
A numeric wrapper for a GenericArray, allowing for easy numerical operations on the whole sequence.
NumericConstant
This is required to allow NumericArray to be operated on by both other NumericArray instances and constants, with generic types, because some type U supercedes NumericArray<U, N>

Traits§

ArrayLength
Trait used to define the number of elements in a GenericArray.

Results

Settings
Help
    trait
    numeric_array::geometry::Geometric
    module
    numeric_array::geometry
    trait method
    numeric_array::geometry::Geometric::norm_squared
    &Geometric -> T
    trait method
    numeric_array::geometry::Geometric::scalar_product
    &Geometric, &Geometric -> T
    trait method
    numeric_array::geometry::Geometric::abs_scalar_product
    &Geometric, &Geometric -> T
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.