@@ -35,12 +35,15 @@ import dtypes = require( '@stdlib/ndarray/dtypes' );
3535import empty = require( '@stdlib/ndarray/empty' ) ;
3636import emptyLike = require( '@stdlib/ndarray/empty-like' ) ;
3737import FancyArray = require( '@stdlib/ndarray/fancy' ) ;
38+ import filter = require( '@stdlib/ndarray/filter' ) ;
39+ import filterMap = require( '@stdlib/ndarray/filter-map' ) ;
3840import flag = require( '@stdlib/ndarray/flag' ) ;
3941import flags = require( '@stdlib/ndarray/flags' ) ;
4042import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ) ;
4143import ind2sub = require( '@stdlib/ndarray/ind2sub' ) ;
4244import indexModes = require( '@stdlib/ndarray/index-modes' ) ;
4345import iter = require( '@stdlib/ndarray/iter' ) ;
46+ import map = require( '@stdlib/ndarray/map' ) ;
4447import maybeBroadcastArray = require( '@stdlib/ndarray/maybe-broadcast-array' ) ;
4548import maybeBroadcastArrays = require( '@stdlib/ndarray/maybe-broadcast-arrays' ) ;
4649import minDataType = require( '@stdlib/ndarray/min-dtype' ) ;
@@ -55,6 +58,7 @@ import order = require( '@stdlib/ndarray/order' );
5558import orders = require( '@stdlib/ndarray/orders' ) ;
5659import outputDataTypePolicies = require( '@stdlib/ndarray/output-dtype-policies' ) ;
5760import promotionRules = require( '@stdlib/ndarray/promotion-rules' ) ;
61+ import reject = require( '@stdlib/ndarray/reject' ) ;
5862import safeCasts = require( '@stdlib/ndarray/safe-casts' ) ;
5963import sameKindCasts = require( '@stdlib/ndarray/same-kind-casts' ) ;
6064import shape = require( '@stdlib/ndarray/shape' ) ;
@@ -563,6 +567,83 @@ interface Namespace {
563567 */
564568 FancyArray : typeof FancyArray ;
565569
570+ /**
571+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
572+ *
573+ * @param x - input ndarray
574+ * @param options - options
575+ * @param options.dtype - output ndarray data type
576+ * @param options.order - iteration order
577+ * @param predicate - predicate function
578+ * @param thisArg - predicate function execution context
579+ * @returns output ndarray
580+ *
581+ * @example
582+ * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive;
583+ * var Float64Array = require( '@stdlib/array/float64' );
584+ * var ndarray = require( '@stdlib/ndarray/ctor' );
585+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
586+ *
587+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
588+ * var shape = [ 2, 3 ];
589+ * var strides = [ 6, 1 ];
590+ * var offset = 1;
591+ *
592+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
593+ * // returns <ndarray>
594+ *
595+ * var opts = {
596+ * 'dtype': 'generic'
597+ * };
598+ * var y = ns.filter( x, opts, isEven );
599+ * // returns <ndarray>
600+ *
601+ * var arr = ndarray2array( y );
602+ * // returns [ 2.0, 4.0, 8.0, 10.0 ]
603+ */
604+ filter : typeof filter ;
605+
606+ /**
607+ * Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
608+ *
609+ * @param x - input ndarray
610+ * @param options - options
611+ * @param options.dtype - output ndarray data type
612+ * @param options.order - iteration order
613+ * @param fcn - callback function
614+ * @param thisArg - callback function execution context
615+ * @returns output ndarray
616+ *
617+ * @example
618+ * var Float64Array = require( '@stdlib/array/float64' );
619+ * var ndarray = require( '@stdlib/ndarray/ctor' );
620+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
621+ *
622+ * function scale( z ) {
623+ * if ( z > 5.0 ) {
624+ * return z * 10.0;
625+ * }
626+ * }
627+ *
628+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
629+ * var shape = [ 2, 3 ];
630+ * var strides = [ 6, 1 ];
631+ * var offset = 1;
632+ *
633+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
634+ * // returns <ndarray>
635+ *
636+ * var opts = {
637+ * 'dtype': 'generic'
638+ * };
639+ * var y = ns.filterMap( x, opts, scale );
640+ * // returns <ndarray>
641+ *
642+ * var arr = ndarray2array( y );
643+ * // returns [ 80.0, 90.0, 100.0 ]
644+ */
645+ filterMap : typeof filterMap ;
646+
566647 /**
567648 * Returns a specified flag for a provided ndarray.
568649 *
@@ -693,6 +774,44 @@ interface Namespace {
693774 */
694775 iter : typeof iter ;
695776
777+ /**
778+ * Applies a callback function to elements in an input ndarray and assigns results to elements in a new output ndarray.
779+ *
780+ * @param x - input ndarray
781+ * @param options - options
782+ * @param options.dtype - output ndarray data type
783+ * @param fcn - callback function
784+ * @param thisArg - callback function execution context
785+ * @returns output ndarray
786+ *
787+ * @example
788+ * var Float64Array = require( '@stdlib/array/float64' );
789+ * var ndarray = require( '@stdlib/ndarray/ctor' );
790+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
791+ *
792+ * function scale( z ) {
793+ * return z * 10.0;
794+ * }
795+ *
796+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
797+ * var shape = [ 2, 3 ];
798+ * var strides = [ 6, 1 ];
799+ * var offset = 1;
800+ *
801+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
802+ * // returns <ndarray>
803+ *
804+ * var opts = {
805+ * 'dtype': 'generic'
806+ * };
807+ * var y = ns.map( x, opts, scale );
808+ * // returns <ndarray>
809+ *
810+ * var arr = ndarray2array( y );
811+ * // returns [ [ 20, 30, 40 ], [ 80, 90, 100 ] ]
812+ */
813+ map : typeof map ;
814+
696815 /**
697816 * Broadcasts an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape.
698817 *
@@ -1019,6 +1138,42 @@ interface Namespace {
10191138 */
10201139 promotionRules : typeof promotionRules ;
10211140
1141+ /**
1142+ * Returns a shallow copy of an ndarray containing only those elements which fail a test implemented by a predicate function.
1143+ *
1144+ * @param x - input ndarray
1145+ * @param options - options
1146+ * @param options.dtype - output ndarray data type
1147+ * @param options.order - iteration order
1148+ * @param predicate - predicate function
1149+ * @param thisArg - predicate function execution context
1150+ * @returns output ndarray
1151+ *
1152+ * @example
1153+ * var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive;
1154+ * var Float64Array = require( '@stdlib/array/float64' );
1155+ * var ndarray = require( '@stdlib/ndarray/ctor' );
1156+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
1157+ *
1158+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1159+ * var shape = [ 2, 3 ];
1160+ * var strides = [ 6, 1 ];
1161+ * var offset = 1;
1162+ *
1163+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1164+ * // returns <ndarray>
1165+ *
1166+ * var opts = {
1167+ * 'dtype': 'generic'
1168+ * };
1169+ * var y = ns.reject( x, opts, isOdd );
1170+ * // returns <ndarray>
1171+ *
1172+ * var arr = ndarray2array( y );
1173+ * // returns [ 2.0, 4.0, 8.0, 10.0 ]
1174+ */
1175+ reject : typeof reject ;
1176+
10221177 /**
10231178 * Returns a list of ndarray data types to which a provided ndarray data type can be safely cast.
10241179 *
0 commit comments