Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BLAS bindings for Rust

License

NotificationsYou must be signed in to change notification settings

mikkyang/rust-blas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT licensedcrates.io

Rust bindings and wrappers for BLAS (Basic Linear Algebra Subprograms).

Overview

RBLAS wraps each external call in a trait with the same name (but capitalized).This trait contains a single static method, of the same name. These traits aregeneric over the four main types of numbers BLAS supports:f32,f64,Complex32, andComplex64.

For example the functionscblas_saxpy,cblas_daxpy,cblas_caxypy, andcblas_zaxpy are called with the functionAxpy::axpy.

Additionally, RBLAS introduces a few traits to shorten calls to these BLASfunctions:Vector for types that implement vector-like characteristics andMatrix for types that implement matrix-like characteristics. TheVectortrait is already implemented byVec and[] types.

Documentation

Installation

By default, the library links withblas dynamically. To link to an alternateimplementation, like OpenBLAS, use the environment variableCARGO_BLAS. Ifyou've already built the bindings, you may need to clean and build again.

export CARGO_BLAS=openblas

Example

externcrate rblas;use rblas::Dot;fnmain(){let x =vec![1.0, -2.0,3.0,4.0];let y =[1.0,1.0,1.0,1.0,7.0];let d =Dot::dot(&x,&y[..x.len()]);assert_eq!(d,6.0);}

Sugared Example (Soon to be Deprecated)

#[macro_use]externcrate rblasas blas;use blas::math::Mat;use blas::{Matrix,Vector};use blas::math::Marker::T;fnmain(){let x =vec![1.0,2.0];let xr =&xas&Vector<_>;let i =mat![1.0,0.0;0.0,1.0];let ir =&ias&Matrix<_>;assert!(xr +&x ==2.0* xr);assert!(ir* xr == x);let dot =(xr ^T)* xr;assert!(dot ==5.0);}

About

BLAS bindings for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp