Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00017
00018
00019
00020 template<typename T1, typename T2>
00021 inline
00022 void
00023 glue_cross::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_cross>& X)
00024 {
00025 arma_extra_debug_sigprint();
00026
00027 typedef typename T1::elem_type eT;
00028 typedef typename Proxy<T1>::ea_type ea_type1;
00029 typedef typename Proxy<T2>::ea_type ea_type2;
00030
00031 const Proxy<T1> A(X.A);
00032 const Proxy<T2> B(X.B);
00033
00034 arma_debug_check( ((A.get_n_elem() != 3) || (B.get_n_elem() != 3)), "cross(): input vectors must have 3 elements" );
00035
00036 out.set_size(A.get_n_rows(), A.get_n_cols());
00037
00038 eT* out_mem = out.memptr();
00039 ea_type1 PA = A.get_ea();
00040 ea_type2 PB = B.get_ea();
00041
00042 const eT ax = PA[0];
00043 const eT ay = PA[1];
00044 const eT az = PA[2];
00045
00046 const eT bx = PB[0];
00047 const eT by = PB[1];
00048 const eT bz = PB[2];
00049
00050 out_mem[0] = ay*bz - az*by;
00051 out_mem[1] = az*bx - ax*bz;
00052 out_mem[2] = ax*by - ay*bx;
00053 }
00054
00055
00056