Wrappers for LAPACK (Fortran)

Overview

LAPACK Package Documentation Build

The package provides wrappers for LAPACK (Fortran).

Architecture

Example

use lapack::*;

let n = 3;
let mut a = vec![3.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 3.0];
let mut w = vec![0.0; n as usize];
let mut work = vec![0.0; 4 * n as usize];
let lwork = 4 * n;
let mut info = 0;

unsafe {
    dsyev(b'V', b'U', n, &mut a, n, &mut w, &mut work, lwork, &mut info);
}

assert!(info == 0);
for (one, another) in w.iter().zip(&[2.0, 2.0, 5.0]) {
    assert!((one - another).abs() < 1e-14);
}

Contribution

Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.

Comments
  • Linker error with OpenBlas

    Linker error with OpenBlas

    When building the example code from the readme, using the crates lapack (0.16.0) and openblas-src (0.6.0), I receive the linker error: undefined reference to `dsyev_'

    This occurs with and without the "system" feature in openblas-src. I mention that all the required crates build fine - it's just my crate with the example code that fails.

    Looking at the linker call that cargo makes, it appears that -lopenblas is not added to the linker options (nor is -llapack, assuming openblas-src builds the bundled Lapack?), and if I manually run the linker with the same arguments that cargo does, but adding -lopenblas, linking succeeds.

    I'm on Arch Linux using Rust 1.27.1

    opened by mattjohnruss 9
  • Fix definitions of *spevx

    Fix definitions of *spevx

    The definitions of *spevx had ifail as a &mut i32, but it should actually be a &mut [i32] since it returns the array of indices of eigenvectors that failed to converge. See netlib reference: http://www.netlib.org/lapack/explore-3.1.1-html/dspevx.f.html

    opened by dgrnbrg 6
  • Linking error undefined reference to `dsyev_'

    Linking error undefined reference to `dsyev_'

    ................/lapack-0.8.1/src/lib.rs:8262: undefined reference to `dsyev_'

    I'm just trying the example and am getting this linking error. I installed OpenBLAS from git, having it in my library path.

    Any idea?

    opened by k34n3 6
  • ggev is considered as a scalar function

    ggev is considered as a scalar function

    ggev has incorrect type. It is not a scalar function and this is related to https://github.com/blas-lapack-rs/lapacke/issues/2. I would like to fix this but having trouble on setting up. Could you explain the procedure for contribution. Thanks

    I tried below command, ./bin/generate.py --sys lapack-sys

    opened by selvavm 4
  • Auxiliary LAPACK routines?

    Auxiliary LAPACK routines?

    What is your opinion on having LAPACK Auxiliary Routines in the crate, i.e. those listed here: http://www.netlib.org/lapack/lawn41/node112.html ?

    I was looking at _lassq right now, and noticed that it's not part of this crate. Is this intentional, or do you welcome PRs for this?

    opened by SuperFluffy 4
  • eigenvalue API bug

    eigenvalue API bug

    Hi,

    I noticed that the interface to the ?geev() methods changed from having argument such as vl: &mut [f64] to vl: &mut f64 (e.g. compare earlier commit 61d32 to commit c4daf ). This seems to be a bug, as vl and vr are array inputs to these functions. I could hand-tune the fortran.py (and c.py) to fix the function calls for ?geev() myself and submit a PR, but I don't know the reasons for switching vl and vr and worry that I may break other functions.

    Note that fixing this will require bumping the version as we'll be changing the API.

    opened by astraw 3
  • Use rust-lang/num instead of stainless-steel/complex?

    Use rust-lang/num instead of stainless-steel/complex?

    Hi,

    It seems that the num crate is quite heavily used, with >100k downloads over all time and thousands in the past weeks alone. In comparison, the complex crate has less than 1.5k downloads over all time. Therefore it seems to me that num is the de-facto standard for complex numbers and another module is likely going to lead to unnecessary code bloat and casting.

    Are there any compelling reasons to stick with complex rather than switching to num? I'm not aware of any, but neither have I looked particularly deeply at the issue. Otherwise, I would propose moving to the num create. If there are features missing from num, I suppose the devs would welcome implementation of those missing features.

    Another point is that, because num defines their Complex type as a generic for type T, it would be easier to implement support for different types as suggested in #6.

    /// A complex number in Cartesian form.
    #[derive(PartialEq, Copy, Clone, Hash, Debug)]
    #[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
    pub struct Complex<T> {
        /// Real portion of the complex number
        pub re: T,
        /// Imaginary portion of the complex number
        pub im: T
    }
    

    Finally, for maintaining compatibility in client code that uses complex::c32 and complex::c64, the following functions or similar could be used to implement the relevant cast:

    extern crate num;
    extern crate complex;
    use std::mem::transmute;
    
    #[inline]
    fn to_complex_c32(x: & mut [num::Complex<f32>]) -> & mut [complex::c32] {
        unsafe { transmute(x) }
    }
    
    #[inline]
    fn to_complex_c64(x: & mut [num::Complex<f64>]) -> & mut [complex::c64] {
        unsafe { transmute(x) }
    }
    
    opened by astraw 3
  • Update num-complex 0.4

    Update num-complex 0.4

    https://github.com/rust-num/num-complex/releases/tag/num-complex-0.4.0

    • blas https://github.com/blas-lapack-rs/blas/pull/35
    • cblas https://github.com/blas-lapack-rs/cblas/pull/5
    • lapack https://github.com/blas-lapack-rs/lapack/pull/26
    • lapacke https://github.com/blas-lapack-rs/lapacke/pull/4
    opened by termoshtt 2
  • how to switch backend depending on platform (mac or linux)?

    how to switch backend depending on platform (mac or linux)?

    Is there a way to support switching backends depending on the OS target (eg, if mac or linux)?

    I tried specifying my cargo.toml with platform specific dependencies like:

    cargo.toml

    [target.'cfg(target_os = "macos")'.dependencies]
    lapack = "0.16.0"
    blas = "0.20.0"
    lapack-src = { version = "0.6", features = ["accelerate"] }
    accelerate-src = "0.3.2"
    
    [target.'cfg(target_os = "linux")'.dependencies]
    lapack = "0.16.0"
    blas = "0.20.0"
    lapack-src = { version = "0.6", features = ["openblas"] }
    openblas-src = "0.9"
    

    lib.rs

    extern crate blas;
    extern crate lapack;
    extern crate lapack_src;
    
    #[cfg(target_os = "macos")]
    extern crate accelerate_src;
    
    #[cfg(target_os = "linux")]
    extern crate openblas_src;
    

    but I get the error:

     --> ... lapack-src-0.6.0/src/lib.rs:43:1
       |
    34 | extern crate accelerate_src as raw;
       | ----------------------------------- previous import of the extern crate `raw` here
    ...
    43 | extern crate openblas_src as raw;
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `raw` reimported here
       |
       = note: `raw` must be defined only once in the type namespace of this module
    help: you can use `as` to change the binding name of the import
       |
    43 | extern crate openblas_src as other_raw;
    
    opened by DrRibosome 2
  • Out-variables are unnecessarily slices

    Out-variables are unnecessarily slices

    For example, the iter argument to dsgesv is a single integer, but the bindings here have it represented as an &mut [i32] rather than &mut i32.

    bug 
    opened by sfackler 2
  • add accelerate provider

    add accelerate provider

    Hi, I managed to get Apple's Accelerate.framework packaged up and published to crates.io. It would be create if you could merge this and make a new release. Thanks!

    opened by astraw 2
  • Should lapack/lapack-sys depend on lapack-src?

    Should lapack/lapack-sys depend on lapack-src?

    I have the following dependencies in Cargo.toml

    lapack = "0.17.0"
    lapack-src = { version="0.8.0", features=["openblas"]}
    

    When I use functions from lapack in my crate, I get linker errors (undefined symbols). This can be solved by adding extern crate lapack_src as _; to my crate, but this behavior is a footgun, as debugging it requires understanding rust linkage model (and its interaction with cargo). As far as I understand it, the issue would be solved if an upstream crate would depend on lapack-src itself.

    Could this be done here ? Or would it be better to do it in lapack-sys ?

    opened by cassiersg 9
Owner
BLAS and LAPACK for Rust
BLAS and LAPACK for Rust
Wrappers for BLAS (Fortran)

BLAS The package provides wrappers for BLAS (Fortran). Architecture Example use blas::*; let (m, n, k) = (2, 4, 3); let a = vec![ 1.0, 4.0, 2

BLAS and LAPACK for Rust 61 Nov 24, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Rust binding of fortran Limited memory LBFGS subroutine

lbfgs-sys Rust binding of fortran L-BFGS-B subroutine. The orginal fortran subroutine is distributed under BSD-3 license. To know more about the condi

Naushad Karim 10 Sep 23, 2022
High-level PortMidi bindings and wrappers for Rust

portmidi-rs High-level PortMidi bindings for Rust. PortMidi website: http://portmedia.sourceforge.net/portmidi/ Installation Add this to your Cargo.to

Philippe Delrieu 69 Dec 1, 2022
PortAudio bindings and wrappers for Rust.

rust-portaudio PortAudio bindings and wrappers for Rust. PortAudio is a free, cross-platform, open-source, audio I/O library. rust-portaudio is still

null 331 Dec 23, 2022
Cross-platform Rust wrappers for the USB ID Repository

usb-ids Cross-platform Rust wrappers for the USB ID Repository. This library bundles the USB ID database, allowing platforms other than Linux to query

William Woodruff 18 Dec 14, 2022
This crate provides a convenient macro that allows you to generate type wrappers that promise to always uphold arbitrary invariants that you specified.

prae This crate provides a convenient macro that allows you to generate type wrappers that promise to always uphold arbitrary invariants that you spec

null 96 Dec 4, 2022
Thin but safe ALSA wrappers for Rust

ALSA bindings for Rust Thin but safe wrappers for ALSA, the most common API for accessing audio devices on Linux. The ALSA API is rather big, so every

null 91 Dec 26, 2022
ZKP fork for rust-secp256k1, adds wrappers for range proofs, pedersen commitments, etc

rust-secp256k1 rust-secp256k1 is a wrapper around libsecp256k1, a C library by Peter Wuille for producing ECDSA signatures using the SECG curve secp25

null 53 Dec 19, 2022
Rust wrappers for NGT approximate nearest neighbor search

ngt-rs   Rust wrappers for NGT, which provides high-speed approximate nearest neighbor searches against a large volume of data. Note that NGT will be

Romain Leroux 16 Sep 19, 2022
Rust bindings and wrappers for GLib, GDK 3, GTK+ 3 and Cairo.

THIS REPOSITORY IS DEPRECATED SEE: https://github.com/rust-gnome rgtk Rust bindings and wrappers for GLib, GDK 3, GTK+ 3 and Cairo. Building rgtk expe

Jeremy Letang 124 Jul 10, 2022
Cross-platform Rust wrappers for the PCI ID Repository

pci-ids This project is modified from wooduffw's usb-ids.rs (https://github.com/woodruffw/usb-ids.rs) Cross-platform Rust wrappers for the PCI ID Repo

Charles Lien 9 Dec 9, 2022
High-level PortMidi bindings and wrappers for Rust

High-level PortMidi bindings and wrappers for Rust

Philippe Delrieu 69 Dec 1, 2022
PortAudio bindings and wrappers for Rust.

rust-portaudio PortAudio bindings and wrappers for Rust. PortAudio is a free, cross-platform, open-source, audio I/O library. rust-portaudio is still

null 332 Dec 30, 2022
A library for constructing Groth-Sahai proofs using pre-built wrappers

Groth-Sahai Wrappers A Rust library containing wrappers that facilitate the construction of non-interactive witness-indistinguishable and zero-knowled

Jacob White 1 Mar 7, 2022
Runit service management wrappers

void-svtools Basic wrappers for managing services for runit,

Isaac Hung 1 Aug 3, 2022
Type-safe SQL query wrappers

fnsql   The fnsql crate provides simple type-safe optional wrappers around SQL queries. Instead of calling type-less .query() and .execute(), you call

Dan Aloni 9 Apr 29, 2022
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022
An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers. written in rust(🦀) with ❤️

Les.rs - Rust Cryptocurrency Exchange Library An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and

Crabby AI 4 Jan 9, 2023