Lets say I have the vector
x = [x0, x1, x2, x3] = [0, 2, 3, 1].
I want to create a symmetric matrix from x. Ie a symmetric matrix that has x as the first row and first column, with x0 as the diagonal. In other words, I want a matrix X like this:
X = [0 2 3 1] = [x0 x1 x2 x3]
[2 0 1 3] [x1 x0 x3 x2]
[3 1 0 2] [x2 x3 x0 x1]
[1 3 2 0] [x3 x2 x1 x0]
Question:
- How can I do this in C?
- How can I extend this for any length vector given?
Computer science is not my area, so all of my attempts so far are quite laughable and involve loops upon loops. Am I missing something obvious?
Thank you