Skip to content

Commit 229c7bc

Browse files
authored
chore: minor clean-up
Signed-off-by: Shabareesh Shetty <[email protected]>
1 parent ff513b9 commit 229c7bc

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_cblas.c

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "stdlib/ndarray/base/min_view_buffer_index.h"
2424

2525
/**
26-
* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix.
26+
* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
2727
*
2828
* @param order storage layout
2929
* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed
@@ -32,13 +32,58 @@
3232
* @param alpha scalar constant
3333
* @param A input matrix
3434
* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
35-
* @param X first input vector
36-
* @param strideX `X` stride length
35+
* @param x first input vector
36+
* @param strideX `x` stride length
3737
* @param beta scalar constant
38-
* @param Y second input vector
39-
* @param strideY `Y` stride length
38+
* @param y second input vector
39+
* @param strideY `y` stride length
4040
* @return output value
4141
*/
42-
double API_SUFFIX(c_dgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, const double beta, const double *Y, const CBLAS_INT strideY ) {
43-
return API_SUFFIX(cblas_dgemv)( order, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY );
42+
double API_SUFFIX(c_dgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *x, const CBLAS_INT strideX, const double beta, const double *y, const CBLAS_INT strideY ) {
43+
CBLAS_INT sx = strideX;
44+
CBLAS_INT sy = strideY;
45+
if ( sx < 0 ) {
46+
sx = -sx;
47+
}
48+
if ( sy < 0 ) {
49+
sy = -sy;
50+
}
51+
return API_SUFFIX(cblas_dgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy );
52+
}
53+
54+
/**
55+
* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.
56+
*
57+
* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed
58+
* @param M number of rows in the matrix `A`
59+
* @param N number of columns in the matrix `A`
60+
* @param alpha scalar constant
61+
* @param A input matrix
62+
* @param strideA1 stride of the first dimension of `A`
63+
* @param strideA1 stride of the second dimension of `A`
64+
* @param offsetA starting index for `A`
65+
* @param x first input vector
66+
* @param strideX `x` stride length
67+
* @param offsetX starting index for `x`
68+
* @param beta scalar constant
69+
* @param y second input vector
70+
* @param strideY `y` stride length
71+
* @param offsetY starting index for `Y`
72+
* @return output value
73+
*/
74+
double API_SUFFIX(c_dgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double beta, const double *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
75+
CBLAS_INT sx = strideX;
76+
CBLAS_INT sy = strideY;
77+
if ( sx < 0 ) {
78+
sx = -sx;
79+
}
80+
if ( sy < 0 ) {
81+
sy = -sy;
82+
}
83+
x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
84+
y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
85+
const int64_t shape[] = { M, N };
86+
const int64_t strides[] = { strideA1, strideA2 };
87+
A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer
88+
return API_SUFFIX(cblas_dgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy );
4489
}

0 commit comments

Comments
 (0)