CGR Localization
 All Classes Namespaces Files Functions Variables Macros Pages
gvector.cpp
Go to the documentation of this file.
1 //========================================================================
2 // This software is free: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License Version 3,
4 // as published by the Free Software Foundation.
5 //
6 // This software is distributed in the hope that it will be useful,
7 // but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 // GNU Lesser General Public License for more details.
10 //
11 // You should have received a copy of the GNU Lesser General Public License
12 // Version 3 in the file COPYING that came with this distribution.
13 // If not, see <http://www.gnu.org/licenses/>.
14 //========================================================================
20 //========================================================================
21 
22 #include "gvector.h"
23 
24 namespace GVector {
25 
26 #ifdef GVECTOR_SSE_OPTIMIZATIONS
27 template <> vector3d<float> vector3d<float>::transform(const matrix3d<float> &M) const
28 {
29  float _x, _y, _z;
30  __m128 v1, v2, rx, ry, rz;
31 
32  v1 = _mm_load_ps(&coefficients[0]);
33  v2 = _mm_load_ps(&M.elements[0]);
34  rx = _mm_dp_ps(v1,v2,0xF1);
35 
36 
37  v1 = _mm_load_ps(&coefficients[0]);
38  v2 = _mm_load_ps(&M.elements[4]);
39  ry = _mm_dp_ps(v1,v2,0xF1);
40 
41  v1 = _mm_load_ps(&coefficients[0]);
42  v2 = _mm_load_ps(&M.elements[8]);
43  rz = _mm_dp_ps(v1,v2,0xF1);
44 
45  _mm_store_ss(&_x,rx);
46  _mm_store_ss(&_y,ry);
47  _mm_store_ss(&_z,rz);
48 
50  q.set(_x,_y,_z);
51  return q;
52 }
53 
54 template <> float vector3d<float>::sqlength() const
55 {
56  return sse_dot_product<float>(coefficients,coefficients,0x71);
57 }
58 
59 template <> float vector3d<float>::dot(const vector3d<float> p) const
60 {
61  return sse_dot_product<float>(coefficients,p.coefficients,0x71);
62 }
63 
64 #endif
65 
66 };