Edit:
After talking with OP in the comments, it sounds like he might want a way to have a computer go through and search for contiguous blocks of -1's in rows or columns of a matrix. I'm providing an example here where you can search through the rows, using numpy in python:
import numpy as np;
V = np.array([
[0,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,-1,0,0,0,0,-1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,-1,-1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,-1,-1,0,0,0,-1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]])
def group_finder(A, num):
print("Searching for groups of %d's in the rows of this matrix:"%num)
print(A)
print
m = M.shape[0]
n = M.shape[1]
#find groups in rows
for i in range(m):
last_matched = False;
index_of_group_start = None;
#go through the entries in each row
for j in range(n) :
this_matched = (M[i][j] == num)
if(this_matched):
if(last_matched):
continue #keep processing the matching numbers
else:
index_of_group_start = j
else:
if(last_matched and index_of_group_start+1 != j):
print("There is a group of %d's in row %d."
%(num, i+1))#add one because numpy is zero-indexed.
print("It starts at column %d and ends at column %d"
%(index_of_group_start+1, j))
print
#update values for next iteration
last_matched = this_matched
group_finder(V, -1)
When I run that code on my machine, this is what I get as output:
Searching for groups of -1's in the rows of this matrix:
[[ 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[ 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0]
[ 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0]
[ 0 0 0 0 0 0 0 -1 -1 1 0 0 0 0 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 -1 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1]
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
There is a group of -1's in row 1.
It starts at column 2 and ends at column 4
There is a group of -1's in row 3.
It starts at column 6 and ends at column 7
There is a group of -1's in row 4.
It starts at column 8 and ends at column 9
There is a group of -1's in row 5.
It starts at column 11 and ends at column 12
There is a group of -1's in row 7.
It starts at column 13 and ends at column 14
Old Answer:
I think you are having a hard time describing what you are asking for. Understandable. I think I can help you describe your problem.
It seems like you need to find consecutive cells of -1's in a spreadsheet program, like Microsoft Excel or LibreOffice. You want something that can find a contiguous group of negative ones in a matrix, and then operate on them. You're looking for something like the COUNTIF
function, but instead of counting cells with a specific property, you are trying to highlight or select cells with a specific property. Specifically, you want to highlight cells that contain a -1, and have a non-diagonal neighboring cell that also contains a -1. Your question is how you can make your spreadsheet program do that.
If that is the case, you have used the wrong tags for your question. Just because someone knows math does not mean that they know spreadsheet software. I would recommend changing the tags on your question. Some good tags might be calc-libreoffice
, excel
, or spreadsheet
. In fact, there is an answer to a similar question with the excel
tag, though it does not deal with rows.
There's a chance you are instead trying to understand how a mathematician would describe a contiguous group of negative ones in a matrix. In that case, I think your question might be better phrased as "What mathematical expression should I use to describe a submatrix that consists entirely of -1s and is restricted to a portion of only one row or a portion of only one column."
One answer to that question is to use a form of matrix subscript notation. I would notate your first group as V5, 11 -- 12 and your second group as V7 -- 10, 15. I would then just say that the entries in V5, 11 -- 12 are all -1.