Skip to content

Commit c72a036

Browse files
committed
refactor: optimize the function
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 5804066 commit c72a036

File tree

1 file changed

+4
-4
lines changed
  • lib/node_modules/@stdlib/array/base/linspace2d/lib

1 file changed

+4
-4
lines changed

lib/node_modules/@stdlib/array/base/linspace2d/lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var zeros2d = require( '@stdlib/array/base/zeros2d' );
24-
var linspace = require( '@stdlib/array/base/linspace' );
2524

2625

2726
// MAIN //
@@ -44,12 +43,12 @@ var linspace = require( '@stdlib/array/base/linspace' );
4443
*/
4544
function linspace2d( start, stop, shape, colexicographic ) {
4645
var out;
47-
var arr;
4846
var idx;
4947
var s0;
5048
var i0;
5149
var s1;
5250
var i1;
51+
var d;
5352
var n;
5453

5554
s0 = shape[ 1 ];
@@ -60,17 +59,18 @@ function linspace2d( start, stop, shape, colexicographic ) {
6059
return [];
6160
}
6261

63-
arr = linspace( start, stop, n );
62+
d = ( stop - start ) / ( n - 1 );
6463
out = zeros2d( shape );
6564
idx = 0;
65+
6666
for ( i1 = 0; i1 < s1; i1++ ) {
6767
for ( i0 = 0; i0 < s0; i0++ ) {
6868
if ( colexicographic ) {
6969
idx = ( i0 * s1 ) + i1;
7070
} else {
7171
idx = ( i1 * s0 ) + i0;
7272
}
73-
out[ i1 ][ i0 ] = arr[ idx ];
73+
out[ i1 ][ i0 ] = start + ( idx * d );
7474
}
7575
}
7676
return out;

0 commit comments

Comments
 (0)