@@ -35,12 +35,15 @@ import dtypes = require( './../../dtypes' );
35
35
import empty = require( './../../empty' ) ;
36
36
import emptyLike = require( './../../empty-like' ) ;
37
37
import FancyArray = require( './../../fancy' ) ;
38
+ import filter = require( './../../filter' ) ;
39
+ import filterMap = require( './../../filter-map' ) ;
38
40
import flag = require( './../../flag' ) ;
39
41
import flags = require( './../../flags' ) ;
40
42
import scalar2ndarray = require( './../../from-scalar' ) ;
41
43
import ind2sub = require( './../../ind2sub' ) ;
42
44
import indexModes = require( './../../index-modes' ) ;
43
45
import iter = require( './../../iter' ) ;
46
+ import map = require( './../../map' ) ;
44
47
import maybeBroadcastArray = require( './../../maybe-broadcast-array' ) ;
45
48
import maybeBroadcastArrays = require( './../../maybe-broadcast-arrays' ) ;
46
49
import minDataType = require( './../../min-dtype' ) ;
@@ -55,6 +58,7 @@ import order = require( './../../order' );
55
58
import orders = require( './../../orders' ) ;
56
59
import outputDataTypePolicies = require( './../../output-dtype-policies' ) ;
57
60
import promotionRules = require( './../../promotion-rules' ) ;
61
+ import reject = require( './../../reject' ) ;
58
62
import safeCasts = require( './../../safe-casts' ) ;
59
63
import sameKindCasts = require( './../../same-kind-casts' ) ;
60
64
import shape = require( './../../shape' ) ;
@@ -563,6 +567,83 @@ interface Namespace {
563
567
*/
564
568
FancyArray : typeof FancyArray ;
565
569
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( './../../ctor' );
585
+ * var ndarray2array = require( './../../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( './../../ctor' );
620
+ * var ndarray2array = require( './../../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
+
566
647
/**
567
648
* Returns a specified flag for a provided ndarray.
568
649
*
@@ -693,6 +774,44 @@ interface Namespace {
693
774
*/
694
775
iter : typeof iter ;
695
776
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( './../../ctor' );
790
+ * var ndarray2array = require( './../../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
+
696
815
/**
697
816
* Broadcasts an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape.
698
817
*
@@ -1019,6 +1138,42 @@ interface Namespace {
1019
1138
*/
1020
1139
promotionRules : typeof promotionRules ;
1021
1140
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( './../../ctor' );
1156
+ * var ndarray2array = require( './../../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
+
1022
1177
/**
1023
1178
* Returns a list of ndarray data types to which a provided ndarray data type can be safely cast.
1024
1179
*
0 commit comments