mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-31 13:50:35 +01:00
moved complex number helpers to complex.rsh
This commit is contained in:
parent
abf3df9d34
commit
6acb09a85e
30
app/src/main/rs/complex.rsh
Normal file
30
app/src/main/rs/complex.rsh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright 2014 Ahmet Inan <xdsopl@googlemail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
typedef float2 complex_t;
|
||||
static inline complex_t complex(float a, float b) { return (complex_t){ a, b }; }
|
||||
static inline float cabs(complex_t z) { return length(z); }
|
||||
static inline float carg(complex_t z) { return atan2(z[1], z[0]); }
|
||||
static inline complex_t cexp(complex_t z)
|
||||
{
|
||||
return complex(exp(z[0]) * cos(z[1]), exp(z[0]) * sin(z[1]));
|
||||
}
|
||||
static inline complex_t cmul(complex_t a, complex_t b)
|
||||
{
|
||||
return complex(a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]);
|
||||
}
|
||||
static inline complex_t conj(complex_t z) { return complex(z[0], -z[1]); }
|
||||
static inline complex_t cdiv(complex_t a, complex_t b) { return cmul(a, conj(b)) / dot(b, b); }
|
||||
|
|
@ -17,27 +17,14 @@ limitations under the License.
|
|||
#pragma version(1)
|
||||
#pragma rs java_package_name(xdsopl.robot36)
|
||||
|
||||
#include "complex.rsh"
|
||||
|
||||
short *audio_buffer;
|
||||
uchar *value_buffer;
|
||||
uchar4 *pixel_buffer;
|
||||
|
||||
static inline uchar4 rgb(uchar r, uchar g, uchar b) { return (uchar4){ b, g, r, 255 }; }
|
||||
|
||||
typedef float2 complex_t;
|
||||
static inline complex_t complex(float a, float b) { return (complex_t){ a, b }; }
|
||||
static inline float cabs(complex_t z) { return length(z); }
|
||||
static inline float carg(complex_t z) { return atan2(z[1], z[0]); }
|
||||
static inline complex_t cexp(complex_t z)
|
||||
{
|
||||
return complex(exp(z[0]) * cos(z[1]), exp(z[0]) * sin(z[1]));
|
||||
}
|
||||
static inline complex_t cmul(complex_t a, complex_t b)
|
||||
{
|
||||
return complex(a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]);
|
||||
}
|
||||
static inline complex_t conj(complex_t z) { return complex(z[0], -z[1]); }
|
||||
static inline complex_t cdiv(complex_t a, complex_t b) { return cmul(a, conj(b)) / dot(b, b); }
|
||||
|
||||
static float ema_a(float cutoff, float rate, int order)
|
||||
{
|
||||
float fc = cutoff / sqrt(rootn(2.0f, order) - 1.0f);
|
||||
|
|
|
|||
Loading…
Reference in a new issue