1
2 /* ----------------------------------------------------------------------
3 * Project: CMSIS DSP Library
4 * Title: arm_russellrao_distance.c
5 * Description: Russell-Rao distance between two vectors
6 *
7 *
8 * Target Processor: Cortex-M cores
9 * -------------------------------------------------------------------- */
10 /*
11 * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
12 *
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the License); you may
16 * not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
23 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 */
27
28 #include "arm_math.h"
29 #include <limits.h>
30 #include <math.h>
31
32
33
34 extern void arm_boolean_distance_TT(const uint32_t *pA
35 , const uint32_t *pB
36 , uint32_t numberOfBools
37 , uint32_t *cTT
38 );
39
40
41 /**
42 @addtogroup BoolDist
43 @{
44 */
45
46 /**
47 * @brief Russell-Rao distance between two vectors
48 *
49 * @param[in] pA First vector of packed booleans
50 * @param[in] pB Second vector of packed booleans
51 * @param[in] numberOfBools Number of booleans
52 * @return distance
53 *
54 */
55
arm_russellrao_distance(const uint32_t * pA,const uint32_t * pB,uint32_t numberOfBools)56 float32_t arm_russellrao_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools)
57 {
58 uint32_t ctt=0;
59
60
61 arm_boolean_distance_TT(pA, pB, numberOfBools, &ctt);
62
63
64 return(1.0*(numberOfBools - ctt) / ((float32_t)numberOfBools));
65 }
66
67
68 /**
69 * @} end of BoolDist group
70 */
71