lygia
/v1.1.6
/math
/gaussian
)gaussian coeficient
Use:
<vec4|vec3|vec2|float> gaussian(<float> sigma, <vec4|vec3|vec2|float> d)
#ifndef FNC_GAUSSIAN
#define FNC_GAUSSIAN
float gaussian(float d, float s) { return exp(-(d*d) / (2.0 * s*s)); }
float gaussian( vec2 d, float s) { return exp(-( d.x*d.x + d.y*d.y) / (2.0 * s*s)); }
float gaussian( vec3 d, float s) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z ) / (2.0 * s*s)); }
float gaussian( vec4 d, float s) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z + d.w*d.w ) / (2.0 * s*s)); }
#endif
Use:
<float4|float3|float2|float> gaussian(<float4|float3|float2|float> d, <float> sigma)
#ifndef FNC_GAUSSIAN
#define FNC_GAUSSIAN
inline float gaussian(float d, float sigma) { return exp(-(d * d) / (2.0 * sigma * sigma)); }
inline float gaussian(float2 d, float sigma) { return exp(-(d.x * d.x + d.y * d.y) / (2.0 * sigma * sigma)); }
inline float gaussian(float3 d, float sigma) { return exp(-(d.x * d.x + d.y * d.y + d.z * d.z) / (2.0 * sigma * sigma)); }
inline float gaussian(float4 d, float sigma)
{
return exp(-(d.x * d.x + d.y * d.y + d.z * d.z + d.w * d.w) / (2.0 * sigma * sigma));
}
#endif
fn gaussian( d: f32, sigma: f32) -> f32 {
return exp(-(d*d) / (2.0 * sigma * sigma));
}
fn gaussian2(d: vec2<f32>, sigma: f32) -> f32 {
return exp(-(d.x*d.x + d.y*d.y) / (2.0 * sigma * sigma));
}
fn gaussian3(d: vec3<f32>, sigma: f32) -> f32 {
return exp(-(d.x*d.x + d.y*d.y + d.z*d.z) / (2.0 * sigma * sigma));
}
fn gaussian4(d: vec4<f32>, sigma: f32) -> f32 {
return exp(-(d.x*d.x + d.y*d.y + d.z*d.z + d.w*d.w) / (2.0 * sigma * sigma));
}
Dependencies:
lygia
/v1.1.6
/math
/cuda_runtime
.glsl
Use:
<float4|float3|float2|float> gaussian(<float> sigma, <float4|float3|float2|float> d)
#ifndef FNC_GAUSSIAN
#define FNC_GAUSSIAN
inline __host__ __device__ float gaussian( float d, float sigma) { return exp(-(d*d) / (2.0f * sigma*sigma)); }
inline __host__ __device__ float gaussian(const float2& d, float sigma) { return exp(-( d.x*d.x + d.y*d.y) / (2.0f * sigma*sigma)); }
inline __host__ __device__ float gaussian(const float3& d, float sigma) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z ) / (2.0f * sigma*sigma)); }
inline __host__ __device__ float gaussian(const float4& d, float sigma) { return exp(-( d.x*d.x + d.y*d.y + d.z*d.z + d.w*d.w ) / (2.0f * sigma*sigma)); }
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository