Skip to content

Commit 19362c1

Browse files
committed
chore: add checks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 57bf0f7 commit 19362c1

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@
3535
* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
3636
*/
3737
void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) {
38+
CBLAS_INT vala;
3839
CBLAS_INT sa1;
3940
CBLAS_INT sa2;
4041
CBLAS_INT ox;
4142
CBLAS_INT oy;
4243

44+
// Perform input argument validation...
45+
if ( order != CblasRowMajor && order != CblasColMajor ) {
46+
c_xerbla( 1, "c_dsyr2", "Error: invalid argument. First argument must be a valid order. Value: `%d`.", order );
47+
return;
48+
}
49+
if ( uplo != CblasLower && uplo != CblasUpper ) {
50+
c_xerbla( 2, "c_dsyr2", "Error: invalid argument. Second argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo );
51+
return;
52+
}
53+
if ( N < 0 ) {
54+
c_xerbla( 3, "c_dsyr2", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N );
55+
return;
56+
}
57+
if ( strideX == 0 ) {
58+
c_xerbla( 6, "c_dsyr2", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX );
59+
return;
60+
}
61+
if ( strideY == 0 ) {
62+
c_xerbla( 8, "c_dsyr2", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideX );
63+
return;
64+
}
65+
if ( LDA < N ) {
66+
c_xerbla( 10, "c_dsyr2", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", N, LDA );
67+
return;
68+
}
69+
// Check whether we can avoid computation altogether...
4370
if ( N == 0 || alpha == 0.0 ) {
4471
return;
4572
}

lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* @param offsetA starting index of `A`
3939
*/
4040
void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) {
41+
int64_t sa[ 2 ];
4142
CBLAS_INT isrm;
4243
CBLAS_INT ix0;
4344
CBLAS_INT ix1;
@@ -53,11 +54,33 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons
5354
double tmp1;
5455
double tmp2;
5556

56-
int64_t strides[] = { strideA1, strideA2 };
57+
// Note on variable naming convention: S#, ix#, iy#, i# where # corresponds to the loop number, with `0` being the innermost loop...
58+
59+
// Perform input argument validation...
60+
if ( uplo != CblasLower && uplo != CblasUpper ) {
61+
c_xerbla( 1, "c_dsyr2_ndarray", "Error: invalid argument. First argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo );
62+
return;
63+
}
64+
if ( N < 0 ) {
65+
c_xerbla( 2, "c_dsyr2_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N );
66+
return;
67+
}
68+
if ( strideX == 0 ) {
69+
c_xerbla( 5, "c_dsyr2_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX );
70+
return;
71+
}
72+
if ( strideY == 0 ) {
73+
c_xerbla( 8, "c_dsyr2_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY );
74+
return;
75+
}
76+
// Check whether we can avoid computation altogether...
5777
if ( N == 0 || alpha == 0.0 ) {
5878
return;
5979
}
60-
isrm = stdlib_ndarray_is_row_major( 2, strides );
80+
// Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments...
81+
sa[ 0 ] = strideA1;
82+
sa[ 1 ] = strideA2;
83+
isrm = stdlib_ndarray_is_row_major( 2, sa );
6184
if ( isrm ) {
6285
// For row-major matrices, the last dimension has the fastest changing index...
6386
sa0 = strideA2; // stride for innermost loop

0 commit comments

Comments
 (0)