rust-ndarray / ndarray-linalg Goto Github PK
View Code? Open in Web Editor NEWLinear algebra package for rust-ndarray using LAPACK binding
License: Other
Linear algebra package for rust-ndarray using LAPACK binding
License: Other
You code does not work on mac os
= note: ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How do I resolve? Or is this codebase no longer valid
ndarray_linalg::generate::random
only supports f32
, f64
, c32
, and c64
. It should use rand::Rand
trait
https://doc.rust-lang.org/rand/rand/trait.Rand.html
I have no idea for supporting LAPACK binding to general ArrayBase.
cargo build
works correctly on my host using features=["openblas"]
. However, when cross compiling to armv7-unknown-linux-gnueabihf
, I get the following (truncated) error:
error: linking with `arm-linux-gnueabihf-gcc` failed: exit code: 1
= note: /target/armv7-unknown-linux-gnueabihf/debug/deps/libopenblas_src-75b3c950014242b8.rlib: error adding symbols: File format not recognized
I assumed the openblas-src crate would have taken care of acquiring the correct armv7 libs, but it looks like I'm mistaken. Any suggestions? Should I take my question to openblas-src
?
As argued in #29
macOS CI has been introduced at #141 only intel-mkl. backend.
I have this error using the det()
method in a function
undefined reference to `LAPACKE_dgetrf`
in Archlinux
Thanks in advance
Arnoldi method is a fundamental component of Krylov subspace method, which is used in sparse matrix context. However, the idea of Arnoldi method can be extended to general linear operators.
Any suggestions are welcome :)
The default backend features is omitted at version 0.8 when we switch to LAPACKE implementation.
See also how BLAS/LAPACK wrappers select their backend: https://github.com/blas-lapack-rs/blas-lapack-rs.github.io/wiki
Current empty default feature causes an issue as reported in #102, we cannot run cargo test
without specifying the backend. The merit of empty default is that we can avoid duplicated dependencies.
lapack has switch to select the LAPACK backend.
https://github.com/stainless-steel/lapack/blob/master/Cargo.toml
Related to rust-ndarray/ndarray#424
Methods that modify the input array in-place, such as solve_mut
and cholesky_mut
, would be better named *_inplace
, such as solve_inplace
and cholesky_inplace
, to maintain consistency with ndarray
. (See ArrayBase::map_inplace
and ArrayBase::mapv_inplace
.) Additionally, it would be clearer for those methods not to return a reference to the array that is being modified. In other words, I suggest changing:
fn solve_mut<'a, Sb: DataMut<Elem = A>>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>;
to
fn solve_inplace<'a, Sb: DataMut<Elem = A>>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<()>;
and
fn cholesky_mut(&mut self, uplo: UPLO) -> Result<&mut Self>;
to
fn cholesky_inplace(&mut self, uplo: UPLO) -> Result<()>;
etc.
What do you think? I can submit a PR with this change.
Consider the following code
let a = arr2(&[[1.], [0.]]);
let (q, r) = a.qr().unwrap();
println!("q = {}", q);
println!("r = {}", r);
The output is
q = [[1],
[0]]
r = [[1]]
however I was expecting q
to be of size 2 x 2
and r
of size 2 x 1
.
For instance, in Matlab, [q, r] = qr([1; 0])
prints
q =
1 0
-0 1
r =
1
0
Implement basic subroutines:
ndarray::linalg::Dot
is limited to use Array
and the RHS
must be reference. We can loosen this restriction, and more general Dot
should be defined in this crate.
https://github.com/bbrener1/dylib_linking_test
Minimum reproducible case in repo above
When SVD is performed on a 2x2 matrix, for example a an identity matrix containing f64s, the program terminates with a segfault.
I have reproduced this bug on Ubuntu and OSX, and have reproduced it using Intel-MKL and OpenBlas backends.
Bug is also apparent in a docker container using run -it rust:latest, so versioning is unlikely to be at issue.
Please see if you can reproduce and track down the cause
ndarray needs the "blas"
feature to enable using blas for its matrix multiplication (and dot product).
That feature enables calling blas without explicitly picking any particular backend.
Picking backend is tricky in general; indeed none of our libraries should pick one, but enable the end user, final application, to pick the blas/lapack provider.
I was made aware of this crate today, and feel free to report any issues with upstream ndarray. Please note that it's best to migrate to the Ix1, Ix2
etc dimensionality type aliases, for compatibility with future versions.
https://circleci.com/gh/termoshtt/ndarray-linalg/124
Intel MKL ERROR: Parameter 4 was incorrect on entry to DGETRF.
test det_empty ... FAILED
test det_zero_nonsquare ... ok
test det_zero ... ok
test det_nonsquare ... ok
test det ... ok
failures:
---- det_empty stdout ----
thread 'det_empty' panicked at 'called `Result::unwrap()` on an `Err` value: Lapack { return_code: -5 }', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failures:
det_empty
Intel MKL ERROR: Parameter 4 was incorrect on entry to DGETRF.
Parameter 4 is LDA and 0
is passed, but LDA must be lager than 1.
Inherited from #17
Current code only supports real numbers, i.e. f32
and f64
.
Some algorithm in the linear algebra are closed in real number, but others are not.
There are many duplicated codes in tests/ directory
Related to #76
SolveH
does not fill the lower matrix while others (e.g. EigH
) fill.SolveH
is missingFollowing features are lacking:
invh
, invh_into
solveh
, factorizeh
Note that using row-major ordering may require more memory and time than column-major ordering, because the routine must transpose the row-major order to the column-major order required by the underlying LAPACK routine.
http://www.netlib.org/lapack/lapacke.html
I found while implementing rust-ndarray/ndarray#445 that the interface between CBLAS and LAPACKE around UPLO
and other parameter are incompatible. I will use BLAS instead of CBLAS for it since the interface of BLAS is compatible with LAPACK (use u8
always). We should use LAPACK instead of LAPACKE (´・ω・`)
Float
and Complex
traits in num
crate support same functions, e.g. sin
, ln
, and so on.
Since real number can be regarded as a complex number naturally, all methods for Complex
can be implemented for Scalar
.
Restore outer product removed in #41
Some functions (including solve_inplace
but probably many others) are missing checks that the input arrays have matching shapes. As a result, the current implementation of solve_inplace
can lead to buffer overflow if the shapes don't match (e.g. if the number of rows in b
is less than the number of rows/columns in a
).
Example with ndarray
0.12 and ndarray-linalg
0.10:
extern crate ndarray;
extern crate ndarray_linalg;
use ndarray::array;
use ndarray::prelude::*;
use ndarray_linalg::solve::Solve;
fn main() {
let a = array![[1., 2.], [3., 4.]];
let mut b = array![1.];
// This is a read of uninitialized memory one past the end of `b`. This is
// undefined behavior, but the point of this print statement is to show
// that calling `a.solve_inplace(&mut b)` changes the value of the element
// one past the end of `b`.
//
// On my system, this prints `0`, but it could print anything because the
// memory is uninitialized.
println!("{}", unsafe { *b.as_ptr().wrapping_offset(1) } );
// This should panic or return an error because `a` is `2x2` and `b` has
// length `1`.
a.solve_inplace(&mut b).unwrap();
// Prints `[-1.9999999999999998]` on my system, which corresponds to the
// first element in the solution if `b` was `array![1., 0.]`.
println!("{}", b);
// This is another read of uninitialized memory one past the end of `b`.
// This is undefined behavior, but the point of this print statement is to
// show that calling `a.solve_inplace(&mut b)` changes the value of the
// element one past the end of `b`.
//
// On my system, this prints `1.4999999999999998`, which corresponds to the
// second element in the solution if `b` was `array![1., 0.]`.
println!("{}", unsafe { *b.as_ptr().wrapping_offset(1) } );
}
Hallo rustaceans, so I am having an issue compiling this library on windows.
Here is what is happening. I am trying to use ndarray-linalg with ndarray to compute some inverses. So I added ndarray-linalg to dependencies in cargo.toml , and I also added openblas-src and included both as extern crates in my main. Here is what that looks like in code:
MY TOML:
[package]
name = "kalman"
version = "0.1.0"
authors = ["VanioBegic <[email protected]>"]
edition = "2018"
[dependencies]
ndarray = "0.12.1"
ndarray-linalg = "0.10"
openblas-src = "0.7.0"
MY EXTERN CRATES:
extern crate ndarray;
extern crate ndarray_linalg;
extern crate openblas_src;
With stable-gnu toolchain I get :
Running `rustc --edition=2018 --crate-name kalman src\main.rs --color always --crate-type bin --emit=dep-info,link
-C debuginfo=2 -C metadata=3ba5ee5205741b31 -C extra-filename=-3ba5ee5205741b31 --out-dir D:\rust\kalman\target\debug\de
ps -C incremental=D:\rust\kalman\target\debug\incremental -L dependency=D:\rust\kalman\target\debug\deps --extern ndarra
y=D:\rust\kalman\target\debug\deps\libndarray-3abb85534de560ac.rlib --extern ndarray_linalg=D:\rust\kalman\target\debug\
deps\libndarray_linalg-837a2f143f8d01ff.rlib --extern openblas_src=D:\rust\kalman\target\debug\deps\libopenblas_src-98bd
3a2195e9d264.rlib -L native=C:\Users\py-goku\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gn
u-0.4.0\lib -L D:/rust/kalman/target/debug/build/openblas-src-f55a152752440e9e/out\opt/OpenBLAS/lib`
warning: unused variable: `meas`
--> src\main.rs:11:9
|
11 | let meas: Array1<f64> = array![1., 0., 0., 0.];
| ^^^^ help: consider prefixing with an underscore: `_meas`
|
= note: #[warn(unused_variables)] on by default
error: linking with `gcc` failed: exit code: 1
|
= note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "C:\\User
s\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "C:\\Us
ers\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-
L" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "D:
\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.102bwz4cwkffz5vr.rcgu.o" "D:\\rust\\kalman\\target\\debug\\
deps\\kalman-3ba5ee5205741b31.12v645j3ed9vrayd.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1
6isqldkpweo3rur.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.19slj34d2n53xkag.rcgu.o" "D:\\ru
st\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1cbieft2qihz0um3.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps
\\kalman-3ba5ee5205741b31.1kb7no5rybe2myhg.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1mu76
0b1ftzhvbs8.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1oe1wuyo9u1furts.rcgu.o" "D:\\rust\\
kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1oh0kko3nivgxo4g.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\ka
lman-3ba5ee5205741b31.1u6h40oxl1w440tx.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1xgys4oqa
w595mwz.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.1ycderw9dyln7txc.rcgu.o" "D:\\rust\\kalm
an\\target\\debug\\deps\\kalman-3ba5ee5205741b31.21gxnztygpshb3j3.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman
-3ba5ee5205741b31.23aglk462cweq2tu.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.25jhqgnco7q8c
e6l.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.28kn6i6qj0xoc7ih.rcgu.o" "D:\\rust\\kalman\\
target\\debug\\deps\\kalman-3ba5ee5205741b31.2d335ex5ci33x0mu.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba
5ee5205741b31.2mbo2q1by6etfp1v.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.2o3xqkkxkz4hk56d.
rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.2oreuwq78gy19k4p.rcgu.o" "D:\\rust\\kalman\\targ
et\\debug\\deps\\kalman-3ba5ee5205741b31.2s0woql8r85jpm93.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5
205741b31.2syhpmbs0vt23e9e.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.2xmrc77t5vpuds2v.rcgu
.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.2y0eikb0ni9mvbuh.rcgu.o" "D:\\rust\\kalman\\target\\
debug\\deps\\kalman-3ba5ee5205741b31.322s0azx0gvb6foz.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee52057
41b31.3274hbhvixc0fczt.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.360iu1b8mfs2nysh.rcgu.o"
"D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.36yroxof3ov7rqre.rcgu.o" "D:\\rust\\kalman\\target\\debu
g\\deps\\kalman-3ba5ee5205741b31.38kyfr76uj2a2bza.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b3
1.3bxknp5ydhjwfs4r.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.3g31ewik06yt4dx4.rcgu.o" "D:\
\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.3gb6svwqmw2d3cuv.rcgu.o" "D:\\rust\\kalman\\target\\debug\\d
eps\\kalman-3ba5ee5205741b31.3npev0sfva8zu3rl.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.3u
4nqwy6op7z7z3p.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.432otjgawcbviyn0.rcgu.o" "D:\\rus
t\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.43f2vnho2v4js9zn.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\
\kalman-3ba5ee5205741b31.44dho71mqna2nsji.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4m1wx1
nlnneqswvs.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4mu15vejcyr6v0ak.rcgu.o" "D:\\rust\\k
alman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4pfvogc8v3bidymm.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kal
man-3ba5ee5205741b31.4rmsuic72egughkf.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4vl37wzs3p
aztefe.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4w7xz6zu7lkiyx9n.rcgu.o" "D:\\rust\\kalma
n\\target\\debug\\deps\\kalman-3ba5ee5205741b31.4xatvkvk6hhumofn.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-
3ba5ee5205741b31.527sx3hb26ryx334.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.54pg963me85rnq
0j.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.62a08qibvfulcfp.rcgu.o" "D:\\rust\\kalman\\ta
rget\\debug\\deps\\kalman-3ba5ee5205741b31.9jf9aw94plte2d2.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee
5205741b31.cramvzkpulzdyt3.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.dlwfetkynhnb8dp.rcgu.
o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.jxoz41mcrc3c5a4.rcgu.o" "D:\\rust\\kalman\\target\\de
bug\\deps\\kalman-3ba5ee5205741b31.tlpcufstnrcyjhv.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b
31.tqza18r74x5zojf.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.u8dbchyx23lmf04.rcgu.o" "D:\\
rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.wn17a3u9d8xnqvi.rcgu.o" "D:\\rust\\kalman\\target\\debug\\dep
s\\kalman-3ba5ee5205741b31.xr1bibrv3g4cpex.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.zwnpc
s8vp2qvpeu.rcgu.o" "-o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-3ba5ee5205741b31.exe" "D:\\rust\\kalman\\target\\
debug\\deps\\kalman-3ba5ee5205741b31.25gr5761hlccinua.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\\rust\\kalma
n\\target\\debug\\deps" "-L" "C:\\Users\\py-goku\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-x86_64-pc-w
indows-gnu-0.4.0\\lib" "-L" "D:/rust/kalman/target/debug/build/openblas-src-f55a152752440e9e/out\\opt/OpenBLAS/lib" "-L"
"C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,
-Bstatic" "D:\\rust\\kalman\\target\\debug\\deps\\libopenblas_src-98bd3a2195e9d264.rlib" "D:\\rust\\kalman\\target\\debu
g\\deps\\libndarray_linalg-837a2f143f8d01ff.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\librand-86be185ec55e8bfa.rlib"
"D:\\rust\\kalman\\target\\debug\\deps\\libwinapi-700386b500e7fb4f.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libran
d_core-eb435bcd66f10ec7.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\librand_core-38a8cdd77640f568.rlib" "D:\\rust\\kal
man\\target\\debug\\deps\\liblapacke-85b05e19e76f0926.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\liblapacke_sys-0de30
ba7859d1867.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libndarray-3abb85534de560ac.rlib" "D:\\rust\\kalman\\target\\d
ebug\\deps\\libnum_complex-82363a479edd90b7.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libnum_traits-553d440d3fe42740
.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libitertools-18b588cfb0c0e6f0.rlib" "D:\\rust\\kalman\\target\\debug\\dep
s\\libeither-5ee002a6bfa0d5e3.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libmatrixmultiply-e5bbb7c57020595e.rlib" "D:
\\rust\\kalman\\target\\debug\\deps\\librawpointer-419e217115828537.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libbla
s_src-2127476f8a7e5e4a.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libcblas_sys-124fa1b3851d4c83.rlib" "D:\\rust\\kalm
an\\target\\debug\\deps\\liblibc-08ef32ba80f20c5a.rlib" "-Wl,--start-group" "C:\\Users\\py-goku\\.rustup\\toolchains\\st
able-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-744703a485660c1e.rlib" "C:\\Users\\py-goku\
\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-28c855288f
12d465.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu
\\lib\\libbacktrace_sys-1f1894ea56815eb1.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\l
ib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-54d77c07f0360832.rlib" "C:\\Users\\py-goku\\.rustup\\toolchai
ns\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-4a1182a5162d96f6.rlib" "C:\\Users\
\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-f110a63e7
9ca9506.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gn
u\\lib\\liballoc-72088863526c7b10.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rus
tlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-8bdc5136c286e0c9.rlib" "C:\\Users\\py-goku\\.rustup\\toolc
hains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-493ddf3b73736766.rlib" "-Wl,--end
-group" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib
\\libcompiler_builtins-7bd2330f2cf0f215.rlib" "-Wl,-Bdynamic" "-lgfortran" "-lopenblas" "-lwinapi_advapi32" "-lwinapi_cr
edui" "-lwinapi_kernel32" "-lwinapi_secur32" "-ladvapi32" "-lws2_32" "-luserenv" "-Wl,-Bstatic" "-lgcc_eh" "-lpthread" "
-Wl,-Bdynamic" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "C:\\Users\\py-goku\\.rustu
p\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
= note: ld: cannot find -lgfortran
error: aborting due to previous error
error: Could not compile `kalman`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name kalman src\main.rs --color always --crate-type bi
n --emit=dep-info,link -C debuginfo=2 -C metadata=3ba5ee5205741b31 -C extra-filename=-3ba5ee5205741b31 --out-dir D:\rust
\kalman\target\debug\deps -C incremental=D:\rust\kalman\target\debug\incremental -L dependency=D:\rust\kalman\target\deb
ug\deps --extern ndarray=D:\rust\kalman\target\debug\deps\libndarray-3abb85534de560ac.rlib --extern ndarray_linalg=D:\ru
st\kalman\target\debug\deps\libndarray_linalg-837a2f143f8d01ff.rlib --extern openblas_src=D:\rust\kalman\target\debug\de
ps\libopenblas_src-98bd3a2195e9d264.rlib -L native=C:\Users\py-goku\.cargo\registry\src\github.com-1ecc6299db9ec823\wina
pi-x86_64-pc-windows-gnu-0.4.0\lib -L D:/rust/kalman/target/debug/build/openblas-src-f55a152752440e9e/out\opt/OpenBLAS/l
ib` (exit code: 1)
With stable-msvc toolchain I get:
Running `rustc --edition=2018 --crate-name kalman src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=a95edc84d22c3dfb -C extra-filename=-a95edc84d22c3dfb --out-dir D:\rust\kalman\target\debug\deps -C incremental=D:\rust\kalma
n\target\debug\incremental -L dependency=D:\rust\kalman\target\debug\deps --extern ndarray=D:\rust\kalman\target\debug\deps\libndarray-92e0395f476950e1.rlib --extern ndarray_linalg=D:\rust\kalman\target\debug\deps\libndarray_linalg-6df84c958c2578c8.rlib --extern openblas
_src=D:\rust\kalman\target\debug\deps\libopenblas_src-016fb3f34a35b405.rlib -L D:/rust/kalman/target/debug/build/openblas-src-a9fb8b5975a41b99/out\opt/OpenBLAS/lib`
warning: unused variable: `meas`
--> src\main.rs:11:9
|
11 | let meas: Array1<f64> = array![1., 0., 0., 0.];
| ^^^^ help: consider prefixing with an underscore: `_meas`
|
= note: #[warn(unused_variables)] on by default
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\rust\\kalman\\target\\debug
\\deps\\kalman-a95edc84d22c3dfb.122vu3aswteipqb1.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.13n2vnuws66j8mdj.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.18s60t46xaif3zvh.rcgu.o" "D:\\rust\\kalman\\target\\debug\\de
ps\\kalman-a95edc84d22c3dfb.1b2yvh7shw587of6.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1ei9wegjtim2kqzm.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1fcfzl6oev6xtzn2.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\
kalman-a95edc84d22c3dfb.1g4ggp65vsdblzgl.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1giie7bs78k2xt7g.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1mr47t1oyy5rsiji.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalm
an-a95edc84d22c3dfb.1ruoctt7ijlljoa6.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1uqshpy4sa4v8an5.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.1vsy0yg9o5par3rq.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a
95edc84d22c3dfb.1x6x3ihj3p13mkpl.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.267zx13kij34u4gt.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.28z5jtqzf4zk6a0a.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95ed
c84d22c3dfb.2bxn7d495r83on0.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.2cx67c2sbouecr3a.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.2lnkm8nbhamz2ufu.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d2
2c3dfb.2nkqt0oi23x4dkb2.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.2r3702bguifhe1jl.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.2wmpnjhzx5ckvomx.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3d
fb.2x9yfmm614o259ap.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.2z0546q3cydrchmp.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.316d728p18tkmmro.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3
a2ku7c0vf58tous.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3cx29zlj5pu8cuam.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3ed27cw63udeet3a.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3foqq
kqh31cmszrd.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3lqkhyitdp1nktxu.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3svekdg01vbp0bpx.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3tcg78kh8
idwv97l.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.3zv7fin0xq29c9p.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.40xcvq6efvpjc1p0.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4fhamr92tvi952
1c.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4i1nreuqah7u98m.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4onj8ou682kjo2i8.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4qy0lcg90jnqzi0c.rc
gu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4sdn6qh9f71x312t.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4sf841ra9wnj9x20.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4tj3u3whifcu6itg.rcgu.o
" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4uxpa4iussens7p4.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4v417z274elxthgp.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.4ykvifozynxio5sa.rcgu.o" "D
:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.53pnp4acasjjvyae.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.53zvmjwduisgidcn.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.56ggjxtlgj7yd2ox.rcgu.o" "D:\\r
ust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.5aikzwzau7elumzl.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.5bvixrabzl8kcjxo.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.5cglmdh2g96jcky7.rcgu.o" "D:\\rust\
\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.cc6kpbki57wosm1.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.e4ki9k9ygqbxw4r.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.ehx25eu8sfjc690.rcgu.o" "D:\\rust\\kalman
\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.esvadvlq5jzkjv.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.jhh6ixa44l796ko.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.jstaw6vryzqt12p.rcgu.o" "D:\\rust\\kalman\\target
\\debug\\deps\\kalman-a95edc84d22c3dfb.y5xv86bej16ece7.rcgu.o" "D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.ykgc0dyjx9fo2jc.rcgu.o" "/OUT:D:\\rust\\kalman\\target\\debug\\deps\\kalman-a95edc84d22c3dfb.exe" "D:\\rust\\kalman\\target\\debug\\deps\\kalman
-a95edc84d22c3dfb.4p8ztpguotmgsgor.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib
\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:D:\\rust\\kalman\\target\\debug\\deps" "/LIBPATH:D:/rust/kalman/target/debug/build/openblas-src-a9fb8b5975a41b99
/out\\opt/OpenBLAS/lib" "/LIBPATH:C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\rust\\kalman\\target\\debug\\deps\\libopenblas_src-016fb3f34a35b405.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\lib
ndarray_linalg-6df84c958c2578c8.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\librand-56bb68fe717a7c52.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libwinapi-4124b515ecc34851.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\librand_core-dd076e771b70d107.rlib" "D:\\rust\\ka
lman\\target\\debug\\deps\\librand_core-095a947572badebd.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\liblapacke-f3b07a3205e00851.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\liblapacke_sys-c47da9062b715d2a.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libndarray-92e03
95f476950e1.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libnum_complex-40b449ee04f55cb0.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libnum_traits-71b583abd7fc37da.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libitertools-96a05f8e8fe0d445.rlib" "D:\\rust\\kalman\\tar
get\\debug\\deps\\libeither-8d7f83e59ef4d65d.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libmatrixmultiply-7843eba1b0a23445.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\librawpointer-472e64f4ec8e6401.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libblas_src-a832735ffc
b26e90.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\libcblas_sys-a5e84083ce548fc0.rlib" "D:\\rust\\kalman\\target\\debug\\deps\\liblibc-017498fec30aa81b.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\
lib\\libstd-b37071b9e2cd3aa5.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-80ad24dd9399543e.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rus
tlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-dd79d3cff78d66ff.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-25039ae4abdf00f4.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stab
le-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-372f2e64ad75cbde.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-89af1159cf06a551.rlib" "C:\\Users\\py-goku\\.
rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-ab52a96521eb83dc.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-ed
3299f47397f63d.rlib" "C:\\Users\\py-goku\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-3d0709ec5c75f4fa.rlib" "gfortran.lib" "openblas.lib" "advapi32.lib" "credui.lib" "kernel32.lib" "secur32.lib" "ad
vapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
= note: LINK : fatal error LNK1181: cannot open input file 'gfortran.lib'
error: aborting due to previous error
error: Could not compile `kalman`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name kalman src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=a95edc84d22c3dfb -C extra-filename=-a95edc84d22c3dfb --out-dir D:\rust\kalman\target\debug\deps -C in
cremental=D:\rust\kalman\target\debug\incremental -L dependency=D:\rust\kalman\target\debug\deps --extern ndarray=D:\rust\kalman\target\debug\deps\libndarray-92e0395f476950e1.rlib --extern ndarray_linalg=D:\rust\kalman\target\debug\deps\libndarray_linalg-6df84c958c2578c8
.rlib --extern openblas_src=D:\rust\kalman\target\debug\deps\libopenblas_src-016fb3f34a35b405.rlib -L D:/rust/kalman/target/debug/build/openblas-src-a9fb8b5975a41b99/out\opt/OpenBLAS/lib` (exit code: 1)
Now some may be aware then when compiled from powershell, openblas-src does not compile, but these same errors persist when trying to build from MSYS2 MinGW 64bit.
I hope we can resolve this, because without ndarray-linalg the ndarray is useless for Numpy users.
Possible answers:
sudo
in Travis CIWhen I run the following code:
use ndarray::*;
use ndarray_linalg::*;
#[test]
fn inv_test() {
let a: Array2<f64> = array!([1.0, 2.0], [3.0, 4.0]);
let a_inv = a.inv().unwrap();
assert!(a_inv.all_close(&array!([-2.0, 1.0], [1.5, -0.5]), 1e-5));
}
it produces the following output (running the command cargo test --features=openblas
:
thread 'tests::inv_test' panicked at 'assertion failed: a_inv.all_close(&array!([ - 2.0 , 1.0 ] , [ 1.5 , - 0.5 ]), 1e-5)', src/main.rs:355:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The value of a_inv is vec![2, -1, -0.5, 0.5]
I would expect the value to be the same as the example using the equivalent using numpy:
>>> from numpy.linalg import inv
>>> a = np.array([[1., 2.], [3., 4.]])
>>> ainv = inv(np.matrix(a))
>>> ainv
matrix([[-2. , 1. ],
[ 1.5, -0.5]])
Encountering problems when building with ndarray-linalg as a dependency
Versions:
OSX: 10.13.4 (17E199)
clang: Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
blas and openblas installed via conda, versions are:
blas 1.0 openblas anaconda
openblas 0.3.3 3 anaconda
openblas-devel 0.3.3 3 anaconda
gfortran was installed via homebrew:
boris@Boriss-MacBook-Pro-2:~/haxx/python/gravity_clustering$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/8.2.0/libexec/gcc/x86_64-apple-darwin17.7.0/8.2.0/lto-wrapper
Target: x86_64-apple-darwin17.7.0
Configured with: ../configure --build=x86_64-apple-darwin17.7.0 --prefix=/usr/local/Cellar/gcc/8.2.0 --libdir=/usr/local/Cellar/gcc/8.2.0/lib/gcc/8 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-8 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC 8.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls
Thread model: posix
gcc version 8.2.0 (Homebrew GCC 8.2.0)
Error text is as follows:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-m64" "-L" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering0-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering1-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering10-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering11-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering12-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering13-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering14-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering15-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering2-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering3-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering4-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering5-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering6-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering7-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering8-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.gravity_clustering9-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o" "-o" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/gravity_clustering-af9a185107b464a2.crate.allocator.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/boris/haxx/python/gravity_clustering/target/release/deps" "-L" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librayon-4b02d786d1bd55a5.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librayon_core-6ad42d4bfe037261.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libcrossbeam_deque-3e4d4acc829c5c73.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libcrossbeam_epoch-ca8363f9197e111f.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libscopeguard-b6ce87978007c9eb.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libmemoffset-19ba1fa21caf0388.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/liblazy_static-f9f2f60147bdfdf0.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libcrossbeam_utils-025f80d9e0908a5b.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libcfg_if-31e57d1f0d09db98.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libarrayvec-b72cb89b05274aca.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libnodrop-a40abb48bf76c4e6.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libndarray_linalg-b74f9ca68324d40e.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/liblapacke-4b6143a9e09368de.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/liblapacke_sys-fa7f00acac0e1073.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libndarray-9ae38c327d6212ae.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libnum_complex-e1f6eb9ac6503af6.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libnum_traits-03eef3ab8946d374.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libitertools-9016f082db60a7a7.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libeither-fcfc96e5a4db8cce.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libmatrixmultiply-817168ed32bf0403.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librawpointer-d8a37321df43ac4b.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libblas_src-772e556da810a4d4.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libcblas_sys-9a2f33c41b92c395.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/libnum_cpus-eaf59e66f6f31242.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librand-800929ac40d24603.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/liblibc-3c1946dd65acb4d1.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librand_core-3b99e0cebd545167.rlib" "/Users/boris/haxx/python/gravity_clustering/target/release/deps/librand_core-d541ebf4a966e2be.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-03b901326ae24853.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-6ff7c563e703aab0.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-5bcc251fd166dc12.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-3af07b1997da2eea.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-f2d882c31340c020.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-c27b8d1b261d1a71.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a8adffd320893f05.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-095d0e0c6f534dd1.rlib" "/Users/boris/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-5bd49e510cc11ed9.rlib" "-framework" "Security" "-lSystem" "-lresolv" "-lpthread" "-lc" "-lm"
= note: Undefined symbols for architecture x86_64:
"_LAPACKE_dgesvd", referenced from:
_$LT$f64$u20$as$u20$ndarray_linalg..lapack_traits..svd..SVD_$GT$::svd::hfaf0e8598dff5bc2 in libndarray_linalg-b74f9ca68324d40e.rlib(ndarray_linalg-b74f9ca68324d40e.ndarray_linalg4-18283fb439679ae1ca7e2ec2221088bb.rs.rcgu.o)
"_cblas_ddot", referenced from:
ndarray::linalg::impl_linalg::_$LT$impl$u20$ndarray..ArrayBase$LT$S$C$$u20$ndarray..dimension..dim..Dim$LT$$u5b$usize$u3b$$u20$_$u5d$$GT$$GT$$GT$::dot::h714423fc9780e798 in gravity_clustering-af9a185107b464a2.gravity_clustering1-b7d3c0d45745af024f0794934bb8388b.rs.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Cargo.toml is:
[package]
name = "gravity_clustering"
version = "0.1.0"
authors = ["boris"]
[dependencies]
ndarray = "0.12"
ndarray-linalg = { version = "0.10", features = ["openblas"] }
#(I have tried this with "ndarray-linalg = "0.10"" as well)
rand = "0.5.5"
num_cpus = "1.8.0"
rayon = "1.0.2"
Please advise on options, so far I have solved this by creating a symlink in usr/local/bin for cc to link to G++-8, however this is terrifying and terrible, and I would like another way to solve. Issue doesn't appear to be platform dependent, as this build also fails on Ubuntu.
EDIT(by @termoshtt): Fix markdown
I recently played around with Rust for a stochastic simulation (dynamical Monte Carlo via Gillespie's algorithm). In order to increase the performance, I parallelized it via std::thread
over different initial conditions. The state space I use is a lattice in several dimensions, represented by Array1<u64>
from ndarray
. So far nothing worth mentioning.
Now I had to adapt the stochastic simulation to do some additional linear algebra along the way (nothing too crazy – just some dozen-dimensional linear problems) and decided to go for ndarray-linalg
with its recommended backend openblas
– instead of re-implementing linear algebra routines or pulling in another linear algebra package. However, this caused the parallelization via std::threads
to not work anymore: The threads were still visible in htop
, but they all stayed on the same core – not speeding up the calculation as intended. The only way I could get it to work as expected was to switch to the backend netlib
. Now my threads populate different cores again and, in this sense, I do not have a problem that needs fixing anymore.
However, it took me a long time to figure this out. I am not an expert in the different backends. Is this known and expected behavior? Is it even intended? Is my "solution" to use netlib
a true solution or is it a weird workaround, possibly causing some other problems in the future?
A simple example project reproducing the observation is given below. With openblas
it does not distribute over several cores. With netlib
instead it does. Note that the linear algebra operations in this example only appear at the very end – and just once per thread.
Cargo.toml
---
[package]
name = "example"
version = "0.1.0"
[dependencies]
rand = "0.5"
ndarray = "0.11"
# ndarray-linalg = {version = "0.9", features=["netlib"]}
ndarray-linalg = {version = "0.9", features=["openblas"]}
main.rs
---
extern crate rand;
extern crate ndarray;
extern crate ndarray_linalg;
use std::thread;
use rand::Rng;
use ndarray::{arr1, Array1};
use ndarray::{arr2, Array2};
use ndarray_linalg::Solve;
fn main() {
println!("Hello, world!");
let mut handles = vec![];
let n = 1000000000;
for idx in 0..4 {
let handle = thread::spawn(move || {
let mut rng = rand::thread_rng();
let mut x: f64 = 0.;
for _ in 0..n {
x += rng.gen::<f64>();
}
println!("Thread no {} finished averaging {} random numbers. \
Result: {}", idx, n, x/(n as f64));
let matrix: Array2<f64> = arr2(&[[1., 1., 0.],[0., 2., 0.], [0., 0., 3.]]);
let vector: Array1<f64> = arr1(&[rng.gen(), rng.gen(), rng.gen()]);
let result = matrix.solve_into(vector).unwrap();
println!("Thread no {} says: result = {}", idx, result);
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap();
}
}
To switch two features
Current test does not cover all implementations, especially for complex matrices.
https://github.com/codecov/example-rust
will be a good example :)
Hi there,
I understand that it's not exactly the aim of this package, but I'm trying to do linear algebra in the browser with a ndarray web assembly module. When I use wasm-pack build
workflow to run the factorize examples I get a number of libc related errors that aren't present in the standard system build. What's strange (or not at all) is that the rest of the ndarray crate lends itself nicely to wasm conversion.
If you have a second, could you briefly glance over these errors, and help me determine whether there's any workaround? I'd love to be able to use the developing ndarray-linalg crate to handle the transformation, and factorization needs that folks may have.
If this is way out of the scope of your tool, then feel free to pass on this issue. Thanks!
//lib.rs
extern crate cfg_if;
extern crate wasm_bindgen;
mod utils;
use cfg_if::cfg_if;
use wasm_bindgen::prelude::*;
cfg_if! {
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
if #[cfg(feature = "wee_alloc")] {
extern crate wee_alloc;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
}
}
extern crate ndarray;
extern crate ndarray_linalg;
use ndarray::*;
use ndarray_linalg::*;
// Solve `Ax=b`
fn solve() -> Result<(), error::LinalgError> {
let a: Array2<f64> = random((3, 3));
let b: Array1<f64> = random(3);
let _x = a.solve(&b)?;
println!("in solve {:?}",_x);
Ok(())
}
// Solve `Ax=b` for many b with fixed A
fn factorize() -> Result<String, error::LinalgError> {
let a: Array2<f64> = random((3, 3));
let f = a.factorize_into()?; // LU factorize A (A is consumed)
let mut ret_string = String::new();
for _ in 0..10 {
let b: Array1<f64> = random(3);
let _x = f.solve_into(b)?; // solve Ax=b using factorized L, U
ret_string += format!("in factorize {:?}",_x);
}
Ok(ret_string)
}
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn greet() -> String {
match factorize() {
Ok(st) => st,
Err(e) => format!("broke something")
}
}
//cargo.toml
[package]
name = "test-linalgwasm"
version = "0.1.0"
authors = [""]
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
cfg-if = "0.1.2"
ndarray= "0.12"
ndarray-linalg = { version = "0.10", features = ["openblas"] }
wasm-bindgen = "0.2"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.2"
[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s
build error
[1/9] Checking `rustc` version...
[2/9] Checking crate configuration...
[3/9] Adding WASM target...
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
[4/9] Compiling to WASM...
Updating crates.io index
Compiling proc-macro2 v0.4.23
Compiling unicode-xid v0.1.0
Compiling wasm-bindgen-shared v0.2.28
Compiling cfg-if v0.1.6
Compiling num-traits v0.2.6
Compiling lazy_static v1.2.0
Compiling openblas-src v0.6.1
Compiling matrixmultiply v0.1.15
Compiling num-complex v0.2.1
Compiling rawpointer v0.1.0
Compiling ndarray v0.12.0
Compiling libc v0.2.43
Compiling rand_core v0.3.0
Compiling either v1.5.0
Compiling wasm-bindgen v0.2.28
Compiling log v0.4.6
Compiling cblas-sys v0.1.4
Compiling lapacke-sys v0.1.4
error[E0432]: unresolved imports `libc::c_char`, `libc::c_double`, `libc::c_float`, `libc::c_int`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/cblas-sys-0.1.4/src/lib.rs:13:12
|
13 | use libc::{c_char, c_double, c_float, c_int};
| ^^^^^^ ^^^^^^^^ ^^^^^^^ ^^^^^ no `c_int` in the root
| | | |
| | | no `c_float` in the root
| | no `c_double` in the root
| no `c_char` in the root
error[E0412]: cannot find type `c_double` in module `libc`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/cblas-sys-0.1.4/src/lib.rs:17:36
|
17 | pub type c_double_complex = [libc::c_double; 2];
| ^^^^^^^^ not found in `libc`
error[E0412]: cannot find type `c_float` in module `libc`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/cblas-sys-0.1.4/src/lib.rs:21:35
|
21 | pub type c_float_complex = [libc::c_float; 2];
| ^^^^^^^ not found in `libc`
error: aborting due to 3 previous errors
Some errors occurred: E0412, E0432.
For more information about an error, try `rustc --explain E0412`.
error: Could not compile `cblas-sys`.
warning: build failed, waiting for other jobs to finish...
error[E0432]: unresolved imports `libc::c_char`, `libc::c_double`, `libc::c_float`, `libc::c_int`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/lapacke-sys-0.1.4/src/lib.rs:13:12
|
13 | use libc::{c_char, c_double, c_float, c_int};
| ^^^^^^ ^^^^^^^^ ^^^^^^^ ^^^^^ no `c_int` in the root
| | | |
| | | no `c_float` in the root
| | no `c_double` in the root
| no `c_char` in the root
error[E0412]: cannot find type `c_double` in module `libc`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/lapacke-sys-0.1.4/src/lib.rs:17:36
|
17 | pub type c_double_complex = [libc::c_double; 2];
| ^^^^^^^^ not found in `libc`
error[E0412]: cannot find type `c_float` in module `libc`
--> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/lapacke-sys-0.1.4/src/lib.rs:21:35
|
21 | pub type c_float_complex = [libc::c_float; 2];
| ^^^^^^^ not found in `libc`
error: aborting due to 3 previous errors
Some errors occurred: E0412, E0432.
For more information about an error, try `rustc --explain E0412`.
error: Could not compile `lapacke-sys`.
\ warning: build failed, waiting for other jobs to finish...
This will be possible without cloning Array.
I have tried running some code with the Intel MKL backend and the OpenBLAS backend, both spew out warnings like
Intel MKL ERROR: Parameter 7 was incorrect on entry to cblas_dgemv.
The only ndarray-linalg
routine I use is Solve
and I use ndarray
without the blas feature.
So far I have been unable to replicate the error with a simple example.
This sounds quite ominous, either the dimension parameter is wrong or my vector is somehow invalid (nans maybe?), but somehow my code doesn't halt. After browsing the source for a morning I haven't been able to find where this message originates or why my code doesn't panic. I'd be happy to solve the issue myself but I really need some pointers on where to start. Your help is appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.