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  */
53 
54 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
55 
56 #include "arm_helium_utils.h"
arm_quaternion_conjugate_f32(const float32_t * pInputQuaternions,float32_t * pConjugateQuaternions,uint32_t nbQuaternions)57 ARM_DSP_ATTRIBUTE void arm_quaternion_conjugate_f32(const float32_t *pInputQuaternions,
58     float32_t *pConjugateQuaternions,
59     uint32_t nbQuaternions)
60 {
61    f32x4_t vec1;
62 
63    for(uint32_t i=0; i < nbQuaternions; i++)
64    {
65       vec1 = vld1q(pInputQuaternions);
66 
67 
68       vec1 = vsetq_lane_f32(-vgetq_lane(vec1, 0),vec1,0);
69       vec1 = vnegq_f32(vec1);
70 
71       vst1q(pConjugateQuaternions, vec1);
72 
73 
74       pInputQuaternions   += 4;
75       pConjugateQuaternions += 4;
76    }
77 }
78 #else
arm_quaternion_conjugate_f32(const float32_t * pInputQuaternions,float32_t * pConjugateQuaternions,uint32_t nbQuaternions)79 ARM_DSP_ATTRIBUTE void arm_quaternion_conjugate_f32(const float32_t *pInputQuaternions,
80     float32_t *pConjugateQuaternions,
81     uint32_t nbQuaternions)
82 {
83    uint32_t i;
84    for(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