Nehal,
I am not sure exactly what you want to do. Maybe post a simple example of a 3x4 input and the output you expect. I would look at the function Inner. I think it can be coaxed to give you what you want without writing all of that code. For example:
mat = {{a1, a2, a3, a4}, {b1, b2, b3, b4}, {c1, c2, c3, c4}}
Inner[Plus, Transpose[mat], mat]
Returns a matrix which is
{{col1+col1, col1+col2, col1+col3, col1+col4},
{{col2+col1, col2+col2, col2+col3, col2+col4},
{col3+col1, col3+col2, col3+col3, col3+col4},
{col4+col1, col4+col2, col4+col3, col4+col4}
in this example it is:
{{2 a1 + 2 b1 + 2 c1, a1 + a2 + b1 + b2 + c1 + c2,
a1 + a3 + b1 + b3 + c1 + c3,
a1 + a4 + b1 + b4 + c1 + c4}, {a1 + a2 + b1 + b2 + c1 + c2,
2 a2 + 2 b2 + 2 c2, a2 + a3 + b2 + b3 + c2 + c3,
a2 + a4 + b2 + b4 + c2 + c4}, {a1 + a3 + b1 + b3 + c1 + c3,
a2 + a3 + b2 + b3 + c2 + c3, 2 a3 + 2 b3 + 2 c3,
a3 + a4 + b3 + b4 + c3 + c4}, {a1 + a4 + b1 + b4 + c1 + c4,
a2 + a4 + b2 + b4 + c2 + c4, a3 + a4 + b3 + b4 + c3 + c4,
2 a4 + 2 b4 + 2 c4}}
If that is not exactly what you want, you can change its inputs or extract part of the result since, as best I can tell, it is close to what you want.
Regards,
Neil