Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/glue_cross_meat.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2010-2013 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 | |
10 //! \addtogroup glue_cross | |
11 //! @{ | |
12 | |
13 | |
14 | |
15 template<typename T1, typename T2> | |
16 inline | |
17 void | |
18 glue_cross::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_cross>& X) | |
19 { | |
20 arma_extra_debug_sigprint(); | |
21 | |
22 typedef typename T1::elem_type eT; | |
23 | |
24 const Proxy<T1> PA(X.A); | |
25 const Proxy<T2> PB(X.B); | |
26 | |
27 arma_debug_check( ((PA.get_n_elem() != 3) || (PB.get_n_elem() != 3)), "cross(): input vectors must have 3 elements" ); | |
28 | |
29 const uword PA_n_rows = Proxy<T1>::is_row ? 1 : PA.get_n_rows(); | |
30 const uword PA_n_cols = Proxy<T1>::is_col ? 1 : PA.get_n_cols(); | |
31 | |
32 out.set_size(PA_n_rows, PA_n_cols); | |
33 | |
34 eT* out_mem = out.memptr(); | |
35 | |
36 if( (Proxy<T1>::prefer_at_accessor == false) && (Proxy<T2>::prefer_at_accessor == false) ) | |
37 { | |
38 typename Proxy<T1>::ea_type A = PA.get_ea(); | |
39 typename Proxy<T2>::ea_type B = PB.get_ea(); | |
40 | |
41 const eT ax = A[0]; | |
42 const eT ay = A[1]; | |
43 const eT az = A[2]; | |
44 | |
45 const eT bx = B[0]; | |
46 const eT by = B[1]; | |
47 const eT bz = B[2]; | |
48 | |
49 out_mem[0] = ay*bz - az*by; | |
50 out_mem[1] = az*bx - ax*bz; | |
51 out_mem[2] = ax*by - ay*bx; | |
52 } | |
53 else | |
54 { | |
55 const bool PA_is_col = Proxy<T1>::is_col ? true : (PA_n_cols == 1); | |
56 const bool PB_is_col = Proxy<T2>::is_col ? true : (PB.get_n_cols() == 1); | |
57 | |
58 const eT ax = PA.at(0,0); | |
59 const eT ay = PA_is_col ? PA.at(1,0) : PA.at(0,1); | |
60 const eT az = PA_is_col ? PA.at(2,0) : PA.at(0,2); | |
61 | |
62 const eT bx = PB.at(0,0); | |
63 const eT by = PB_is_col ? PB.at(1,0) : PB.at(0,1); | |
64 const eT bz = PB_is_col ? PB.at(2,0) : PB.at(0,2); | |
65 | |
66 out_mem[0] = ay*bz - az*by; | |
67 out_mem[1] = az*bx - ax*bz; | |
68 out_mem[2] = ax*by - ay*bx; | |
69 } | |
70 } | |
71 | |
72 | |
73 | |
74 //! @} |