nalgebra/nalgebra-lapack/src/lib.rs

149 lines
3.8 KiB
Rust
Raw Normal View History

//! # nalgebra-lapack
2018-02-02 19:26:35 +08:00
//!
//! Rust library for linear algebra using nalgebra and LAPACK.
2018-02-02 19:26:35 +08:00
//!
//! ## Documentation
2018-02-02 19:26:35 +08:00
//!
//! Documentation is available [here](https://docs.rs/nalgebra-lapack/).
2018-02-02 19:26:35 +08:00
//!
//! ## License
2018-02-02 19:26:35 +08:00
//!
//! MIT
2018-02-02 19:26:35 +08:00
//!
//! ## Cargo features to select lapack provider
2018-02-02 19:26:35 +08:00
//!
//! Like the [lapack crate](https://crates.io/crates/lapack) from which this
//! behavior is inherited, nalgebra-lapack uses [cargo
//! features](https://doc.crates.io/manifest.html#the-[features]-section) to select
//! which lapack provider (or implementation) is used. Command line arguments to
//! cargo are the easiest way to do this, and the best provider depends on your
//! particular system. In some cases, the providers can be further tuned with
//! environment variables.
2018-02-02 19:26:35 +08:00
//!
//! Below are given examples of how to invoke `cargo build` on two different systems
//! using two different providers. The `--no-default-features --features "provider"`
//! arguments will be consistent for other `cargo` commands.
2018-02-02 19:26:35 +08:00
//!
//! ### Ubuntu
2018-02-02 19:26:35 +08:00
//!
//! As tested on Ubuntu 12.04, do this to build the lapack package against
//! the system installation of netlib without LAPACKE (note the E) or
//! CBLAS:
2018-02-02 19:26:35 +08:00
//!
//! ```.ignore
//! sudo apt-get install gfortran libblas3gf liblapack3gf
//! export CARGO_FEATURE_SYSTEM_NETLIB=1
//! export CARGO_FEATURE_EXCLUDE_LAPACKE=1
//! export CARGO_FEATURE_EXCLUDE_CBLAS=1
2018-02-02 19:26:35 +08:00
//!
//! export CARGO_FEATURES="--no-default-features --features netlib"
//! cargo build ${CARGO_FEATURES}
//! ```
2018-02-02 19:26:35 +08:00
//!
2018-09-25 14:28:48 +08:00
//! ### macOS
2018-02-02 19:26:35 +08:00
//!
2018-09-25 14:28:48 +08:00
//! On macOS, do this to use Apple's Accelerate framework:
2018-02-02 19:26:35 +08:00
//!
//! ```.ignore
//! export CARGO_FEATURES="--no-default-features --features accelerate"
//! cargo build ${CARGO_FEATURES}
//! ```
2018-02-02 19:26:35 +08:00
//!
//! [version-img]: https://img.shields.io/crates/v/nalgebra-lapack.svg
//! [version-url]: https://crates.io/crates/nalgebra-lapack
//! [status-img]: https://travis-ci.org/strawlab/nalgebra-lapack.svg?branch=master
//! [status-url]: https://travis-ci.org/strawlab/nalgebra-lapack
//! [doc-img]: https://docs.rs/nalgebra-lapack/badge.svg
//! [doc-url]: https://docs.rs/nalgebra-lapack/
2018-02-02 19:26:35 +08:00
//!
//! ## Contributors
//! This integration of LAPACK on nalgebra was
//! [initiated](https://github.com/strawlab/nalgebra-lapack) by Andrew Straw. It
//! then became officially supported and integrated to the main nalgebra
//! repository.
#![deny(non_camel_case_types)]
#![deny(unused_parens)]
#![deny(non_upper_case_globals)]
#![deny(unused_qualifications)]
#![deny(unused_results)]
#![deny(missing_docs)]
2018-11-07 01:32:20 +08:00
#![doc(
html_favicon_url = "https://nalgebra.org/img/favicon.ico",
html_root_url = "https://nalgebra.org/rustdoc"
2018-11-07 01:32:20 +08:00
)]
extern crate nalgebra as na;
2018-02-02 19:26:35 +08:00
extern crate num_traits as num;
mod lapack_check;
mod cholesky;
mod eigen;
mod hessenberg;
mod lu;
mod qr;
mod schur;
mod svd;
mod symmetric_eigen;
use num_complex::Complex;
pub use self::cholesky::{Cholesky, CholeskyScalar};
pub use self::eigen::Eigen;
pub use self::hessenberg::Hessenberg;
pub use self::lu::{LUScalar, LU};
pub use self::qr::QR;
pub use self::schur::Schur;
pub use self::svd::SVD;
pub use self::symmetric_eigen::SymmetricEigen;
trait ComplexHelper {
type RealPart;
fn real_part(self) -> Self::RealPart;
}
impl ComplexHelper for f32 {
type RealPart = f32;
#[inline]
fn real_part(self) -> Self::RealPart {
self
}
}
impl ComplexHelper for f64 {
type RealPart = f64;
#[inline]
fn real_part(self) -> Self::RealPart {
self
}
}
impl ComplexHelper for Complex<f32> {
type RealPart = f32;
#[inline]
fn real_part(self) -> Self::RealPart {
self.re
}
}
impl ComplexHelper for Complex<f64> {
type RealPart = f64;
#[inline]
fn real_part(self) -> Self::RealPart {
self.re
}
}
unsafe fn uninitialized_vec<T: Copy>(n: usize) -> Vec<T> {
let mut res = Vec::new();
res.reserve_exact(n);
res.set_len(n);
res
}