Skip to content

Commit

Permalink
refactor: replace use of 'double precision' and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Apr 19, 2024
1 parent 818ede6 commit c8e7dea
Show file tree
Hide file tree
Showing 14 changed files with 1,012 additions and 1,479 deletions.
31 changes: 24 additions & 7 deletions lib/node_modules/@stdlib/blas/base/drot/benchmark/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ else
fPIC ?= -fPIC
endif

# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
INCLUDE ?=

# List of source files:
c_src := ../../src/drot.c
SOURCE_FILES ?=

# List of libraries (e.g., `-lopenblas -lpthread`):
LIBRARIES ?=

# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
LIBPATH ?=

# List of C targets:
c_targets := benchmark.length.out
Expand All @@ -79,11 +88,15 @@ c_targets := benchmark.length.out
# RULES #

#/
# Compiles C source files.
# Compiles source files.
#
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
# @param {string} [CFLAGS] - C compiler options
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`)
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
# @param {string} [SOURCE_FILES] - list of source files
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
#
# @example
# make
Expand All @@ -99,12 +112,16 @@ all: $(c_targets)
# Compiles C source files.
#
# @private
# @param {string} CC - C compiler
# @param {string} CFLAGS - C compiler flags
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
# @param {string} CC - C compiler (e.g., `gcc`)
# @param {string} CFLAGS - C compiler options
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
# @param {string} SOURCE_FILES - list of source files
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
#/
$(c_targets): %.out: %.c
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)

#/
# Runs compiled benchmarks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define ITERATIONS 10000000
#define REPEATS 3
#define MIN 1
#define MAX 5
#define MAX 6

/**
* Prints the TAP version.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2020 The Stdlib Authors.
# Copyright (c) 2024 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.
Expand Down
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/blas/base/drot/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
> {{alias}}.ndarray( 4, x, 1, 1, y, 1, 1, 0.8, 0.6 );
> x
<Float64Array>[ 1.0, ~5.8, 7.2, 8.6, 10.0 ]
> y
<Float64Array>[ 6.0, 4.4, ~4.6, ~4.8, 5.0 ]

// Advanced Indexing:
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/drot/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface Routine {
( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number, c: number, s: number ): Float64Array;

/**
* Applies a plane rotation.
* Applies a plane rotation using alternative indexing semantics.
*
* @param N - number of indexed elements
* @param x - first input array
Expand Down Expand Up @@ -101,9 +101,9 @@ interface Routine {
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
*
* drot.ndarray( 2, x, 2, 2, y, 2, 2, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, 2.0, 7.8, 4.0, 10.6, 6.0 ]
* // y => <Float64Array>[ 7.0, 8.0, 5.4, 10.0, ~5.8, 12.0 ]
* drot.ndarray( 3, x, 2, 1, y, 2, 1, 0.8, 0.6 );
* // x => <Float64Array>[ 1.0, 6.4, 3.0, 9.2, 5.0, 12.0 ]
* // y => <Float64Array>[ 7.0, 5.2, 9.0, 5.6, 11.0, ~6.0 ]
*/
declare var drot: Routine;

Expand Down
35 changes: 26 additions & 9 deletions lib/node_modules/@stdlib/blas/base/drot/examples/c/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2020 The Stdlib Authors.
# Copyright (c) 2024 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.
Expand Down Expand Up @@ -69,8 +69,17 @@ else
fPIC ?= -fPIC
endif

# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
INCLUDE ?=

# List of source files:
c_src := ../../src/drot.c
SOURCE_FILES ?=

# List of libraries (e.g., `-lopenblas -lpthread`):
LIBRARIES ?=

# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
LIBPATH ?=

# List of C targets:
c_targets := example.out
Expand All @@ -79,11 +88,15 @@ c_targets := example.out
# RULES #

#/
# Compiles C source files.
# Compiles source files.
#
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
# @param {string} [CFLAGS] - C compiler options
# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`)
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
# @param {string} [SOURCE_FILES] - list of source files
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
#
# @example
# make
Expand All @@ -99,15 +112,19 @@ all: $(c_targets)
# Compiles C source files.
#
# @private
# @param {string} CC - C compiler
# @param {string} CFLAGS - C compiler flags
# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code
# @param {string} CC - C compiler (e.g., `gcc`)
# @param {string} CFLAGS - C compiler options
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
# @param {string} SOURCE_FILES - list of source files
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
#/
$(c_targets): %.out: %.c
$(QUIET) $(CC) $(CFLAGS) $(fPIC) -I ../../include -o $@ $(c_src) $< -lm
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)

#/
# Runs compiled benchmarks.
# Runs compiled examples.
#
# @example
# make run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int main( void ) {

// Print the result:
for ( int i = 0; i < 5; i++ ) {
printf( "x[ %i ] = %lf\n", i, x[ i ] );
printf( "y[ %i ] = %lf\n", i, y[ i ] );
}
}
12 changes: 0 additions & 12 deletions lib/node_modules/@stdlib/blas/base/drot/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ function drot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) {
ix = offsetX;
iy = offsetY;

// If both strides are equal to `1`...
if ( strideX === 1 && strideY === 1 ) {
for ( i = 0; i < N; i++ ) {
tmp = ( c * x[ ix ] ) + ( s * y[ iy ] );
y[ iy ] = ( c * y[ iy ] ) - ( s * x[ ix ] );
x[ ix ] = tmp;
ix += strideX;
iy += strideY;
}
return y;
}
// If both strides are not equal to `1`...
for ( i = 0; i < N; i++ ) {
tmp = ( c * x[ ix ] ) + ( s * y[ iy ] );
y[ iy ] = ( c * y[ iy ] ) - ( s * x[ ix ] );
Expand Down
Loading

0 comments on commit c8e7dea

Please sign in to comment.