- #1
brydustin
- 205
- 0
Basically, I'm trying to get the various entries of TT to be dotted with the various entries of KK. Each row of TT is a vector while in KK the elements are vectors.
So I'm working with different dimensions, but should be able to "call" them still using the right command. My attempt is below, and when I do the calculation in a loop, I get an error, however if I try it outside of a loop, for example:
Dot[TT[[2]], KK[[2, 3]]]
I don't get error, this equals = 0.86
=======
TT = {{-0.8, 0.4, -0.1}, {-0.1, 0.8, 0.4`}, {-0.5, 0.78`, -0.4}, {0.1,
0.18, -0.9}, {0.8, -0.1`, -0.4}, {0.7, -0.3`, 0.55`}} ;
KK = {{{0.`, 0.`, 0.`}, {-7.1`, 0.7`, -0.1`}, {-13.`, 0.8`,
0.8`}, {-18.`, -2.`, 2.2`}, {-21.`, -6.`, 3.`}, {-26.`, -10.`,
2.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-5.`, 0.`,
0.9`}, {-11.1`, -2.8`, 2.3285`}, {-14.`, -7.`,
3.`}, {-19.`, -11.`, 3.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`,
0.`}, {0.`, 0.`, 0.`}, {-5.1`, -2.`, 1.`}, {-8.`, -7.`,
2.`}, {-13.`, -11.`, 2.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`,
0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-3.`, -4.`,
1.`}, {-8.`, -8.`, 0.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`,
0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-4.`, -3.`,
0.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`,
0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}}}
JJ = IdentityMatrix[6];
For[i = 1, i < 6, i++,
For[j = i + 1, j < 6, j++
JJ[[i, j]] = (Dot[TT[], KK[[i, j]]] -
Dot[TT[[j]], KK[[i, j]]])/(Norm[KK[[i, j]]])^3
]]
So I'm working with different dimensions, but should be able to "call" them still using the right command. My attempt is below, and when I do the calculation in a loop, I get an error, however if I try it outside of a loop, for example:
Dot[TT[[2]], KK[[2, 3]]]
I don't get error, this equals = 0.86
=======
TT = {{-0.8, 0.4, -0.1}, {-0.1, 0.8, 0.4`}, {-0.5, 0.78`, -0.4}, {0.1,
0.18, -0.9}, {0.8, -0.1`, -0.4}, {0.7, -0.3`, 0.55`}} ;
KK = {{{0.`, 0.`, 0.`}, {-7.1`, 0.7`, -0.1`}, {-13.`, 0.8`,
0.8`}, {-18.`, -2.`, 2.2`}, {-21.`, -6.`, 3.`}, {-26.`, -10.`,
2.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-5.`, 0.`,
0.9`}, {-11.1`, -2.8`, 2.3285`}, {-14.`, -7.`,
3.`}, {-19.`, -11.`, 3.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`,
0.`}, {0.`, 0.`, 0.`}, {-5.1`, -2.`, 1.`}, {-8.`, -7.`,
2.`}, {-13.`, -11.`, 2.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`,
0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-3.`, -4.`,
1.`}, {-8.`, -8.`, 0.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`,
0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {-4.`, -3.`,
0.`}}, {{0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`,
0.`, 0.`}, {0.`, 0.`, 0.`}, {0.`, 0.`, 0.`}}}
JJ = IdentityMatrix[6];
For[i = 1, i < 6, i++,
For[j = i + 1, j < 6, j++
JJ[[i, j]] = (Dot[TT[], KK[[i, j]]] -
Dot[TT[[j]], KK[[i, j]]])/(Norm[KK[[i, j]]])^3
]]