[RFC]: mismatch between BLAS band storage and `to-compact` layout

Aperta
#10,863 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #10865 di @DivitJain26 — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
data

Direzione di ricerca

Inizia dal punto di ingresso @stdlib/array/base/banded/to-compact e dall’implementazione blas/base/cgbmv menzionata nell’issue. Confronta le relative convenzioni di memorizzazione colexicografica con la documentazione BLAS collegata, quindi esamina le issue correlate e i test del package. Il lavoro è completato quando il layout previsto per colonne è stato deciso esplicitamente e l’output osservato concorda con tale decisione.

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

Descrizione

Description

Description

While implementing blas/base/cgbmv, I noticed that the band matrix storage format expected by BLAS gbmv differs from the layout produced by @stdlib/array/base/banded/to-compact.

to-compact produces a diagonal-centered layout, whereas BLAS expects a band storage layout compatible with the gbmv routines (as documented in (Intel® oneAPI Math Kernel Library).

Because of this difference, to-compact cannot be directly used for preparing matrices for gbmv.

This behaviour is only present in colexicographic or column wise packing.

For example, given:
var A = [
  [  1,  2,  3,  0,  0 ],
  [ -2,  4,  5,  6,  0 ],
  [ -3, -5,  7,  8,  9 ],
  [  0, -6, -8, 10, 11 ],
  [  0,  0, -9,-11, 12 ]
];
Output from to-compact
Column wise (colexicographic) packing
AC = toCompact( A, 2, 2, true );
/* e.g., returns =>
    [
        [ 0,  0,  1,  -2, -3 ],
        [ 0,  2,  4,  -5, -6 ],
        [ 3,  5,  7,  -8, -9 ],
        [ 6,  8, 10, -11,  0 ],
        [ 9, 11, 12,   0,  0 ]
    ]
*/
Expected BLAS band storage (MKL / Netlib)

BLAS gbmv expects band matrices packed differently.

Band Matrix
A general band matrix A of m rows and n columns with kl sub-diagonals, ku super-diagonals and leading dimension lda is represented as a one dimensional array a of size at least lda * n (respectively, lda * m) if column (respectively, row) major layout is used.
Before entry in any BLAS function using a general band matrix, the leading (kl + ku + 1) by n (respectively, m) part of the array a must contain the matrix A. This matrix must be supplied column-by-column (respectively, row-by-row), with the main diagonal of the matrix in row ku (respectively, column kl) of the array (0-based indexing), the first super-diagonal starting at position 1 (respectively, 0) in row (ku – 1) (respectively, column (kl + 1)), the first sub-diagonal starting at position 0 (respectively, 1) in row (ku + 1) (respectively, column (kl – 1)), and so on. Elements in the array a that do not correspond to elements in the band matrix (such as the top left ku-by-ku triangle) are not referenced.

Acompact = [
  [  0,   0,  1,  2, 3 ],
  [  0,  -2,  4,  5, 6 ],
  [ -3,  -5,  7,  8, 9 ],
  [ -6,  -8, 10, 11, 0 ],
  [ -9, -11, 12,  0, 0 ]
]
Related Issues

Related issues # , # , and # .

Questions

No.

Demo

No response

Reproduction
var toCompact = require('@stdlib/array/base/banded/to-compact');

var A = [
  [  1,  2,  3,  0,  0 ],
  [ -2,  4,  5,  6,  0 ],
  [ -3, -5,  7,  8,  9 ],
  [  0, -6, -8, 10, 11 ],
  [  0,  0, -9,-11, 12 ]
];

var AC = toCompact( A, 2, 2, true );

console.log( AC );
Expected Results
[
  [  0,   0,  1,  2, 3 ],
  [  0,  -2,  4,  5, 6 ],
  [ -3,  -5,  7,  8, 9 ],
  [ -6,  -8, 10, 11, 0 ],
  [ -9, -11, 12,  0, 0 ]
]
Actual Results
[
  [ 0,  0,  1,  -2, -3 ],
  [ 0,  2,  4,  -5, -6 ],
  [ 3,  5,  7,  -8, -9 ],
  [ 6,  8, 10, -11,  0 ],
  [ 9, 11, 12,   0,  0 ]
]
Version

No response

Environments

Node.js

Browser Version

No response

Node.js / npm Version

20.20.0

Platform

Linux

Checklist
  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
Lingua principale
JavaScript
Stelle
6k
Fork
1.3k
Merge medio
1g 21h
PR unite (30g)
224

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 stdlib-js/stdlib

Tutte le issue di stdlib-js/stdlib

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.