Skip to content

Commit 29ac5de

Browse files
committed
fix: apply suggestions from code review
--- 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: passed - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 9e7b708 commit 29ac5de

3 files changed

Lines changed: 101 additions & 1 deletion

File tree

lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,39 @@
2929
# Target name should match the add-on export name:
3030
'addon_target_name%': 'addon',
3131

32+
# Fortran compiler (to override -Dfortran_compiler=<compiler>):
33+
'fortran_compiler%': 'gfortran',
34+
35+
# Fortran compiler flags:
36+
'fflags': [
37+
# Specify the Fortran standard to which a program is expected to conform:
38+
'-std=f95',
39+
40+
# Indicate that the layout is free-form source code:
41+
'-ffree-form',
42+
43+
# Aggressive optimization:
44+
'-O3',
45+
46+
# Enable commonly used warning options:
47+
'-Wall',
48+
49+
# Warn if source code contains problematic language features:
50+
'-Wextra',
51+
52+
# Warn if a procedure is called without an explicit interface:
53+
'-Wimplicit-interface',
54+
55+
# Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers):
56+
'-fno-underscoring',
57+
58+
# Warn if source code contains Fortran 95 extensions and C-language constructs:
59+
'-pedantic',
60+
61+
# Compile but do not link (output is an object file):
62+
'-c',
63+
],
64+
3265
# Set variables based on the host OS:
3366
'conditions': [
3467
[
@@ -128,6 +161,68 @@
128161
},
129162
], # end condition (OS!="win")
130163
], # end conditions
164+
165+
# Define custom build actions for particular inputs:
166+
'rules': [
167+
{
168+
# Define a rule for processing Fortran files:
169+
'extension': 'f',
170+
171+
# Define the pathnames to be used as inputs when performing processing:
172+
'inputs': [
173+
# Full path of the current input:
174+
'<(RULE_INPUT_PATH)'
175+
],
176+
177+
# Define the outputs produced during processing:
178+
'outputs': [
179+
# Store an output object file in a directory for placing intermediate results (only accessible within a single target):
180+
'<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)'
181+
],
182+
183+
# Define the rule for compiling Fortran based on the host OS:
184+
'conditions': [
185+
[
186+
'OS=="win"',
187+
188+
# Rule to compile Fortran on Windows:
189+
{
190+
'rule_name': 'compile_fortran_windows',
191+
'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...',
192+
193+
'process_outputs_as_sources': 0,
194+
195+
# Define the command-line invocation:
196+
'action': [
197+
'<(fortran_compiler)',
198+
'<@(fflags)',
199+
'<@(_inputs)',
200+
'-o',
201+
'<@(_outputs)',
202+
],
203+
},
204+
205+
# Rule to compile Fortran on non-Windows:
206+
{
207+
'rule_name': 'compile_fortran_linux',
208+
'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...',
209+
210+
'process_outputs_as_sources': 1,
211+
212+
# Define the command-line invocation:
213+
'action': [
214+
'<(fortran_compiler)',
215+
'<@(fflags)',
216+
'-fPIC', # generate platform-independent code
217+
'<@(_inputs)',
218+
'-o',
219+
'<@(_outputs)',
220+
],
221+
}
222+
], # end condition (OS=="win")
223+
], # end conditions
224+
}, # end rule (extension=="f")
225+
], # end rules
131226
}, # end target <(addon_target_name)
132227

133228
# Target to copy a generated add-on to a standard location:

lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *
123123
}
124124
} else if ( N > 0 ) {
125125
prev = X[ offsetX ];
126+
io = offsetX;
126127
} else {
127128
prev = append[ offsetA ];
129+
io = offsetA;
128130
}
129131

130132
// x
@@ -216,7 +218,7 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN
216218

217219
// Copy `append` into output array:
218220
io = offsetOut + ( ( N1 + N ) * strideOut );
219-
c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, io );
221+
c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io );
220222
}
221223

222224
if ( k == 1 ) {

lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ tape( 'the function calculates the k-th discrete forward differences of a double
135135
t.deepEqual( o, expected, 'returns expected value' );
136136
t.strictEqual( out, o, 'return expected value' );
137137

138+
o = new Float64Array( 4 );
139+
w = new Float64Array( 4 );
140+
138141
out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len
139142
expected = new Float64Array([
140143
4.0,

0 commit comments

Comments
 (0)