Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c390f08
feat: add c implementation
DivitJain26 Apr 23, 2026
f0b231b
feat: add headers
DivitJain26 Apr 23, 2026
6bd70cb
docs: add c exmaple
DivitJain26 Apr 23, 2026
0f6c632
bench: add c benchmark
DivitJain26 Apr 23, 2026
b9159f7
chore: add c manifest.json
DivitJain26 Apr 23, 2026
a39cf69
fix: adds dependency in manifest.json
DivitJain26 Apr 23, 2026
65a0402
fix: fixs file name
DivitJain26 Apr 23, 2026
338de8c
fix: fixs array size
DivitJain26 Apr 23, 2026
7fd18c2
fix: fixs array size
DivitJain26 Apr 23, 2026
801f26f
fix: fixs array size
DivitJain26 Apr 23, 2026
0d522f0
fix: fixs dependency
DivitJain26 Apr 23, 2026
2f0743d
chore: remve unsed dpendencyo
DivitJain26 Apr 23, 2026
42d84a8
chore: update copy right year
DivitJain26 Apr 23, 2026
3bf074f
feat: add jas warppers for native bindings
DivitJain26 Apr 23, 2026
a3a89a3
fix: fix pointers and bounds
DivitJain26 Apr 23, 2026
6ee54af
test: add test suite for c
DivitJain26 Apr 23, 2026
a134ce5
chore: update copyright yeras
DivitJain26 Apr 23, 2026
78d0a60
bench: add js benchmark for c
DivitJain26 Apr 23, 2026
227276a
bench: update isnan
DivitJain26 Apr 23, 2026
6e19980
docs: update readme for c implementation
DivitJain26 Apr 23, 2026
e6d91d0
chore: fix exmaple
DivitJain26 Apr 23, 2026
d492160
chore: fix exmaple
DivitJain26 Apr 23, 2026
127b979
chore: fix exmaple
DivitJain26 Apr 23, 2026
45e1877
chore: fix exmaple
DivitJain26 Apr 23, 2026
166bc11
refactor: remove conditionals from hot loops
DivitJain26 Apr 23, 2026
8419b2f
refactor: variable initialized
DivitJain26 Apr 23, 2026
45fed28
chore: add header
DivitJain26 Apr 23, 2026
9d69299
chore: add header
DivitJain26 Apr 24, 2026
ea66713
chore: cahde headers
DivitJain26 Apr 24, 2026
1f33d04
bench: use dynamic memory reallocation
DivitJain26 Apr 24, 2026
abaf09b
bench: use dynamic memory reallocation
DivitJain26 Apr 24, 2026
d78f0bf
bench: use dynamic memory reallocation
DivitJain26 Apr 24, 2026
d3d560a
bench: use cfill
DivitJain26 Apr 24, 2026
e61c9d6
bench: use cfill
DivitJain26 Apr 24, 2026
d9462c1
bench: use cfill
DivitJain26 Apr 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 114 additions & 9 deletions lib/node_modules/@stdlib/blas/base/cgemv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ var y = filledarrayBy( M, 'complex64', rand );
var alpha = new Complex64( 0.5, 0.5 );
var beta = new Complex64( 0.5, -0.5 );

cgemv( 'column-major', 'no-transpose', M, N, alpha, A, 4, x, 1, beta, y, 1 );
cgemv( 'column-major', 'no-transpose', M, N, alpha, A, M, x, 1, beta, y, 1 );

// Print the results:
logEach( '%s', x );

cgemv.ndarray( 'no-transpose', M, N, alpha, A, 1, 4, 0, x, 1, 0, beta, y, 1, 0 );
cgemv.ndarray( 'no-transpose', M, N, alpha, A, 1, M, 0, x, 1, 0, beta, y, 1, 0 );

// Print the results:
logEach( '%s', x );
Expand Down Expand Up @@ -242,21 +242,86 @@ logEach( '%s', x );
### Usage

```c
TODO
#include "stdlib/blas/base/cgemv.h"
```

#### TODO
<!-- lint disable maximum-heading-length -->

#### c_cgemv( layout, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY )

TODO.
Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` or `y = α*A^H*x + β*y` where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.

```c
TODO
#include "stdlib/blas/base/shared.h"
#include "stdlib/complex/float32/ctor.h"

const float A[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f };
const float x[] = { 1.0f, 1.0f, 2.0f, 2.0f };
float y[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f };
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );

c_cgemv( CblasColMajor, CblasNoTrans, 4, 2, alpha, (void *)A, 4, (void *)x, 1, beta, (void *)y, 1 );
```

TODO
The function accepts the following arguments:

- **layout**: `[in] CBLAS_LAYOUT` storage layout.
- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`.
- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`.
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
- **A**: `[in] void*` input matrix.
- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
- **X**: `[in] void*` first input vector.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **beta**: `[in] stdlib_complex64_t` scalar constant.
- **Y**: `[inout] void*` second input vector.
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.

```c
TODO
void c_cgemv( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t alpha, const void *A, const CBLAS_INT LDA, const void *X, const CBLAS_INT strideX, const stdlib_complex64_t beta, void *Y, const CBLAS_INT strideY )
```

<!-- lint disable maximum-heading-length -->

#### c_cgemv_ndarray( trans, M, N, alpha, \*A, sa1, sa2, oa, \*X, sx, ox, beta, \*Y, sy, oy )

Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` or `y = α*A^H*x + β*y`, using indexing alternative semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix.

```c
#include "stdlib/blas/base/shared.h"
#include "stdlib/complex/float32/ctor.h"

const float A[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f };
const float x[] = { 1.0f, 1.0f, 2.0f, 2.0f };
float y[] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f };
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );

c_cgemv( CblasNoTrans, 4, 2, alpha, (void *)A, 1, 4, (void *)x, 1, 0, beta, (void *)y, 1, 0 );
```

The function accepts the following arguments:

- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`.
- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`.
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
- **A**: `[in] void*` input matrix.
- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`.
- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`.
- **oa**: `[in] CBLAS_INT` starting index for `A`.
- **X**: `[in] void*` first input vector.
- **sx**: `[in] CBLAS_INT` stride length for `X`.
- **ox**: `[in] CBLAS_INT` starting index for `X`.
- **beta**: `[in] stdlib_complex64_t` scalar constant.
- **Y**: `[inout] void*` second input vector.
- **sy**: `[in] CBLAS_INT` stride length for `Y`.
- **oy**: `[in] CBLAS_INT` starting index for `Y`.

```c
void c_cgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex64_t alpha, const void *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex64_t beta, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY )
```

</section>
Expand All @@ -278,7 +343,47 @@ TODO
### Examples

```c
TODO
#include "stdlib/blas/base/cgemv.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/complex/float32/ctor.h"
#include <stdio.h>

int main( void ) {
// Define a 3x3 matrix stored in row-major order:
const float A[ 3*3*2 ] = {
1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f,
4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f,
7.0f, 7.0f, 8.0f, 8.0f, 9.0f, 9.0f
};

// Define `x` and `y` vectors:
const float x[ 3*2 ] = { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f };
float y[ 3*2 ] = { 3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f };

// Create complex scalars:
const stdlib_complex64_t alpha = stdlib_complex64( 0.5f, 0.5f );
const stdlib_complex64_t beta = stdlib_complex64( 0.5f, -0.5f );

// Specify the number of elements along each dimension of `A`:
const int M = 3;
const int N = 3;

// Perform the matrix-vector operation `y = α*A*x + β*y`:
c_cgemv( CblasRowMajor, CblasNoTrans, M, N, alpha, (void *)A, M, (void *)x, 1, beta, (void *)y, 1 );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
}

// Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics:
c_cgemv_ndarray( CblasNoTrans, M, N, alpha, (void *)A, N, 1, 0, (void *)x, 1, 0, beta, (void *)y, 1, 0 );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "y[ %i ] = %f + %fj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
}
}
```

</section>
Expand Down
129 changes: 129 additions & 0 deletions lib/node_modules/@stdlib/blas/base/cgemv/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pow = require( '@stdlib/math/base/special/pow' );
var floor = require( '@stdlib/math/base/special/floor' );
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var format = require( '@stdlib/string/format' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var cgemv = tryRequire( resolve( __dirname, './../lib/cgemv.native.js' ) );
var opts = {
'skip': ( cgemv instanceof Error )
};
var options = {
'dtype': 'float32'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} N - array dimension size
* @returns {Function} benchmark function
*/
function createBenchmark( N ) {
var alpha;
var beta;
var xbuf;
var ybuf;
var Abuf;
var x;
var y;
var A;

xbuf = uniform( N*2, -100.0, 100.0, options );
x = new Complex64Array( xbuf.buffer );
ybuf = uniform( N*2, -100.0, 100.0, options );
y = new Complex64Array( ybuf.buffer );
Abuf = uniform( (N*N)*2, -100.0, 100.0, options );
A = new Complex64Array( Abuf.buffer );

alpha = new Complex64( 0.5, 0.5 );
beta = new Complex64( 0.5, -0.5 );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var i;
var z;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = cgemv( 'row-major', 'no-transpose', N, N, alpha, A, N, x, 1, beta, y, 1 );
if ( isnanf( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var min;
var max;
var N;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
f = createBenchmark( N );
bench( format( '%s::native:size=%d', pkg, N*N ), opts, f );
}
}

main();
Loading
Loading