Skip to content

Instantly share code, notes, and snippets.

@harms
Created January 17, 2012 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harms/1624764 to your computer and use it in GitHub Desktop.
Save harms/1624764 to your computer and use it in GitHub Desktop.
J for directionally filtering out rows or columns of a matrix.
'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