Skip to content

[RFC]: add blas/ext/base/gtriu #13550

Description

@kgryte

Description

This RFC proposes an API to copy the upper triangular part of a matrix A to another matrix B.

API signatures:

gtriu( order, M, N, k, A, LDA, B, LDB )
gtriu.ndarray( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB )

The implementation will be similar to lapack/base/dlacpy.

See

function copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) {
where we copy all of the upper triangular part of A to B.

In this implementation, however, we will support a k parameter, which, similar to the Array API, specifies a diagonal below which to ignore.

  • k = 0 is the main diagonal.
  • k < 0 is a diagonal below the main diagonal.
  • k > 0 is a diagonal above the main diagonal.

where the main diagonal is defined as the set of indices {(i,i)} for i on the interval [0, min(M,N)-1].

Hence, if k < 0, the functions will copy the upper triangle and one or more sub-diagonals below the main diagonal (i.e., part of the lower triangle). If k > 0, the functions will copy only part of the upper triangle.

As a consequence, the loops in

function copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) {
cannot be used exactly, but can be used as a starting point. More specifically, the initial conditions for i1 and i0 will need to be updated according to the resolved diagonal.

And similar to dlacpy, we should copy in cache optional order (i.e., row-by-row for row-major and column-by-column for column-major).

Related Issues

None.

Questions

No.

Other

No.

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.

Metadata

Metadata

Assignees

Labels

AcceptedRFC feature request which has been accepted.BLASIssue or pull request related to Basic Linear Algebra Subprograms (BLAS).FeatureIssue or pull request for adding a new feature.MaintainersIssue which should be handled by project maintainers & is not recommended for external contributors.difficulty: 2May require some initial design or R&D, but should be straightforward to resolve and/or implement.priority: HighHigh priority concern or feature request.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions