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

Add RQ decomposition

Abierto
#398 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust
Área
data

Línea de trabajo

Start with the existing qr API and its LAPACK bindings, then investigate how gerqf applies to row-major arrays and what the equivalent is for column-major storage. Done means a built-in RQ decomposition API handles the relevant array layouts and returns the R and Q factors described in the issue.

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

Descripción

Hello, and thanks for the great library. I would like to request the addition of RQ decomposition. Although it's fairly trivial to implement RQ in terms of QR (link), it still took me quite some time to figure this out even with AI help (which used extra unnecessary flips).

One thing that made this challenging for me was that qr does not accept arrays with negative strides, so any slice had to then be copied into another backing array. This is ultimately what I ended up with:

use ndarray::Data;
use ndarray::prelude::*;
use ndarray_linalg::error::Result;
use ndarray_linalg::{Lapack, QRInto, Scalar};

pub trait RQ {
    type R;
    type Q;
    fn rq(&self) -> Result<(Self::R, Self::Q)>;
}

impl<A, S> RQ for ArrayBase<S, Ix2>
where
    A: Scalar + Lapack,
    S: Data<Elem = A>,
{
    type R = Array2<A>;
    type Q = Array2<A>;

    fn rq(&self) -> Result<(Self::R, Self::Q)> {
        let a = Array::from_shape_vec(
            self.raw_dim(),
            self.slice(s![..;-1,..]).t().iter().cloned().collect(),
        )?;

        let (q, r) = a.qr_into()?;

        let q = Array::from_shape_vec(
            q.raw_dim(),
            q.t().slice(s![..;-1,..]).iter().cloned().collect(),
        )?;
        let r = Array::from_shape_vec(
            r.raw_dim(),
            r.t().slice(s![..;-1,..;-1]).iter().cloned().collect(),
        )?;
        Ok((r, q))
    }
}

A built-in RQ would ideally use gerqf for row major arrays. Not sure what the equivalent would be for column major.

Lenguaje dominante
Rust
Estrellas
452
Forks
95
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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.