glue_cross_meat.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2010-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
14 
17 
18 
19 
20 template<typename T1, typename T2>
21 inline
22 void
24  {
26 
27  typedef typename T1::elem_type eT;
28  typedef typename Proxy<T1>::ea_type ea_type1;
29  typedef typename Proxy<T2>::ea_type ea_type2;
30 
31  const Proxy<T1> A(X.A);
32  const Proxy<T2> B(X.B);
33 
34  arma_debug_check( ((A.get_n_elem() != 3) || (B.get_n_elem() != 3)), "cross(): input vectors must have 3 elements" );
35 
36  out.set_size(A.get_n_rows(), A.get_n_cols());
37 
38  eT* out_mem = out.memptr();
39  ea_type1 PA = A.get_ea();
40  ea_type2 PB = B.get_ea();
41 
42  const eT ax = PA[0];
43  const eT ay = PA[1];
44  const eT az = PA[2];
45 
46  const eT bx = PB[0];
47  const eT by = PB[1];
48  const eT bz = PB[2];
49 
50  out_mem[0] = ay*bz - az*by;
51  out_mem[1] = az*bx - ax*bz;
52  out_mem[2] = ax*by - ay*bx;
53  }
54 
55 
56 
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
Definition: Mat_meat.hpp:4024
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
Definition: Mat_meat.hpp:4211
#define arma_debug_check
Definition: debug.hpp:1084
const T1 & A
first operand
Definition: Glue_bones.hpp:44
const T2 & B
second operand
Definition: Glue_bones.hpp:45
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
Dense matrix class.
static void apply(Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_cross > &X)


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57