aspose file tools*
The moose likes Beginning Java and the fly likes Comparing submatrix with a main matrix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Comparing submatrix with a main matrix" Watch "Comparing submatrix with a main matrix" New topic
Author

Comparing submatrix with a main matrix

sina sinchen
Greenhorn

Joined: May 24, 2004
Posts: 9
Dear all,

I have a matrix of the following form.
Ex:

1 0 0 0 1 0 1 1 0 1 1
0 0 0 1 0 1 0 1 1 1 0
1 1 1 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 1
1 0 0 1 1 0 0 0 0 0 1
1 1 1 0 0 0 1 0 0 0 0

I have to search in this matrix a submatrix(A) of the form
0 1 1
0 0 1
0 0 0. and the program should give the output:i) Total no.of submatrix present in the main matrix and ii)row and column elements forming the submatrix in the main matrix.

For Ex: in the above example we can find the submatrix for R4,R5,R6&C9,C10,C11

THe search must take into consideration the combinations all the rows and colums.i.e.,the rows and colums are not only consecutive but also the program should compare submatrix(A) with the submatrix from the main matrix using the combination like row1,2,5& column 1,2,4 and so on.......

I havenot done any programming like this before where I can compare a submatrix with a main matrix. I have written the program using if and for loops and that worked out pretty well, but for my file it took almost 1day to run since there were many loops.

So please suggest me for generating the code and how to proceed with the programming.

THanx in advance.
Kenneth Albertson
Ranch Hand

Joined: Sep 18, 2005
Posts: 59
If the submatrix size is fixed, you only need 2 for loops. Even if the submatrix can be of a variable size and shape, you would still only need 4 for loops, and the program would still only take 1 second to run.

If you want some assistance, sina, you need to do more than just describe the exercise and ask someone to do it for you. You need to show the code you have written (using [code] tags, so that it is readable), and explain what you have done to work out what the problem is. Then we can give you some hints.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing submatrix with a main matrix