For exampleBasically, for the following matrix

behavior of MaxLocColumnWise(A,k) whereis the search of columnwise k=1maximum location should searchin the maximumsubmatrices of the vector [5A. Passing by reference,8] and changes k from 1 to 2MaxLocColumnWise, which is changes the row locationvalue of 8k in.
For example, for the originalfollowing matrix.

- when
k=0, MaxLocColumnWise(A,k) converts k to the index of maximum element in [1,4,7], which is 2, which is the index of 7 i.e. we get 2 as a result of
int k = 0;
`MaxLocColumnWise(A,k)`;
std::cout << k <<"\n";
when k=1, MaxLocColumnWise(A,k) converts k to the index of maximum element in [5,8], which is 2, which is the index of 8. (This case is highlighted in red here)
when k=2, MaxLocColumnWise(A,k) converts k to the index of maximum element in [9], which is 2, which is the index of 9
And interestinglyInterestingly it turns out that the following code takes quite long time.
(An excuse for the exclusion of the code : Matrix is just from typedef std::vector<Vector> Matrix;)
I have implemented this subroutine to the following Gaussian elimination with partial pivoting routine:
void GaussElimPartialPivot(Matrix& A, Vector& b){
int n = A.size();
for (int j=0; j<(n-1); j++){
int index = j;
MaxLocColumnWise(A, index);
SwapMatrixRows(A, j, index);
SwapVector(b, j, index);
// main loop
for (int i=(j+1); i<n; i++){
double m = A[i][j]/A[j][j];
b[i] -= m*b[j];
for(int k=j; k<n; k++){
A[i][k] -= m*A[j][k];
}
}
}
}
But when A gets large, the program gets slower exactly due to the subroutine MaxLocColumnWise, which was verified from excluding each subroutine in the main code.
But I'm not sure exactly where in MaxLocColumnWise() to blame. Any help will be appreciated.