glue_cross_meat.hpp
Go to the documentation of this file.
00001 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
00002 // Copyright (C) 2010-2011 Conrad Sanderson
00003 // 
00004 // This file is part of the Armadillo C++ library.
00005 // It is provided without any warranty of fitness
00006 // for any purpose. You can redistribute this file
00007 // and/or modify it under the terms of the GNU
00008 // Lesser General Public License (LGPL) as published
00009 // by the Free Software Foundation, either version 3
00010 // of the License or (at your option) any later version.
00011 // (see http://www.opensource.org/licenses for more info)
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 


armadillo_matrix
Author(s): Conrad Sanderson - NICTA (www.nicta.com.au), (Wrapper by Sjoerd van den Dries)
autogenerated on Tue Jan 7 2014 11:42:04