Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

SQRT optimization

DSP related issues, mathematics, processing and techniques

SQRT optimization

Postby Rocko » Tue Nov 19, 2019 11:28 am

Hey there,

I got to a point in which I need to use a function:
Y = sqrt(x)
in which X is limited between [1:0].

Can this be optimized, by avoiding sqrt and instead using taylor/maclaurin approximations?
I guess those would reach 3rd order (to reach satsifactory precision) and some multiplications and additions. Is that really better than using the original sqrt function ?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: SQRT optimization

Postby martinvicanek » Tue Nov 19, 2019 10:07 pm

There is not much to optimize: the sqrt function is as fast as a division, which is about four multiplies.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: SQRT optimization

Postby steph_tsf » Thu Feb 20, 2020 1:25 pm

I am attaching a .fsm, aiming at showing the state of the art. Kind of zoo. This goes beyond the SQRT optimization. It also covers the lin2db and db2lin functions. Please let me know if there is something missing. By the way, inside the .fsm, there is a question about the way one is raising audio to the 2nd power. Have a nice day.
RMS detector square root lin2db db2lin.fsm
(8.75 KiB) Downloaded 1413 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: SQRT optimization

Postby trogluddite » Thu Feb 20, 2020 6:10 pm

steph_tsf wrote:...question about the way one is raising audio to the 2nd power

The max is irrelevant to the power function. It is just obtaining whichever stereo channel has the greater absolute magnitude (assuming that left/right are packed into the first two SSE channels).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: SQRT optimization

Postby martinvicanek » Thu Feb 20, 2020 7:17 pm

To use the x^a power function for a square root is indeed "sub-optimal". Better use sqrt (code) or sqrtps (ASM).
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: SQRT optimization

Postby steph_tsf » Fri Feb 21, 2020 1:13 am

http://www.dsprobotics.com/support/viewtopic.php?f=2&t=37876&start=20
I've read the trogluddite post, confirming that "sqrtps" is full precision. Good news.
Contrary to "rsqrtps" (the reciprocal of it), that's limited to approximately 11-bits of precision ("half-precision").
Time to edit the RMS detector canvas, thus. One thus need to rely on the "sqrtps" instruction, just before the output.
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: SQRT optimization

Postby steph_tsf » Fri Feb 21, 2020 3:27 pm

I am attaching a .fsm and a .jpg, for asking what's the specification of the sqrt(x) function that's supported by Flowstone 3.0.4. The .fsm shows that the the sqrt(x) DSP Code Component function doesn't deliver the square root of the input. Have a nice day.
sqrt(x) function for audio.fsm
(12.09 KiB) Downloaded 1359 times

DSP Code Component (650 pix).jpg
DSP Code Component (650 pix).jpg (99.48 KiB) Viewed 22951 times
Last edited by steph_tsf on Sat Feb 22, 2020 1:28 am, edited 2 times in total.
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: SQRT optimization

Postby deraudrl » Fri Feb 21, 2020 5:05 pm

steph_tsf wrote:**** Sorry, the board attachment quota has been reached. *****

Is such quota, a weekly limitation? When will I be able to attach the .fsm and .jpg?
Given that we've had three users hit the limit in the last two days, I'm starting to think the "limit" is global, not per-user.
I keep a pair of oven mitts next to my computer so I don't get a concussion from slapping my forehead while I'm reading the responses to my questions.
deraudrl
 
Posts: 239
Joined: Thu Nov 28, 2019 9:12 pm
Location: SoCal

Re: SQRT optimization

Postby trogluddite » Sat Feb 22, 2020 12:06 am

steph_tsf wrote:Is such quota, a weekly limitation? When will I be able to attach the .fsm and .jpg?

deraudrl wrote:Given that we've had three users hit the limit in the last two days, I'm starting to think the "limit" is global, not per-user.

In all my years moderating, I've still never worked out what the hell the algorithm is for it - there seem to be post-count, per-user, and global elements. I would have thought that having been here so long, I would have had it happen to me many times before, but it never has, even when we've had flurries like this one (I now have the horrible feeling that I've probably just jinxed myself! :shock: )

I also can't help wondering whether all the damned spammers aren't helping. Spogg and I can only ban them, which stops them from logging back in, but it doesn't delete their NSFW animated-GIF avatars etc. (q.v. the way that they still show in the "birthdays" list). The amount of junk on the server doesn't bear thinking about, given that we sometimes ban dozens in a single day.

In the mean-time, the only advice we can offer is to send an email to support@dsprobotics.com reporting that you can no longer upload, and hope for the best - Malc doesn't seem to check the account all that often, but he usually does fix it once he knows.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: SQRT optimization

Postby steph_tsf » Sat Feb 22, 2020 1:38 am

trogluddite wrote:the only advice we can offer is to send an email to support@dsprobotics.com reporting that you can no longer upload, and hope for the best

Without doing anything, without sending an email, I am again allowed to attach files. The attachments are now on my post, above. The sqrt(x) doesn't deliver what one is expecting. There must me something obvious like an offset, or some rescaling. Can you please tell?
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Next

Return to DSP

Who is online

Users browsing this forum: No registered users and 64 guests