diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/Makefile b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/Makefile new file mode 100644 index 000000000000..cf0e1c097dbc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/Makefile @@ -0,0 +1,141 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling Fortran source files: +ifdef FORTRAN_COMPILER + FC := $(FORTRAN_COMPILER) +else + FC := gfortran +endif + +# Define the command-line options when compiling Fortran files: +FFLAGS ?= \ + -std=f95 \ + -ffree-form \ + -O3 \ + -Wall \ + -Wextra \ + -Wno-compare-reals \ + -Wimplicit-interface \ + -fno-underscoring \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop`): +INCLUDE ?= + +# List of Fortran source files: +SOURCE_FILES ?= ../../src/caxpy.f + +# List of Fortran targets: +f_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles Fortran source files. +# +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [FORTRAN_COMPILER] - Fortran compiler +# @param {string} [FFLAGS] - Fortran compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(f_targets) + +.PHONY: all + +#/ +# Compiles Fortran source files. +# +# @private +# @param {string} SOURCE_FILES - list of Fortran source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} FC - Fortran compiler +# @param {string} FFLAGS - Fortran compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(f_targets): %.out: %.f + $(QUIET) $(FC) $(FFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(f_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/benchmark.length.f b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/benchmark.length.f new file mode 100644 index 000000000000..a695d1b99dc7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/fortran/benchmark.length.f @@ -0,0 +1,155 @@ +!> +! @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. +!< + +program bench + implicit none + ! .. + ! Local constants: + character(5), parameter :: name = 'caxpy' + integer, parameter :: iterations = 10000000 + integer, parameter :: repeats = 3 + integer, parameter :: min = 1 + integer, parameter :: max = 6 + ! .. + call main() +contains + + subroutine print_version() + print '(A)', 'TAP version 13' + end subroutine print_version + + subroutine print_summary( total, passing ) + integer, intent(in) :: total, passing + character(len=999) :: str, tmp + intrinsic adjustl, trim + + print '(A)', '#' + write (str, '(I15)') total + tmp = adjustl( str ) + print '(A,A)', '1..', trim( tmp ) + print '(A,A)', '# total ', trim( tmp ) + write (str, '(I15)') passing + tmp = adjustl( str ) + print '(A,A)', '# pass ', trim( tmp ) + print '(A)', '#' + print '(A)', '# ok' + end subroutine print_summary + + subroutine print_results( iterations, elapsed ) + integer, intent(in) :: iterations + double precision, intent(in) :: elapsed + double precision :: rate + character(len=999) :: str, tmp + intrinsic dble, adjustl, trim + + rate = dble( iterations ) / elapsed + print '(A)', ' ---' + write (str, '(I15)') iterations + tmp = adjustl( str ) + print '(A,A)', ' iterations: ', trim( tmp ) + write (str, '(f100.9)') elapsed + tmp = adjustl( str ) + print '(A,A)', ' elapsed: ', trim( tmp ) + write (str, '(f100.9)') rate + tmp = adjustl( str ) + print '(A,A)', ' rate: ', trim( tmp ) + print '(A)', ' ...' + end subroutine print_results + + double precision function benchmark( iterations, len ) + interface + subroutine caxpy( N, alpha, x, strideX, y, strideY ) + integer :: N, strideX, strideY + complex :: alpha + complex :: x(*), y(*) + end subroutine caxpy + end interface + + integer, intent(in) :: iterations, len + double precision :: elapsed + real :: t1, t2 + double precision :: r1, r2 + integer :: i + complex :: alpha + complex, allocatable :: x(:), y(:) + intrinsic random_number, cpu_time, cmplx + + allocate( x(len), y(len) ) + + ! Initialize alpha + call random_number( r1 ) + call random_number( r2 ) + alpha = cmplx( real(r1)*10.0, real(r2)*10.0 ) + + ! Initialize vectors + do i = 1, len + call random_number( r1 ) + call random_number( r2 ) + x( i ) = cmplx( real(r1)*1000.0, real(r2)*1000.0 ) + + call random_number( r1 ) + call random_number( r2 ) + y( i ) = cmplx( real(r1)*1000.0, real(r2)*1000.0 ) + end do + + call cpu_time( t1 ) + + do i = 1, iterations + call caxpy( len, alpha, x, 1, y, 1 ) + if ( y(1) /= y(1) ) then + print '(A)', 'should not return NaN' + exit + end if + end do + + call cpu_time( t2 ) + elapsed = t2 - t1 + + deallocate( x, y ) + benchmark = elapsed + end function benchmark + + subroutine main() + integer :: count, iter, len, i, j + double precision :: elapsed + character(len=999) :: str, tmp + intrinsic adjustl, trim + + call print_version() + count = 0 + + do i = min, max + len = 10**i + iter = iterations / 10**(i-1) + do j = 1, repeats + count = count + 1 + write (str, '(I15)') len + tmp = adjustl( str ) + print '(A,A,A,A)', '# fortran::', name, ':len=', trim( tmp ) + elapsed = benchmark( iter, len ) + call print_results( iter, elapsed ) + write (str, '(I15)') count + tmp = adjustl( str ) + print '(A,A,A)', 'ok ', trim( tmp ), ' benchmark finished' + end do + end do + + call print_summary( count, count ) + end subroutine main + +end program bench diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/binding.gyp b/lib/node_modules/@stdlib/blas/base/caxpy/binding.gyp index 02a2799da097..60dce9d0b31a 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/binding.gyp +++ b/lib/node_modules/@stdlib/blas/base/caxpy/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/include.gypi b/lib/node_modules/@stdlib/blas/base/caxpy/include.gypi index 497aeca15320..dcb556d250e8 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/caxpy/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/include/stdlib/blas/base/caxpy_fortran.h b/lib/node_modules/@stdlib/blas/base/caxpy/include/stdlib/blas/base/caxpy_fortran.h new file mode 100644 index 000000000000..4b4f36fe4dc8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/caxpy/include/stdlib/blas/base/caxpy_fortran.h @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +/** +* Header file containing function declarations for the Fortran interface to the BLAS Level 1 routine `caxpy`. +*/ +#ifndef STDLIB_BLAS_BASE_CAXPY_FORTRAN_H +#define STDLIB_BLAS_BASE_CAXPY_FORTRAN_H + +#include "stdlib/complex/float32/ctor.h" + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C/Fortran compiler (a Fortran compiler must be configured to not attach underscores). +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Scales a single-precision complex floating-point vector by a single-precision complex floating-point constant and adds the result to a single-precision complex floating-point vector. +*/ +void caxpy( const CBLAS_INT *, const stdlib_complex64_t *, const void *, const CBLAS_INT *, void *, const CBLAS_INT * ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_BLAS_BASE_CCOPY_FORTRAN_H diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/manifest.json b/lib/node_modules/@stdlib/blas/base/caxpy/manifest.json index 440871cf3483..f9babf5684f7 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/caxpy/manifest.json @@ -34,8 +34,8 @@ "blas": "", "wasm": false, "src": [ - "./src/caxpy.c", - "./src/caxpy_ndarray.c" + "./src/caxpy.f", + "./src/caxpy_f.c" ], "include": [ "./include" @@ -44,16 +44,13 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", - "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex64array", "@stdlib/napi/argv-complex64", "@stdlib/complex/float32/ctor", - "@stdlib/complex/float32/base/add", - "@stdlib/complex/float32/base/mul" + "@stdlib/strided/base/min-view-buffer-index" ] }, { @@ -181,8 +178,8 @@ "blas": "", "wasm": false, "src": [ - "./src/caxpy.c", - "./src/caxpy_ndarray.c" + "./src/caxpy.f", + "./src/caxpy_f.c" ], "include": [ "./include" @@ -191,16 +188,13 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/base/scabs1", - "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-complex64array", "@stdlib/napi/argv-complex64", "@stdlib/complex/float32/ctor", - "@stdlib/complex/float32/base/add", - "@stdlib/complex/float32/base/mul" + "@stdlib/strided/base/min-view-buffer-index" ] }, { diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/src/Makefile b/lib/node_modules/@stdlib/blas/base/caxpy/src/Makefile index bcf18aa46655..2caf905cedbe 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/caxpy/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy.f b/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy.f new file mode 100644 index 000000000000..5d82848d3555 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy.f @@ -0,0 +1,99 @@ +!> +! @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. +!< + +!> Computes a constant times a vector plus a vector (single-precision complex floating-point). +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.9.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Jack Dongarra, linpack, 3/11/78. +! +! - modified 12/3/93, array(1) declarations changed to array(*) +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} N - number of indexed elements +! @param {complex} alpha - scalar constant +! @param {Array} x - input array +! @param {integer} strideX - `x` stride length +! @param {Array} y - output array +! @param {integer} strideY - `y` stride length +!< +subroutine caxpy( N, alpha, x, strideX, y, strideY ) + implicit none + ! .. + ! Scalar arguments: + complex :: alpha + integer :: strideX, strideY, N + ! .. + ! Array arguments: + complex :: x(*), y(*) + ! .. + ! Local scalars: + integer :: ix, iy, i + ! .. + if ( N <= 0 ) then + return + end if + if ( real(alpha) == 0.0e0 .AND. aimag(alpha) == 0.0e0 ) then + return + end if + ! .. + if ( strideX == 1 .AND. strideY == 1 ) then + do i = 1, N + y(i) = y(i) + alpha * x(i) + end do + else + if ( strideX < 0 ) then + ix = ( -N + 1 ) * strideX + 1 + else + ix = 1 + end if + if ( strideY < 0 ) then + iy = ( -N + 1 ) * strideY + 1 + else + iy = 1 + end if + do i = 1, N + y(iy) = y(iy) + alpha * x(ix) + ix = ix + strideX + iy = iy + strideY + end do + end if + return +end subroutine caxpy diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy_f.c b/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy_f.c new file mode 100644 index 000000000000..f08035a8556d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/caxpy/src/caxpy_f.c @@ -0,0 +1,60 @@ +/** +* @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. +*/ + +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/caxpy.h" +#include "stdlib/blas/base/caxpy_fortran.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include "stdlib/complex/float32/ctor.h" + + +/** +* Scales a single-precision complex floating-point vector by a single-precision complex floating-point constant and adds the result to a single-precision complex floating-point vector. +* +* @param N number of indexed elements +* @param alpha scalar constant +* @param X input array +* @param strideX X stride length +* @param Y output array +* @param strideY Y stride length +*/ +void API_SUFFIX( c_caxpy )( const CBLAS_INT N, const stdlib_complex64_t alpha, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY ) { + caxpy( &N, &alpha, (void *)X, &strideX, (void *)Y, &strideY ); +} + +/** +* Scales a single-precision complex floating-point vector by a single-precision complex floating-point constant and adds the result to a single-precision complex floating-point vector using alternative indexing semantics. +* +* @param N number of indexed elements +* @param alpha scalar constant +* @param X input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y output array +* @param strideY Y stride length +* @param offsetY starting index for Y +*/ +void API_SUFFIX( c_caxpy_ndarray )( const CBLAS_INT N, const stdlib_complex64_t alpha, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + stdlib_complex64_t *x = (stdlib_complex64_t *)X; + stdlib_complex64_t *y = (stdlib_complex64_t *)Y; + + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); + y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); + + caxpy( &N, &alpha, (void *)x, &strideX, (void *)y, &strideY ); +}