Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add RQ decomposition

Aperta
#398 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
452
Fork
95
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-ndarray/ndarray-linalg

Tutte le issue di rust-ndarray/ndarray-linalg

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.