core/vnl/vnl_det.txx
Go to the documentation of this file.
00001 // This is core/vnl/vnl_det.txx
00002 #ifndef vnl_det_txx_
00003 #define vnl_det_txx_
00004 
00005 #include "vnl_det.h"
00006 
00007 template <class T>
00008 T vnl_det(T const *row0, T const *row1)
00009 {
00010   return row0[0]*row1[1] - row0[1]*row1[0];
00011 }
00012 
00013 template <class T>
00014 T vnl_det(T const *row0, T const *row1, T const *row2)
00015 {
00016   return // the extra '+' makes it work nicely with emacs indentation.
00017     + row0[0]*row1[1]*row2[2]
00018     - row0[0]*row2[1]*row1[2]
00019     - row1[0]*row0[1]*row2[2]
00020     + row1[0]*row2[1]*row0[2]
00021     + row2[0]*row0[1]*row1[2]
00022     - row2[0]*row1[1]*row0[2];
00023 }
00024 
00025 template <class T>
00026 T vnl_det(T const *row0, T const *row1, T const *row2, T const *row3)
00027 {
00028   return
00029     + row0[0]*row1[1]*row2[2]*row3[3]
00030     - row0[0]*row1[1]*row3[2]*row2[3]
00031     - row0[0]*row2[1]*row1[2]*row3[3]
00032     + row0[0]*row2[1]*row3[2]*row1[3]
00033     + row0[0]*row3[1]*row1[2]*row2[3]
00034     - row0[0]*row3[1]*row2[2]*row1[3]
00035     - row1[0]*row0[1]*row2[2]*row3[3]
00036     + row1[0]*row0[1]*row3[2]*row2[3]
00037     + row1[0]*row2[1]*row0[2]*row3[3]
00038     - row1[0]*row2[1]*row3[2]*row0[3]
00039     - row1[0]*row3[1]*row0[2]*row2[3]
00040     + row1[0]*row3[1]*row2[2]*row0[3]
00041     + row2[0]*row0[1]*row1[2]*row3[3]
00042     - row2[0]*row0[1]*row3[2]*row1[3]
00043     - row2[0]*row1[1]*row0[2]*row3[3]
00044     + row2[0]*row1[1]*row3[2]*row0[3]
00045     + row2[0]*row3[1]*row0[2]*row1[3]
00046     - row2[0]*row3[1]*row1[2]*row0[3]
00047     - row3[0]*row0[1]*row1[2]*row2[3]
00048     + row3[0]*row0[1]*row2[2]*row1[3]
00049     + row3[0]*row1[1]*row0[2]*row2[3]
00050     - row3[0]*row1[1]*row2[2]*row0[3]
00051     - row3[0]*row2[1]*row0[2]*row1[3]
00052     + row3[0]*row2[1]*row1[2]*row0[3];
00053 }
00054 
00055 //--------------------------------------------------------------------------------
00056 
00057 #define VNL_DET_INSTANTIATE(T) \
00058 template T vnl_det(T const *, T const *); \
00059 template T vnl_det(T const *, T const *, T const *); \
00060 template T vnl_det(T const *, T const *, T const *, T const *)
00061 
00062 #endif // vnl_det_txx_