### Related

##### mat_norm-matrix

a:matrix([1,2,3,4,5]);

mat_norm(a,1);

Calculate

? mat_norm;

Calculate

##### mat_norm-matrix-sqrt-transpose

/* "Ground truth" */R...

RBTruth : transpose(m...

RCTruth : transpose(m...

Calculate

##### mat_norm-matrix

a:matrix([1,2,3,4,5]);

mat_norm(a,1);

Calculate

? mat_norm;

Calculate

##### mat_norm-matrix-sqrt-transpose

/* "Ground truth" */R...

RBTruth : transpose(m...

RCTruth : transpose(m...

Calculate

### mat_norm

Run Example
```(%i1)ans1:matrix([1,2,3],[4,5,6],[7,8,9]);
[ 1  2  3 ]
[         ]
(%o1)                             [ 4  5  6 ]
[         ]
[ 7  8  9 ]
(%i2) sum:(mat_norm(matrixmap(lambda([x],if not(equal(x,0)) then 1 else 0),ans1),frobenius))^2;
(%o2)                                  9
(%i3) ```
Run Example
```/* "Ground truth" */RATruth : transpose(matrix(  [0.14139, 0.153155, 0.978035],  [0.989608, -0.0479961, -0.135547],  [0.0261821, 0.987036, -0.15835]));
[ 0.14139    0.989608    0.0261821 ]
[                                  ]
(%o1)                [ 0.153155  - 0.0479961  0.987036  ]
[                                  ]
[ 0.978035  - 0.135547   - 0.15835 ]
(%i2) RBTruth : transpose(matrix(  [0.494514, 0.150712, 0.856003],  [0.869109, -0.0974071, -0.484935],  [0.0102952, 0.983767, -0.179154]));
[ 0.494514   0.869109    0.0102952  ]
[                                   ]
(%o2)                [ 0.150712  - 0.0974071   0.983767  ]
[                                   ]
[ 0.856003  - 0.484935   - 0.179154 ]
(%i3) RCTruth : transpose(matrix(  [0.715119, 0.102426, 0.691458],  [0.698985, -0.111708, -0.706357],  [0.00489207, 0.988448, -0.151478]));
[ 0.715119   0.698985   0.00489207 ]
[                                  ]
(%o3)                [ 0.102426  - 0.111708   0.988448  ]
[                                  ]
[ 0.691458  - 0.706357  - 0.151478 ]
(%i4) RBATruth: RBTruth.transpose(RATruth);
[ 0.93026610368792    0.0441851822223   0.364216637447  ]
[                                                       ]
(%o4)      [ - 0.0493285897661  0.99877090188431   0.0048253466537 ]
[                                                       ]
[ - 0.3635559192534  - 0.0224553193255   0.93130141445  ]
(%i5) RCATruth: RCTruth.transpose(RATruth);
[ 0.79295990795595   0.08080414569102   0.6038914320855  ]
[                                                        ]
(%o5)     [ - 0.0701854739432   0.9966823624968   - 0.041202843614 ]
[                                                        ]
[ - 0.6052173035798  - 0.0097116080103   0.796001238609  ]
(%i6) CATruth : [-17.6081, -3.12802, 0.014307];
(%o6)                  [- 17.6081, - 3.12802, 0.014307]
(%i7) CBTruth : [-13.8177, 0.726613, 0.116081];
(%o7)                   [- 13.8177, 0.726613, 0.116081]
(%i8) CCTruth : [-9.37493, 4.36508, 0.0385902];
(%o8)              [- 9.374930000000001, 4.36508, 0.0385902]
(%i9) CBATruth : RATruth.(CBTruth - CATruth)/sqrt((CBTruth - CATruth).(CBTruth - CATruth) + (CCTruth - CATruth).(CCTruth - CATruth));
[ 0.35173957178448  ]
[                   ]
(%o9)                        [ 0.040074487584944 ]
[                   ]
[ 0.25602115297259  ]
(%i10) CCATruth : RATruth.(CCTruth - CATruth)/sqrt((CBTruth - CATruth).(CBTruth - CATruth) + (CCTruth - CATruth).(CCTruth - CATruth));
[ 0.69326796938661  ]
[                   ]
(%o10)                       [ 0.074763438063957 ]
[                   ]
[ 0.56825773653939  ]
(%i11) /* Sampson error minimization, three view, AAAA */RBA3vS: matrix(   [ 0.930581,     0.044252,     0.363401],   [-0.049369,     0.998769,     0.004799],   [-0.362741,    -0.022407,     0.931621]);
[  0.930581    0.044252   0.363401 ]
[                                  ]
(%o11)               [ - 0.049369   0.998769   0.004799 ]
[                                  ]
[ - 0.362741  - 0.022407  0.931621 ]
(%i12) RCA3vS: matrix(   [ 0.794961,     0.080888,     0.601243],   [-0.070105,     0.996680,    -0.041395],   [-0.602596,    -0.009243,     0.797993]);
[  0.794961    0.080888    0.601243  ]
[                                    ]
(%o12)              [ - 0.070105   0.99668    - 0.041395 ]
[                                    ]
[ - 0.602596  - 0.009243   0.797993  ]
(%i13) CBA3vS : [0.352812, 0.040276, 0.257826];
(%o13)                  [0.352812, 0.040276, 0.257826]
(%i14) CCA3vS : [0.691708, 0.074028, 0.568759];
(%o14)                  [0.691708, 0.074028, 0.568759]
(%i15) /* Nister thing followed by Hartley thing, 0.233186 reprojection error */RBA2v5p: matrix(   [ 0.930940,     0.044140,     0.362495],   [-0.049239,     0.998775,     0.004833],   [-0.361837,    -0.022348,     0.931973]);
[  0.93094     0.04414    0.362495 ]
[                                  ]
(%o15)               [ - 0.049239   0.998775   0.004833 ]
[                                  ]
[ - 0.361837  - 0.022348  0.931973 ]
(%i16) RCA2v5p: matrix(   [ 0.793001,     0.082117,     0.603661],   [-0.070768,     0.996583,    -0.042602],   [-0.605097,    -0.008937,     0.796102]);
[  0.793001    0.082117    0.603661  ]
[                                    ]
(%o16)              [ - 0.070768   0.996583   - 0.042602 ]
[                                    ]
[ - 0.605097  - 0.008937   0.796102  ]
(%i17) CBA2v5p : [0.347189, 0.039900, 0.255276];
(%o17)                   [0.347189, 0.0399, 0.255276]
(%i18) CCA2v5p : [0.697271, 0.071345, 0.566944];
(%o18)                  [0.697271, 0.071345, 0.566944]
(%i19)    /* Rate that shit. */RotationDistance3D(A, B) := float(2*asin(mat_norm(ident(3) - A.transpose(B), frobenius)/(2*sqrt(2))));
(%o19) RotationDistance3D(A, B) := float(2
mat_norm(ident(3) - A . transpose(B), frobenius)
asin(------------------------------------------------))
2 sqrt(2)
(%i20) PositionDistance3D(A, B) := float(sqrt((A - B).(A - B)));
(%o20)    PositionDistance3D(A, B) := float(sqrt((A - B) . (A - B)))
(%i21) PositionDistance3D(CBA2v5p, CBATruth);
(%o21)                        0.0046144774823992
(%i22) PositionDistance3D(CCA2v5p, CCATruth);
(%o22)                         0.005425483995348
(%i23) RotationDistance3D(RBA2v5p, RBATruth);
(%o23)                        0.0018500737211556
(%i24) RotationDistance3D(RCA2v5p, RCATruth);
(%o24)                        0.0015345788657773
(%i25) PositionDistance3D(CBA3vS, CBATruth);
(%o25)                        0.0021090714362496
(%i26) PositionDistance3D(CCA3vS, CCATruth);
(%o26)                        0.0017960063168096
(%i27) RotationDistance3D(RBA3vS, RBATruth);
(%o27)                       8.7743421579866937E-4
(%i28) RotationDistance3D(RCA3vS, RCATruth);
(%o28)                        0.0033261809276113
(%i29) ```
Run Example
```/* "Ground truth" */RATruth : transpose(matrix(  [0.14139, 0.153155, 0.978035],  [0.989608, -0.0479961, -0.135547],  [0.0261821, 0.987036, -0.15835]));
[ 0.14139    0.989608    0.0261821 ]
[                                  ]
(%o1)                [ 0.153155  - 0.0479961  0.987036  ]
[                                  ]
[ 0.978035  - 0.135547   - 0.15835 ]
(%i2) RBTruth : transpose(matrix(  [0.494514, 0.150712, 0.856003],  [0.869109, -0.0974071, -0.484935],  [0.0102952, 0.983767, -0.179154]));
[ 0.494514   0.869109    0.0102952  ]
[                                   ]
(%o2)                [ 0.150712  - 0.0974071   0.983767  ]
[                                   ]
[ 0.856003  - 0.484935   - 0.179154 ]
(%i3) RCTruth : transpose(matrix(  [0.715119, 0.102426, 0.691458],  [0.698985, -0.111708, -0.706357],  [0.00489207, 0.988448, -0.151478]));
[ 0.715119   0.698985   0.00489207 ]
[                                  ]
(%o3)                [ 0.102426  - 0.111708   0.988448  ]
[                                  ]
[ 0.691458  - 0.706357  - 0.151478 ]
(%i4) RBATruth: RBTruth.transpose(RATruth);
[ 0.93026610368792    0.0441851822223   0.364216637447  ]
[                                                       ]
(%o4)      [ - 0.0493285897661  0.99877090188431   0.0048253466537 ]
[                                                       ]
[ - 0.3635559192534  - 0.0224553193255   0.93130141445  ]
(%i5) RCATruth: RCTruth.transpose(RATruth);
[ 0.79295990795595   0.08080414569102   0.6038914320855  ]
[                                                        ]
(%o5)     [ - 0.0701854739432   0.9966823624968   - 0.041202843614 ]
[                                                        ]
[ - 0.6052173035798  - 0.0097116080103   0.796001238609  ]
(%i6) CATruth : [-17.6081, -3.12802, 0.014307];
(%o6)                  [- 17.6081, - 3.12802, 0.014307]
(%i7) CBTruth : [-13.8177, 0.726613, 0.116081];
(%o7)                   [- 13.8177, 0.726613, 0.116081]
(%i8) CCTruth : [-9.37493, 4.36508, 0.0385902];
(%o8)              [- 9.374930000000001, 4.36508, 0.0385902]
(%i9) CBATruth : RATruth.(CBTruth - CATruth)/sqrt((CBTruth - CATruth).(CBTruth - CATruth) + (CCTruth - CATruth).(CCTruth - CATruth));
[ 0.35173957178448  ]
[                   ]
(%o9)                        [ 0.040074487584944 ]
[                   ]
[ 0.25602115297259  ]
(%i10) CCATruth : RATruth.(CCTruth - CATruth)/sqrt((CBTruth - CATruth).(CBTruth - CATruth) + (CCTruth - CATruth).(CCTruth - CATruth));
[ 0.69326796938661  ]
[                   ]
(%o10)                       [ 0.074763438063957 ]
[                   ]
[ 0.56825773653939  ]
(%i11) /* Sampson error minimization, three view, AAAA reprojection error, size AAAAA */RBA3vS: matrix(   [ 0.930574,     0.044258,     0.363420],   [-0.049365,     0.998769,     0.004772],   [-0.362761,    -0.022380,     0.931613]);
[  0.930574   0.044258   0.36342  ]
[                                 ]
(%o11)                [ - 0.049365  0.998769   0.004772 ]
[                                 ]
[ - 0.362761  - 0.02238  0.931613 ]
(%i12) RCA3vS: matrix(   [ 0.794717,     0.080914,     0.601563],   [-0.070063,     0.996679,    -0.041500],   [-0.602923,    -0.009167,     0.797747]);
[  0.794717    0.080914   0.601563 ]
[                                  ]
(%o12)               [ - 0.070063   0.996679   - 0.0415 ]
[                                  ]
[ - 0.602923  - 0.009167  0.797747 ]
(%i13) CBA3vS : [0.352468, 0.040149, 0.257571];
(%o13)                  [0.352468, 0.040149, 0.257571]
(%i14) CCA3vS : [0.692188, 0.073719, 0.568554];
(%o14)                  [0.692188, 0.073719, 0.568554]
(%i15) /* Nister thing followed by Hartley thing, 0.565793 reprojection error (seeed 8) */RBA2v5p: matrix(   [ 0.938405,     0.045844,     0.342481],   [-0.049203,     0.998788,     0.001121],   [-0.342015,    -0.017903,     0.939524]);
[  0.938405    0.045844   0.342481 ]
[                                  ]
(%o15)               [ - 0.049203   0.998788   0.001121 ]
[                                  ]
[ - 0.342015  - 0.017903  0.939524 ]
(%i16) RCA2v5p: matrix(   [ 0.795461,     0.081052,     0.600560],   [-0.070198,     0.996668,    -0.041532],   [-0.601925,    -0.009121,     0.798500]);
[  0.795461    0.081052    0.60056   ]
[                                    ]
(%o16)              [ - 0.070198   0.996668   - 0.041532 ]
[                                    ]
[ - 0.601925  - 0.009121    0.7985   ]
(%i17) CBA2v5p : [0.287014, 0.024628, 0.247539];
(%o17)                  [0.287014, 0.024628, 0.247539]
(%i18) CCA2v5p : [0.712015, 0.075615, 0.585711];
(%o18)                  [0.712015, 0.075615, 0.585711]
(%i19)    /* Rate that shit. */RotationDistance3D(A, B) := float(2*asin(mat_norm(ident(3) - A.transpose(B), frobenius)/(2*sqrt(2))));
(%o19) RotationDistance3D(A, B) := float(2
mat_norm(ident(3) - A . transpose(B), frobenius)
asin(------------------------------------------------))
2 sqrt(2)
(%i20) PositionDistance3D(A, B) := float(sqrt((A - B).(A - B)));
(%o20)    PositionDistance3D(A, B) := float(sqrt((A - B) . (A - B)))
(%i21) max(PositionDistance3D(CBA2v5p, CBATruth), PositionDistance3D(CCA2v5p, CCATruth));
(%o21)                         0.067081596139256
(%i22) max(RotationDistance3D(RBA2v5p, RBATruth), RotationDistance3D(RCA2v5p, RCATruth));
(%o22)                         0.023532597936046
(%i23) max(PositionDistance3D(CBA3vS, CBATruth), PositionDistance3D(CCA3vS, CCATruth));
(%o23)                        0.0017141136407848
(%i24) max(RotationDistance3D(RBA3vS, RBATruth), RotationDistance3D(RCA3vS, RCATruth));
(%o24)                        0.0029353424894702
(%i25) ```

### Related Help

Help for Mat_norm