Pivoted Cholesky
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start by reading the existing ndarray_linalg::cholesky entry points, especially factorizec and CholeskyFactorized, then compare their behavior with LAPACK's dpstrf example. Define how the factor, pivot, and rank should be returned and how a truncated factor could initialize CholeskyFactorized; done means the pivoted PSD case and the reduced-system reuse path are specified and tested.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Currently, Cholesky will fail on PSD but not PD matrices, because it calls ?pptrf.
use ndarray::{array, Array, Axis};
use ndarray_linalg::cholesky::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let x1 = array![1., 2., 3., 4., 7.];
let x2 = array![-1., 2., 3., 5., 8.];
let x3 = array![1., -2., 3., 6., 9.];
let x4 = &x1 * 1. + &x2 * 2. - &x3 * 3.;
let xs = [x1, x2, x3, x4];
let xs = xs
.iter()
.map(|x| x.view().insert_axis(Axis(1)))
.collect::<Vec<_>>();
let X = ndarray::stack(Axis(1), &xs)?;
println!("{:?}", X);
let XTX = X.t().dot(&X);
println!("{:?}", XTX);
let chol = XTX.factorizec(UPLO::Lower)?; // Error: Lapack { return_code: 4 }
Ok(())
}
However, if we allow pivoting, then we can return a cholesky factor U, pivot matrix P such that P U^T U P^T = A for an input matrix A that's merely PSD (this also returns the rank r).
It would be nice if ndarray-linalg could also provide this pivoted version, e.g., as shown here in python:
from scipy.linalg.lapack import dpstrf
import numpy as np
xt = np.array([
[1, 2, 3, 4, 7],
[-1, 2, 3, 5, 8],
[1, -2, 3, 6, 9]]).astype(float)
x = np.insert(xt, len(xt), xt[0] + 2 * xt[1] - 3 * xt[2], axis=0).T
xtx = x.T.dot(x)
U, P, rank, info = dpstrf(xtx)
assert info > 0
assert rank == 3
P -= 1
U = np.triu(U)
invP = np.empty_like(P)
invP[P] = np.arange(len(P), dtype=int)
print(np.linalg.norm(U.T.dot(U)[np.ix_(invP, invP)] - xtx, ord='fro')) # row indexing inverts permutations
# 3.552713678800501e-14
An interesting design question would be what the interface should be. Clearly this routine should return the factor, pivot, and rank in some form. But it'd be nice if I could take my pivoted Cholesky output, truncate U to its leading principal minor of order r, and initialize a CholeskyFactorized struct directly, so that I can just re-use existing methods for solving the reduced subsystem.
- 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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-ndarray/ndarray-linalg
-
Thin SVD Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
rust-ndarray/ndarray-linalg#414 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
rust-ndarray/ndarray-linalg#413 · 1 comentario ·
-
Cyclically Tridiagonal Matrices? Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
rust-ndarray/ndarray-linalg#404 ·
-
SIGSEGV on qr decomposition Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
rust-ndarray/ndarray-linalg#402 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
rust-ndarray/ndarray-linalg#401 · 2 reacciones ·
Todos los issues de rust-ndarray/ndarray-linalg
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
TheLarkInn/aipm#2413 ·
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
alexgorbatchev/simple-ptt#15 ·
-
tooling
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
todo:ticket
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
taikoxyz/taiko-mono#22168 · 1 comentario ·