Loading...
Searching...
No Matches
juce_FloatVectorOperations.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
#ifndef JUCE_SNAP_TO_ZERO
#if JUCE_INTEL
#define JUCE_SNAP_TO_ZERO(n) if (! (n < -1.0e-8f || n > 1.0e-8f)) n = 0;
#else
#define JUCE_SNAP_TO_ZERO(n) ignoreUnused (n)
#endif
#endif
class ScopedNoDenormals;
//==============================================================================
template <typename FloatType, typename CountType>
struct FloatVectorOperationsBase
{
static void JUCE_CALLTYPE clear (FloatType* dest, CountType numValues) noexcept;
static void JUCE_CALLTYPE fill (FloatType* dest, FloatType valueToFill, CountType numValues) noexcept;
static void JUCE_CALLTYPE copy (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE copyWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
static void JUCE_CALLTYPE add (FloatType* dest, FloatType amountToAdd, CountType numValues) noexcept;
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, FloatType amount, CountType numValues) noexcept;
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE add (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE subtract (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
static void JUCE_CALLTYPE addWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType numValues) noexcept;
static void JUCE_CALLTYPE subtractWithMultiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType numValues) noexcept;
static void JUCE_CALLTYPE multiply (FloatType* dest, FloatType multiplier, CountType numValues) noexcept;
static void JUCE_CALLTYPE multiply (FloatType* dest, const FloatType* src, FloatType multiplier, CountType num) noexcept;
static void JUCE_CALLTYPE negate (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE abs (FloatType* dest, const FloatType* src, CountType numValues) noexcept;
static void JUCE_CALLTYPE min (FloatType* dest, const FloatType* src, FloatType comp, CountType num) noexcept;
static void JUCE_CALLTYPE min (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE max (FloatType* dest, const FloatType* src, FloatType comp, CountType num) noexcept;
static void JUCE_CALLTYPE max (FloatType* dest, const FloatType* src1, const FloatType* src2, CountType num) noexcept;
static void JUCE_CALLTYPE clip (FloatType* dest, const FloatType* src, FloatType low, FloatType high, CountType num) noexcept;
static Range<FloatType> JUCE_CALLTYPE findMinAndMax (const FloatType* src, CountType numValues) noexcept;
static FloatType JUCE_CALLTYPE findMinimum (const FloatType* src, CountType numValues) noexcept;
static FloatType JUCE_CALLTYPE findMaximum (const FloatType* src, CountType numValues) noexcept;
};
#if ! DOXYGEN
namespace detail
{
template <typename... Bases>
struct NameForwarder : public Bases...
{
using Bases::clear...,
Bases::fill...,
Bases::copy...,
Bases::copyWithMultiply...,
Bases::add...,
Bases::subtract...,
Bases::addWithMultiply...,
Bases::subtractWithMultiply...,
Bases::multiply...,
Bases::negate...,
Bases::abs...,
Bases::min...,
Bases::max...,
Bases::clip...,
Bases::findMinAndMax...,
Bases::findMinimum...,
Bases::findMaximum...;
};
} // namespace detail
#endif
//==============================================================================
class JUCE_API FloatVectorOperations : public detail::NameForwarder<FloatVectorOperationsBase<float, int>,
FloatVectorOperationsBase<float, size_t>,
FloatVectorOperationsBase<double, int>,
FloatVectorOperationsBase<double, size_t>>
{
public:
static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, int num) noexcept;
static void JUCE_CALLTYPE convertFixedToFloat (float* dest, const int* src, float multiplier, size_t num) noexcept;
static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
static void JUCE_CALLTYPE disableDenormalisedNumberSupport (bool shouldDisable = true) noexcept;
static bool JUCE_CALLTYPE areDenormalsDisabled() noexcept;
private:
friend ScopedNoDenormals;
static intptr_t JUCE_CALLTYPE getFpStatusRegister() noexcept;
static void JUCE_CALLTYPE setFpStatusRegister (intptr_t) noexcept;
};
//==============================================================================
class ScopedNoDenormals
{
public:
ScopedNoDenormals() noexcept;
~ScopedNoDenormals() noexcept;
private:
#if JUCE_USE_SSE_INTRINSICS || (JUCE_USE_ARM_NEON || (JUCE_64BIT && JUCE_ARM))
intptr_t fpsr;
#endif
};
} // namespace juce
juce::FloatVectorOperations
Definition juce_FloatVectorOperations.h:184
juce::FloatVectorOperations::disableDenormalisedNumberSupport
static void JUCE_CALLTYPE disableDenormalisedNumberSupport(bool shouldDisable=true) noexcept
Definition juce_FloatVectorOperations.cpp:1499
juce::FloatVectorOperations::enableFlushToZeroMode
static void JUCE_CALLTYPE enableFlushToZeroMode(bool shouldEnable) noexcept
Definition juce_FloatVectorOperations.cpp:1483
juce::FloatVectorOperations::areDenormalsDisabled
static bool JUCE_CALLTYPE areDenormalsDisabled() noexcept
Definition juce_FloatVectorOperations.cpp:1517
juce::Range
Definition juce_Range.h:40
juce::ScopedNoDenormals
Definition juce_FloatVectorOperations.h:219
juce::FloatVectorOperationsBase
Definition juce_FloatVectorOperations.h:55
juce::FloatVectorOperationsBase::add
static void JUCE_CALLTYPE add(FloatType *dest, FloatType amountToAdd, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1208
juce::FloatVectorOperationsBase::max
static void JUCE_CALLTYPE max(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1363
juce::FloatVectorOperationsBase::findMinimum
static FloatType JUCE_CALLTYPE findMinimum(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1398
juce::FloatVectorOperationsBase::multiply
static void JUCE_CALLTYPE multiply(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1295
juce::FloatVectorOperationsBase::clear
static void JUCE_CALLTYPE clear(FloatType *dest, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1176
juce::FloatVectorOperationsBase::addWithMultiply
static void JUCE_CALLTYPE addWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1259
juce::FloatVectorOperationsBase::findMinAndMax
static Range< FloatType > JUCE_CALLTYPE findMinAndMax(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1391
juce::FloatVectorOperationsBase::copy
static void JUCE_CALLTYPE copy(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1191
juce::FloatVectorOperationsBase::clip
static void JUCE_CALLTYPE clip(FloatType *dest, const FloatType *src, FloatType low, FloatType high, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1381
juce::FloatVectorOperationsBase::findMaximum
static FloatType JUCE_CALLTYPE findMaximum(const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1405
juce::FloatVectorOperationsBase::subtractWithMultiply
static void JUCE_CALLTYPE subtractWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1277
juce::FloatVectorOperationsBase::copyWithMultiply
static void JUCE_CALLTYPE copyWithMultiply(FloatType *dest, const FloatType *src, FloatType multiplier, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1199
juce::FloatVectorOperationsBase::fill
static void JUCE_CALLTYPE fill(FloatType *dest, FloatType valueToFill, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1183
juce::FloatVectorOperationsBase::subtract
static void JUCE_CALLTYPE subtract(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1242
juce::FloatVectorOperationsBase::abs
static void JUCE_CALLTYPE abs(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1337
juce::FloatVectorOperationsBase::negate
static void JUCE_CALLTYPE negate(FloatType *dest, const FloatType *src, CountType numValues) noexcept
Definition juce_FloatVectorOperations.cpp:1329
juce::FloatVectorOperationsBase::min
static void JUCE_CALLTYPE min(FloatType *dest, const FloatType *src, FloatType comp, CountType num) noexcept
Definition juce_FloatVectorOperations.cpp:1345