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

未关闭
#10,863 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

  • #10865 来自 @DivitJain26 —— 已关闭,未合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript
领域
data

调研方向

从 @stdlib/array/base/banded/to-compact 入口点以及 issue 中提到的 blas/base/cgbmv 实现开始。将它们的 colexicographic 存储约定与链接的 BLAS 文档进行比较,然后检查相关 issue 和包测试。当明确决定预期的按列布局,并且观察到的输出与该决定一致时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
JavaScript
星标
6k
派生
1.3k
平均合并
1 天 21 小时
30 天内合并 PR
224

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stdlib-js/stdlib 的其他 Issue

查看 stdlib-js/stdlib 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。