Created
January 17, 2012 04:47
-
-
Save harms/1624764 to your computer and use it in GitHub Desktop.
J for directionally filtering out rows or columns of a matrix.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'byRow byColumn'=: <"0 s:' Row Column' NB. these two names may be any two distinct values | |
nix=: 2 :' #~"(1+n=byRow) -.@ u"(1+n=byColumn) ' | |
NB. examples of use: | |
(2={.) nix byColumn i. 3 5 | |
0 1 3 4 | |
5 6 8 9 | |
10 11 13 14 | |
(2|+/%#) nix byRow i. 3 5 | |
0 1 2 3 4 | |
10 11 12 13 14 | |
Note 'inspired by "Machine Learning for .NET" by Seth Juarez' | |
Equivalent to the portion of Matrix.cs that begins: | |
public Matrix this[Func<Vector, bool> f, VectorType t] | |
http://machine.codeplex.com/SourceControl/changeset/view/094e8d33f44f#ml/Math/Matrix.cs | |
see also article by Seth Juarez in Jan 2012 issue http://www.mashedcodemagazine.com/ | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment