44 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<1,2> &A) {
45 arma::mat::fixed<1,1> res;
46 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1);
50 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<2,1> &A) {
51 arma::mat::fixed<1,1> res;
52 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0);
56 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<1,3> &A) {
57 arma::mat::fixed<1,1> res;
58 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1)+A(0,2)*A(0,2);
62 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<3,1> &A) {
63 arma::mat::fixed<1,1> res;
64 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0)+A(2,0)*A(2,0);
68 inline arma::mat::fixed<2,2>
normal_matrix(
const arma::mat::fixed<2,3> &A) {
69 arma::mat::fixed<2,2> res;
70 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1)+A(0,2)*A(0,2);
71 res(0,1) = A(0,0)*A(1,0)+A(0,1)*A(1,1)+A(0,2)*A(1,2);
72 res(1,0) = A(1,0)*A(0,0)+A(1,1)*A(0,1)+A(1,2)*A(0,2);
73 res(1,1) = A(1,0)*A(1,0)+A(1,1)*A(1,1)+A(1,2)*A(1,2);
77 inline arma::mat::fixed<2,2>
normal_matrix(
const arma::mat::fixed<3,2> &A) {
78 arma::mat::fixed<2,2> res;
79 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0)+A(2,0)*A(2,0);
80 res(0,1) = A(0,0)*A(0,1)+A(1,0)*A(1,1)+A(2,0)*A(2,1);
81 res(1,0) = A(0,1)*A(0,0)+A(1,1)*A(1,0)+A(2,1)*A(2,0);
82 res(1,1) = A(0,1)*A(0,1)+A(1,1)*A(1,1)+A(2,1)*A(2,1);
88 template<>
inline double determinant(
const arma::mat::fixed<1,1> &M)
93 template<>
inline double determinant(
const arma::mat::fixed<2,2> &M)
95 return M(0,0)*M(1,1) - M(1,0)*M(0,1);
98 template<>
inline double determinant(
const arma::mat::fixed<3,3> &M)
100 return ( M(0,0)*M(1,1)*M(2,2) + M(0,1)*M(1,2)*M(2,0) + M(0,2)*M(1,0)*M(2,1) )
101 - ( M(2,0)*M(1,1)*M(0,2) + M(2,1)*M(1,2)*M(0,0) + M(2,2)*M(1,0)*M(0,1) );
114 template<>
inline double determinant(
const arma::mat::fixed<1,2> &M)
119 template<>
inline double determinant(
const arma::mat::fixed<2,1> &M)
124 template<>
inline double determinant(
const arma::mat::fixed<1,3> &M)
129 template<>
inline double determinant(
const arma::mat::fixed<3,1> &M)
134 template<>
inline double determinant(
const arma::mat::fixed<2,3> &M)
139 template<>
inline double determinant(
const arma::mat::fixed<3,2> &M)
148 template<arma::uword m, arma::uword n>
149 arma::mat::fixed<n,m>
inverse(
const arma::mat::fixed<m,n> &A) {
155 template<>
inline arma::mat::fixed<1,1>
inverse(
const arma::mat::fixed<1,1> &A)
157 arma::mat::fixed<1,1> B;
162 template<>
inline arma::mat::fixed<2,2>
inverse(
const arma::mat::fixed<2,2> &A)
164 arma::mat::fixed<2,2> B;
167 B(0,0) = A(1,1) / det;
168 B(0,1) = -A(0,1) / det;
169 B(1,0) = -A(1,0) / det;
170 B(1,1) = A(0,0) / det;
174 template<>
inline arma::mat::fixed<3,3>
inverse(
const arma::mat::fixed<3,3> &A)
176 arma::mat::fixed<3,3> B;
178 B(0,0) = A(1,1)*A(2,2) - A(2,1)*A(1,2);
179 B(1,0) = -A(1,0)*A(2,2) + A(2,0)*A(1,2);
180 B(2,0) = A(1,0)*A(2,1) - A(2,0)*A(1,1);
182 double det = A(0,0)*B(0,0) + A(0,1)*B(1,0) + A(0,2)*B(2,0);
183 B(0,0)/=det; B(1,0)/=det; B(2,0)/=det;
185 B(0,1) = (-A(0,1)*A(2,2) + A(2,1)*A(0,2)) / det;
186 B(1,1) = (A(0,0)*A(2,2) - A(2,0)*A(0,2)) / det;
187 B(2,1) = (-A(0,0)*A(2,1) + A(2,0)*A(0,1)) / det;
189 B(0,2) = (A(0,1)*A(1,2) - A(1,1)*A(0,2)) / det;
190 B(1,2) = (-A(0,0)*A(1,2) + A(1,0)*A(0,2)) / det;
191 B(2,2) = (A(0,0)*A(1,1) - A(1,0)*A(0,1)) / det;