1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_quaternion_conjugate_f32.c
4 * Description: Floating-point quaternion conjugate
5 *
6 * $Date: 23 April 2021
7 * $Revision: V1.9.0
8 *
9 * Target Processor: Cortex-M and Cortex-A cores
10 * -------------------------------------------------------------------- */
11 /*
12 * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29 #include "dsp/quaternion_math_functions.h"
30 #include <math.h>
31
32 /**
33 @ingroup groupQuaternionMath
34 */
35
36 /**
37 @defgroup QuatConjugate Quaternion Conjugate
38
39 Compute the conjugate of a quaternion.
40 */
41
42 /**
43 @addtogroup QuatConjugate
44 @{
45 */
46
47 /**
48 @brief Floating-point quaternion conjugates.
49 @param[in] pInputQuaternions points to the input vector of quaternions
50 @param[out] pConjugateQuaternions points to the output vector of conjugate quaternions
51 @param[in] nbQuaternions number of quaternions in each vector
52 @return none
53 */
54
55 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
56
57 #include "arm_helium_utils.h"
arm_quaternion_conjugate_f32(const float32_t * pInputQuaternions,float32_t * pConjugateQuaternions,uint32_t nbQuaternions)58 void arm_quaternion_conjugate_f32(const float32_t *pInputQuaternions,
59 float32_t *pConjugateQuaternions,
60 uint32_t nbQuaternions)
61 {
62 f32x4_t vec1;
63
64 for(uint32_t i=0; i < nbQuaternions; i++)
65 {
66 vec1 = vld1q(pInputQuaternions);
67
68
69 vec1 = vsetq_lane_f32(-vgetq_lane(vec1, 0),vec1,0);
70 vec1 = vnegq_f32(vec1);
71
72 vst1q(pConjugateQuaternions, vec1);
73
74
75 pInputQuaternions += 4;
76 pConjugateQuaternions += 4;
77 }
78 }
79 #else
arm_quaternion_conjugate_f32(const float32_t * pInputQuaternions,float32_t * pConjugateQuaternions,uint32_t nbQuaternions)80 void arm_quaternion_conjugate_f32(const float32_t *pInputQuaternions,
81 float32_t *pConjugateQuaternions,
82 uint32_t nbQuaternions)
83 {
84 for(uint32_t i=0; i < nbQuaternions; i++)
85 {
86
87 pConjugateQuaternions[4 * i + 0] = pInputQuaternions[4 * i + 0];
88 pConjugateQuaternions[4 * i + 1] = -pInputQuaternions[4 * i + 1];
89 pConjugateQuaternions[4 * i + 2] = -pInputQuaternions[4 * i + 2];
90 pConjugateQuaternions[4 * i + 3] = -pInputQuaternions[4 * i + 3];
91 }
92 }
93 #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
94
95 /**
96 @} end of QuatConjugate group
97 */
98