FloatVectorOperations Divide


#1

Can divide operations be added to this library?  I use these quite a bit and it would be nice if it were built in.

//in BasicOps32

static forcedinline ParallelType div (ParallelType a, ParallelType b) noexcept  { return _mm_div_ps (a, b); }

 

//in BasicOps64

static forcedinline ParallelType div (ParallelType a, ParallelType b) noexcept  { return _mm_div_pd (a, b); }

 

void JUCE_CALLTYPE FloatVectorOperations::copyWithDividend(float* dest, const float* src, float dividend, int num) noexcept 

    {

#if JUCE_USE_VDSP_FRAMEWORK

        vDSP_svdiv(&dividend, src, 1, dest, 1,  (vDSP_Length)num);
   
#else

        JUCE_PERFORM_VEC_OP_SRC_DEST(dest[i] = dividend / src[i], Mode::div(divsd,s),

        JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,

        const Mode::ParallelType divsd = Mode::load1(dividend);)

#endif

    }

 

void JUCE_CALLTYPE FloatVectorOperations::copyWithDivide (float* dest, const float* src, float divisor, int num) noexcept 

    {

#if JUCE_USE_VDSP_FRAMEWORK

        vDSP_vsdiv(src, 1, &divisor, dest, 1, (vDSP_Length)num);

#else

        JUCE_PERFORM_VEC_OP_SRC_DEST(dest[i] = src[i] / divisor, Mode::div( s,divs),

        JUCE_LOAD_SRC, JUCE_INCREMENT_SRC_DEST,

        const Mode::ParallelType divs = Mode::load1(divisor);)

#endif

}

 

void JUCE_CALLTYPE FloatVectorOperations::divide(float* dest, const float* src1, const float* src2, int num) noexcept 

    {

#if JUCE_USE_VDSP_FRAMEWORK

        vDSP_vdiv(src2,1,src1,1,dest,1, (vDSP_Length) num);

#else

        JUCE_PERFORM_VEC_OP_SRC1_SRC2_DEST(dest[i] = src2[i] / src1[i], Mode::div(s1, s2), JUCE_LOAD_SRC1_SRC2, JUCE_INCREMENT_SRC1_SRC2_DEST, )

#endif

    }

Thanks,

Darren

 

 


#2

Thanks - yes, we're planning on adding a lot more DSP functionality soon!


#3

bump… would really love to have an optimized buffer division in floatVectorOperations.


#4

+1
And optimized buffer trunc, modf please:
my post