forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_e.c
More file actions
33 lines (32 loc) · 1.05 KB
/
log_e.c
File metadata and controls
33 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2021 Intel Corporation. All rights reserved.
//
// Author: Shriram Shastry <malladi.sastry@linux.intel.com>
//
//
#include <sof/math/log.h>
#include <sof/audio/format.h>
/**
* Base-e logarithm loge(x)
*
* loge = (u) computes the base-e logarithm of
* u using lookup table.
* input u must be scalar/real number and positive
*
* +------------------+-----------------+--------+--------+
* | inpfxp |loge (returntype)| inpfxp | loge |
* +----+-----+-------+----+----+-------+--------+--------+
* |WLen| FLen|Signbit|WLen|FLen|Signbit| Qformat| Qformat|
* +----+-----+-------+----+----+-------+--------+--------+
* | 32 | 0 | 0 | 32 | 27 | 0 | 32.0 | 5.27 |
* +------------------+-----------------+--------+--------+
*
* Arguments : uint32_t numerator [1 to 4294967295- Q32.0]
* Return Type : uint32_t UQ5.27 [ 0 to 22.1808076352]
*/
uint32_t ln_int32(uint32_t numerator)
{
return((uint32_t)Q_SHIFT_RND((int64_t)base2_logarithm(numerator) *
ONE_OVER_LOG2_E, 64, 32));
}