Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#289 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust
Área
data

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Rust
Estrellas
452
Forks
95
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-ndarray/ndarray-linalg

Todos los issues de rust-ndarray/ndarray-linalg

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.