So I'm suppose to make a convolution matrix. An 8x8 and a 3x3 to make a 6x6. What I'm planning to do was find the sum of the 3x3 and multiply the sum of the 8x8 starting from the top left [0-2][9-11][17-19] store the result on a 6x6 matrix at [0][0] then move one column to the right of the 8x8, so and it'll then multiply it by [1-3][10-12][18-20] and store the result in the 6x6 at [0][1] and repeat until it reaches the end then it'll start back on the 0 column but shift the row of the 8x8 by 1.
int eightArray[8][8];
int a[6][6];
int something = 0;
int threeRow = 0, threeColumn = 0, counterOne = 0, counterTwo = 0, column = 0, row = 0;
for(int i = threeRow; i < 8; i++){
for(int j = threeColumn; j < 8; j++){
counterOne++;
something += eightArray[i][j];
cout << i << " " << j << " ";
// After it checks 3 three column it goes to the next row
if(counterOne % 3 == 0){
cout << endl;
break;
}
}
// After it checks three rows the sum of 3x3 matrix within the 8x8 is found
++counterTwo;
if(counterTwo % 3 == 0){
i = threeRow;
cout << endl;
// Set the 6x6 matrix with the product
a[row][column] = something;
something = 0;
// Starts reading the 8x8 matrix on the next column
threeColumn++;
column++;
// Can only shift it 6 times before out of range
if(column % 6 == 0){
cout << endl << "Next set" << endl;
// Resets the column back to 0
threeColumn = 0;
column = 0;
// Starts reading from next row
threeRow++;
row++;
// After reading 6 rows, breaks out of loop
if(row % 6 == 0){
break;
}
}
}
}
When I found your post it was green checked which tells most people that you re done with the post and have an answer. A good reason you have not received any response.
I did not know if this bit of code is to be put in main or a function. I put it in main and it worked for now.
When I started working on your program I found that each array needed to be initialized, so I did. After initializing the "a" array I wrote a set of nested for loops to set the "a" array to 1's. Later I noticed the program changed the "a" array back to 0's.
I also noticed that the "eightArray" never receives any values and the "something" variable is always 0, not very useful.
After running the program many times I changed line 9 to std::cout << i << " " << j << " X"; so I could see what was happening and realized the only output is coming from line 9 and not from any array. Hard to get your desired output when the only output is coming from your for loop iterators.
There needs to be some changes, but I have not figured out where yet. Your instructions are good, but some parts I do not completely understand yet.