1 | initial version |
Try multiply(M.col(i), 1.0/(sum(M.col(i))(0)), M.col(i));
This takes the column, finds the sum, and multiplies the column by 1/sum. Then use the reduce to check.
2 | No.2 Revision |
Try multiply(M.col(i), 1.0/(sum(M.col(i))(0)), M.col(i));
This takes the column, finds the sum, and multiplies the column by 1/sum. Then use the reduce to check.
If you want to use the normalize function, you need to change the norm type to NORM_L1, and it will do the same thing. Actually, just do this, that's better.
3 | No.3 Revision |
Try multiply(M.col(i), 1.0/(sum(M.col(i))(0)), M.col(i));
This takes the column, finds the sum, and multiplies the column by 1/sum. Then use the reduce to check.
If you want to use the normalize function, you need to change the norm type to NORM_L1, and it will do the same thing. Actually, just do this, that's better.better. Here's the documentation on the normalize function so you can see why NORM_L2 wasn't working and why NORM_L1 will.