Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

getting no method named `svd` found for reference `&ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>`

Đang mở
#289 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
data

Hướng nghiên cứu

Start by comparing the issue's Cargo.toml dependency configuration with ndarray-linalg's Cargo.toml and the repository's SVD tests. Run the reported example and the mentioned cargo test --features=openblas svd command; done means the SVD method is available for the shown ndarray type under the documented dependency setup.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Not sure if this is the write place to ask such questions but I couldn't find anywhere else more specific. I am trying to implement the (Moore-Penrose) pseudo-inverse of a matrix[1]. My code currently looks like

use ndarray::prelude::*;
use ndarray_linalg::*;
use std::cmp::min;
use thiserror::Error;

#[non_exhaustive]
#[derive(Error, Debug)]
pub enum Error {
    #[error("svd failed")]
    SvdFailed,
}

pub fn pinv(a: &Array2<f64>) -> Result<Array2<f64>, Error> {
    //a.conjugate()
    let (n, m) = a.dim();
    let result: (Option<Array1<f64>>, Array1<f64>, Option<Array1<f64>>) =
        a.svd(true, true).map_err(Error::SvdFailed)?;

I am running into issues getting

error[E0599]: no method named `svd` found for reference `&ArrayBase<OwnedRepr<T>, Dim<[usize; 2]>>` in the current scope
  --> numrs/src/linalg.rs:16:43
   |
16 |     let (u, s, vt): (_, Array1<_>, _) = a.svd(true, true).unwrap();
   |                                           ^^^ help: there is an associated function with a similar name: `std`

the dependencies part of my Cargo.toml file is the same versions as the ndarray-linalg crate on github[2]

[dependencies]
num-complex = "0.4.0"
num-traits  = "0.2.14"
rand = "0.8.3"
thiserror = "1.0.24"

[dependencies.ndarray]
version = "0.15.1"
features = ["blas", "approx", "std"]
default-features = false

#ndarray-linalg = { version = "0.13.1", features = ["openblas-static"] }
[dependencies.ndarray-linalg]
github = "https://github.com/rust-ndarray/ndarray-linalg/ndarray-linalg"
version = "0.13.1"
features = ["openblas-static"]

[dependencies.lax]
version = "0.1.0"
github = "https://github.com/rust-ndarray/ndarray-linalg/lax"
default-features = false

Any idea's what is going on here. I downloaded the ndarray-linalg source from github and the test run fine with

$ cargo test --features=openblas svd
  1. https://github.com/numpy/numpy/blob/v1.20.0/numpy/linalg/linalg.py#L1915-L2011
  2. https://github.com/rust-ndarray/ndarray-linalg/blob/master/ndarray-linalg/Cargo.toml
Ngôn ngữ chính
Rust
Star
452
Fork
95
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-ndarray/ndarray-linalg

Tất cả issue của rust-ndarray/ndarray-linalg

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.