162 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<1,2> &A) {
163 arma::mat::fixed<1,1> res;
164 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1);
168 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<2,1> &A) {
169 arma::mat::fixed<1,1> res;
170 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0);
174 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<1,3> &A) {
175 arma::mat::fixed<1,1> res;
176 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1)+A(0,2)*A(0,2);
180 inline arma::mat::fixed<1,1>
normal_matrix(
const arma::mat::fixed<3,1> &A) {
181 arma::mat::fixed<1,1> res;
182 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0)+A(2,0)*A(2,0);
186 inline arma::mat::fixed<2,2>
normal_matrix(
const arma::mat::fixed<2,3> &A) {
187 arma::mat::fixed<2,2> res;
188 res(0,0) = A(0,0)*A(0,0)+A(0,1)*A(0,1)+A(0,2)*A(0,2);
189 res(0,1) = A(0,0)*A(1,0)+A(0,1)*A(1,1)+A(0,2)*A(1,2);
190 res(1,0) = A(1,0)*A(0,0)+A(1,1)*A(0,1)+A(1,2)*A(0,2);
191 res(1,1) = A(1,0)*A(1,0)+A(1,1)*A(1,1)+A(1,2)*A(1,2);
195 inline arma::mat::fixed<2,2>
normal_matrix(
const arma::mat::fixed<3,2> &A) {
196 arma::mat::fixed<2,2> res;
197 res(0,0) = A(0,0)*A(0,0)+A(1,0)*A(1,0)+A(2,0)*A(2,0);
198 res(0,1) = A(0,0)*A(0,1)+A(1,0)*A(1,1)+A(2,0)*A(2,1);
199 res(1,0) = A(0,1)*A(0,0)+A(1,1)*A(1,0)+A(2,1)*A(2,0);
200 res(1,1) = A(0,1)*A(0,1)+A(1,1)*A(1,1)+A(2,1)*A(2,1);
206 template<>
inline double determinant(
const arma::mat::fixed<1,1> &M)
211 template<>
inline double determinant(
const arma::mat::fixed<2,2> &M)
213 return M(0,0)*M(1,1) - M(1,0)*M(0,1);
216 template<>
inline double determinant(
const arma::mat::fixed<3,3> &M)
218 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) )
219 - ( 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) );
232 template<>
inline double determinant(
const arma::mat::fixed<1,2> &M)
237 template<>
inline double determinant(
const arma::mat::fixed<2,1> &M)
242 template<>
inline double determinant(
const arma::mat::fixed<1,3> &M)
247 template<>
inline double determinant(
const arma::mat::fixed<3,1> &M)
252 template<>
inline double determinant(
const arma::mat::fixed<2,3> &M)
257 template<>
inline double determinant(
const arma::mat::fixed<3,2> &M)
266 template<arma::uword m, arma::uword n>
267 arma::mat::fixed<n,m>
inverse(
const arma::mat::fixed<m,n> &A) {
273 template<>
inline arma::mat::fixed<1,1>
inverse(
const arma::mat::fixed<1,1> &A)
275 arma::mat::fixed<1,1> B;
280 template<>
inline arma::mat::fixed<2,2>
inverse(
const arma::mat::fixed<2,2> &A)
282 arma::mat::fixed<2,2> B;
285 B(0,0) = A(1,1) / det;
286 B(0,1) = -A(0,1) / det;
287 B(1,0) = -A(1,0) / det;
288 B(1,1) = A(0,0) / det;
292 template<>
inline arma::mat::fixed<3,3>
inverse(
const arma::mat::fixed<3,3> &A)
294 arma::mat::fixed<3,3> B;
296 B(0,0) = A(1,1)*A(2,2) - A(2,1)*A(1,2);
297 B(1,0) = -A(1,0)*A(2,2) + A(2,0)*A(1,2);
298 B(2,0) = A(1,0)*A(2,1) - A(2,0)*A(1,1);
300 double det = A(0,0)*B(0,0) + A(0,1)*B(1,0) + A(0,2)*B(2,0);
301 B(0,0)/=det; B(1,0)/=det; B(2,0)/=det;
303 B(0,1) = (-A(0,1)*A(2,2) + A(2,1)*A(0,2)) / det;
304 B(1,1) = (A(0,0)*A(2,2) - A(2,0)*A(0,2)) / det;
305 B(2,1) = (-A(0,0)*A(2,1) + A(2,0)*A(0,1)) / det;
307 B(0,2) = (A(0,1)*A(1,2) - A(1,1)*A(0,2)) / det;
308 B(1,2) = (-A(0,0)*A(1,2) + A(1,0)*A(0,2)) / det;
309 B(2,2) = (A(0,0)*A(1,1) - A(1,0)*A(0,1)) / det;