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.
Joined: Sep 18, 2005
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.