# Select rows of matrix that are higher than a given row

Imagine I have the following matrix: X={{0,0,0},{1,0,1},{1,1,1},{1,2,1},{3,3,3}}. I want to select the sublists that are greater or equal than this list T={0,1,1}. Greater in the sense that X[[]]-T has no negative entries. The output should look like R={{1,1,1},{1,2,1},{3,3,3}}, since all elements of the sublists are equal of greater than the elements of the list T compared element by element. Thanks for help!

Thanks for the quick answers. I have searched myself meanwhile and found this one:

Higher[C_] := Select[B, NonNegative[Min[#[[]] - C[[]]]] &];


Does it seem right?

X = Table[RandomInteger[{-10, 10}], {30}, {3}]


1

Faster

Select[X, And @@ Thread[# > {0, 1, 1}] &]


or slower one:

Select[X, (! MemberQ[# - {0, 1, 1}, _?NonPositive]) &]

• Thanks Kuba! It works perfectly! Which one do you recommend I use for efficiency purposes! The one you suggested or the one I found above? Thanks. :) – Friedrich Nietzsche Jun 25 '13 at 5:30

If x is short then it probably doesn't matter much how you do it,
but if x is long then Pick is clearly faster than either Select.
The trick is to operate on a few long vectors (the columns of x)
rather than many short vectors (the rows of x).

t = {0,1,1}; Dimensions[x = RandomInteger[3, {10^5, 3}]]
(* {100000, 3} *)

AbsoluteTiming@Dimensions@Select[x,NonNegative@Min[#-t]&]
(* {1.888830, {56520, 3}} *)