Skip to content

Commit 16ed26d

Browse files
committed
Add interface
1 parent 41986f6 commit 16ed26d

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

lib/node_modules/@stdlib/strided/common/include/stdlib/strided/common/unary.h

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ void stdlib_strided_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, vo
4141
*/
4242
void stdlib_strided_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn );
4343

44+
/**
45+
* Applies a unary callback to each element in a strided input array, casting the callback's single-precision floating-point return value to a double-precision floating-point number.
46+
*/
47+
void stdlib_strided_f_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn );
48+
4449
/**
4550
* Applies a unary callback returning double-precision floating-point numbers, casts results to single-precision floating-point format, and assigns results to elements in a strided output array.
4651
*/

lib/node_modules/@stdlib/strided/common/src/nullary.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void stdlib_strided_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void
131131
*
132132
* // Define a callback:
133133
* float ones() {
134-
* return 1.0;
134+
* return 1.0f;
135135
* }
136136
*
137137
* // Fill the output array with ones:

lib/node_modules/@stdlib/strided/common/src/unary.c

+42-4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,44 @@ void stdlib_strided_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, vo
144144
STDLIB_UNARY_LOOP_CLBK( float, float )
145145
}
146146

147+
/**
148+
* Applies a unary callback to each element in a strided input array, casting the callback's single-precision floating-point return value to a double-precision floating-point number.
149+
*
150+
* @param arrays array whose first element is a pointer to a strided input array and whose last element is a pointer to a strided output array
151+
* @param shape array whose only element is the number of elements over which to iterate
152+
* @param strides array containing strides (in bytes) for each strided array
153+
* @param fcn callback
154+
*
155+
* @example
156+
* #include "stdlib/strided/common/unary.h"
157+
* #include <stdint.h>
158+
*
159+
* // Create underlying byte arrays:
160+
* uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
161+
* uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
162+
*
163+
* // Define a pointer to an array containing pointers to strided arrays:
164+
* uint8_t *arrays[] = { x, out };
165+
*
166+
* // Define the strides:
167+
* int64_t strides[] = { 4, 8 }; // 4 bytes per float, 8 bytes per double
168+
*
169+
* // Define the number of elements over which to iterate:
170+
* int64_t shape[] = { 3 };
171+
*
172+
* // Define a callback:
173+
* float scale( float x ) {
174+
* return x + 10.0f;
175+
* }
176+
*
177+
* // Apply the callback:
178+
* stdlib_strided_f_f( arrays, shape, strides, (void *)scale );
179+
*/
180+
void stdlib_strided_f_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ) {
181+
UnaryFcnFloat32 *f = (UnaryFcnFloat32 *)fcn;
182+
STDLIB_UNARY_LOOP_CLBK( float, double )
183+
}
184+
147185
/**
148186
* Applies a unary callback to each element in a strided input array, casting the callback's double-precision return value to a single-precision floating-point number.
149187
*
@@ -741,7 +779,7 @@ void stdlib_strided_H_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *stri
741779
*
742780
* // Define a callback:
743781
* float scale( float x ) {
744-
* return x + (float)10.0;
782+
* return x + 10.0f;
745783
* }
746784
*
747785
* // Apply the callback:
@@ -1083,7 +1121,7 @@ void stdlib_strided_h_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *stri
10831121
*
10841122
* // Define a callback:
10851123
* float scale( float x ) {
1086-
* return x + (float)10.0;
1124+
* return x + 10.0f;
10871125
* }
10881126
*
10891127
* // Apply the callback:
@@ -1501,7 +1539,7 @@ void stdlib_strided_B_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *stri
15011539
*
15021540
* // Define a callback:
15031541
* float scale( float x ) {
1504-
* return x + (float)10.0;
1542+
* return x + 10.0f;
15051543
* }
15061544
*
15071545
* // Apply the callback:
@@ -1957,7 +1995,7 @@ void stdlib_strided_b_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *stri
19571995
*
19581996
* // Define a callback:
19591997
* float scale( float x ) {
1960-
* return x + (float)10.0;
1998+
* return x + 10.0f;
19611999
* }
19622000
*
19632001
* // Apply the callback:

0 commit comments

Comments
 (0)