Is this correct?

Yes that looks correct.

In my code, where am I computing right upper and left lower elements?

You are computing the whole thing.
You have two loops over the params creating a full size n x n matrix.