1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 2 дек. 2019 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef DSP_ARCH_NATIVE_PMATH_POW_H_
23 #define DSP_ARCH_NATIVE_PMATH_POW_H_
24 
25 #ifndef __DSP_NATIVE_IMPL
26     #error "This header should not be included directly"
27 #endif /* __DSP_NATIVE_IMPL */
28 
29 namespace native
30 {
powcv1(float * v,float c,size_t count)31     void powcv1(float *v, float c, size_t count)
32     {
33         float C = ::logf(c);
34         for (size_t i=0; i<count; ++i)
35             v[i] = ::expf(v[i] * C);
36     }
37 
powcv2(float * dst,const float * v,float c,size_t count)38     void powcv2(float *dst, const float *v, float c, size_t count)
39     {
40         float C = ::logf(c);
41         for (size_t i=0; i<count; ++i)
42             dst[i] = ::expf(v[i] * C);
43     }
44 
powvc1(float * c,float v,size_t count)45     void powvc1(float *c, float v, size_t count)
46     {
47         for (size_t i=0; i<count; ++i)
48             c[i] = ::expf(v * ::logf(c[i]));
49     }
50 
powvc2(float * dst,const float * c,float v,size_t count)51     void powvc2(float *dst, const float *c, float v, size_t count)
52     {
53         for (size_t i=0; i<count; ++i)
54             dst[i] = ::expf(v * ::logf(c[i]));
55     }
56 
powvx1(float * v,const float * x,size_t count)57     void powvx1(float *v, const float *x, size_t count)
58     {
59         for (size_t i=0; i<count; ++i)
60             v[i] = ::expf(x[i] * ::logf(v[i]));
61     }
62 
powvx2(float * dst,const float * v,const float * x,size_t count)63     void powvx2(float *dst, const float *v, const float *x, size_t count)
64     {
65         for (size_t i=0; i<count; ++i)
66             dst[i] = ::expf(x[i] * ::logf(v[i]));
67     }
68 }
69 
70 #endif /* DSP_ARCH_NATIVE_PMATH_POW_H_ */
71