lapack/
lib.rs

1//! Wrappers for [LAPACK] \(Fortran).
2//!
3//! ## [Architecture]
4//!
5//! ## Example
6//!
7//! ```no_run
8//! use lapack::*;
9//!
10//! let n = 3;
11//! let mut a = vec![3.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.0];
12//! let mut w = vec![0.0; n as usize];
13//! let mut work = vec![0.0; 4 * n as usize];
14//! let lwork = 4 * n;
15//! let mut info = 0;
16//!
17//! unsafe {
18//!     dsyev(b'V', b'U', n, &mut a, n, &mut w, &mut work, lwork, &mut info);
19//! }
20//!
21//! assert!(info == 0);
22//! for (one, another) in w.iter().zip(&[2.0, 2.0, 5.0]) {
23//!     assert!((one - another).abs() < 1e-14);
24//! }
25//! ```
26//!
27//! [architecture]: https://blas-lapack-rs.github.io/architecture
28//! [lapack]: https://en.wikipedia.org/wiki/LAPACK
29
30#![allow(
31    clippy::missing_safety_doc,
32    clippy::missing_transmute_annotations,
33    clippy::too_many_arguments
34)]
35
36extern crate lapack_sys as ffi;
37extern crate num_complex as num;
38
39use std::mem::transmute;
40
41use libc::{c_char, size_t};
42
43/// A complex number with 32-bit parts
44#[allow(non_camel_case_types)]
45pub type c32 = num::Complex<f32>;
46
47/// A complex number with 64-bit parts
48#[allow(non_camel_case_types)]
49pub type c64 = num::Complex<f64>;
50
51pub type Select2F32 = Option<extern "C" fn(*const f32, *const f32) -> i32>;
52pub type Select3F32 = Option<extern "C" fn(*const f32, *const f32, *const f32) -> i32>;
53
54pub type Select2F64 = Option<extern "C" fn(*const f64, *const f64) -> i32>;
55pub type Select3F64 = Option<extern "C" fn(*const f64, *const f64, *const f64) -> i32>;
56
57pub type Select1C32 = Option<extern "C" fn(*const c32) -> i32>;
58pub type Select2C32 = Option<extern "C" fn(*const c32, *const c32) -> i32>;
59
60pub type Select1C64 = Option<extern "C" fn(*const c64) -> i32>;
61pub type Select2C64 = Option<extern "C" fn(*const c64, *const c64) -> i32>;
62
63include!("lapack-sys.rs");