From 341533b52c5ed1a389655f411fb897376b7c72ca Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 6 Jul 2024 14:11:36 -0700 Subject: [PATCH] refactor: use utility to resolve offset --- .../@stdlib/strided/base/dmap/manifest.json | 4 +++- .../@stdlib/strided/base/dmap/src/main.c | 13 +++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/strided/base/dmap/manifest.json b/lib/node_modules/@stdlib/strided/base/dmap/manifest.json index 890a937a3dc0..4c25a16849f2 100644 --- a/lib/node_modules/@stdlib/strided/base/dmap/manifest.json +++ b/lib/node_modules/@stdlib/strided/base/dmap/manifest.json @@ -32,7 +32,9 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/strided/base/dmap/src/main.c b/lib/node_modules/@stdlib/strided/base/dmap/src/main.c index 99515725b589..dd7f184d63c7 100644 --- a/lib/node_modules/@stdlib/strided/base/dmap/src/main.c +++ b/lib/node_modules/@stdlib/strided/base/dmap/src/main.c @@ -17,6 +17,7 @@ */ #include "stdlib/strided/base/dmap.h" +#include "stdlib/strided/base/stride2offset.h" #include /** @@ -51,16 +52,8 @@ void stdlib_strided_dmap( const int64_t N, const double *X, const int64_t stride if ( N <= 0 ) { return; } - if ( strideX < 0 ) { - ix = (1-N) * strideX; - } else { - ix = 0; - } - if ( strideY < 0 ) { - iy = (1-N) * strideY; - } else { - iy = 0; - } + ix = stdlib_strided_stride2offset( N, strideX ); + iy = stdlib_strided_stride2offset( N, strideY ); for ( i = 0; i < N; i++ ) { Y[ iy ] = fcn( X[ ix ] ); ix += strideX;