Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ void API_SUFFIX(stdlib_strided_dmeanstdevpn)( const CBLAS_INT N, const double co
* @param offsetOut starting index for Out
*/
void API_SUFFIX(stdlib_strided_dmeanstdevpn_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) {
CBLAS_INT io;
const CBLAS_INT io = offsetOut + strideOut;

API_SUFFIX(stdlib_strided_dmeanvarpn_ndarray)( N, correction, X, strideX, offsetX, Out, strideOut, offsetOut );

if ( strideOut < 0 ) {
io = 0;
} else {
io = strideOut + offsetOut;
}
Out[ io ] = stdlib_base_sqrt( Out[ io ] );
return;
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,32 @@ tape( 'the function supports negative `stride` parameters', function test( t ) {
t.end();
});

tape( 'the function supports a negative `strideOut` parameter and an `offsetOut` parameter', function test( t ) {
var expected;
var out;
var x;
var v;

x = new Float64Array([
1.0, // 0
2.0,
2.0, // 1
-7.0,
-2.0, // 2
3.0,
4.0, // 3
2.0
]);
out = new Float64Array( 4 );

v = dmeanstdevpn( 4, 1, x, 2, 0, out, -1, 3 );

expected = new Float64Array( [ 0.0, 0.0, 2.5, 1.25 ] );
t.deepEqual( v, expected, 'returns expected value' );

t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns an arithmetic mean equal to the first element and a standard deviation of `0`', function test( t ) {
var expected;
var out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,32 @@ tape( 'the function supports negative `stride` parameters', opts, function test(
t.end();
});

tape( 'the function supports a negative `strideOut` parameter and an `offsetOut` parameter', opts, function test( t ) {
var expected;
var out;
var x;
var v;

x = new Float64Array([
1.0, // 0
2.0,
2.0, // 1
-7.0,
-2.0, // 2
3.0,
4.0, // 3
2.0
]);
out = new Float64Array( 4 );

v = dmeanstdevpn( 4, 1, x, 2, 0, out, -1, 3 );

expected = new Float64Array( [ 0.0, 0.0, 2.5, 1.25 ] );
t.deepEqual( v, expected, 'returns expected value' );

t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns an arithmetic mean equal to the first element and a standard deviation of `0`', opts, function test( t ) {
var expected;
var out;
Expand Down