new QSIN (QQSIN)

Previous topic - Next topic

Qedo

new QSIN (QQSIN).
on my computer (notebook):
QQSIN = 230 ms
QSIN   = 580 ms
SIN GLBasic= 1150 ms
Wait your time


[attachment deleted by admin]

bigsofty

Really well optimised!  :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

ampos

I use:

Code (glbasic) Select
dim qsin[359];for x=0 to 359;qsin[x]=sin[x];next
sinn=qsin[angle]


Can you add this to your code for testing speed?
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Qedo


M_QSIN (ampos code) = 380 ms
QQSIN = 230 ms
QSIN   = 580 ms
SIN GLBasic= 1150 ms
Wait your time

[attachment deleted by admin]

Kitty Hello

Can I use that for distribution with the new SDK? Awesome work!

dreamerman

Don't forget about 'Lookup-table based SIN' by Ocean: http://www.glbasic.com/forum/index.php?topic=2855.msg20951#msg20951

on my pc:
m_qsin (Ampos) -> 564ms
Sin GlBasic -> 1772ms
QQSin -> 488ms
QSin -> 996ms
tSin (Ocean) -> 538ms

QQSin isn't so precise as tSin but for most calculations it would be ok..
Good job :]
Check my source code editor for GLBasic - link Update: 20.04.2020

Qedo


feel free to use it   :)

Kitty Hello

About accuracy: Draw a circle to test:

Code (glbasic) Select


function cirl: x,y,R
for phi=0 to 360 step 0.1
    setpixel x+qsin(phi)*R, y+qsin(90+phi)*R, 0xffffff // sin(90+phi) = cos(phi)
next
endfunction


kanonet

On my machine the original SIN(x) is the fastest...
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

matchy

#9
Cool function! QQSIN is fastest and draws a circle fine. It seems GLB SIN is faster only in debug.

My results (Win7):
(Debub OFF)
Code (glbasic) Select

Time for 15300000 loops
M_QSIN time: 262.7019786 ms
SIN GLBasic time: 818.1101458 ms
new QQSIN time: 154.9435493 ms    ***
old QSIN time: 326.0813655 ms


(Debug ON)
Code (glbasic) Select

Time for 15300000 loops
M_QSIN time: 1819.38153 ms
SIN GLBasic time: 1046.089785 ms   ***
new QQSIN time: 2216.111983 ms
old QSIN time: 2206.459872 ms



kanonet

Oh you are right, it was in debug mode... in release mode QQSIN is the fastest.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Wampus

Only just tried this now. Great going. :)

BdR

from the first project file..
Quote// Start: Thursday, March 15, 2007
You've been holding this back for all this time? Anyway, pretty impressive math stuff, and I didn't know GLBasic can handle floating points of 35 decimals. I tried the updated QQSIN1.zip sources and here are my measurements:

desktop pc/windows, Pentium 4 CPU 3.20GHz
Code (glbasic) Select
time for 15300000 loops

M_QSIN time: 460.5181186 ms
last value SIN GLBasic =  0.7071067812

SIN GLBasic time: 1469.167289 ms
last value SIN GLBasic =  0.7071067812

new QQSIN time: 360.3170347 ms
last value new QQSIN =  0.7077865858

old QSIN time: 838.0197293 ms
last alue old QSIN =  0.7077653318

SIN GLBasic value -60.1 deg. =  -0.8668967489
SIN GLBasic value 60.2 deg. =  0.8677654534
SIN GLBasic value 289.3 deg. =  -0.9438009516

new QQSIN value -60.1 deg. =  -0.875032347
new QQSIN value 60.2 deg. =  0.8683695847
new QQSIN value 289.3 deg. =  -0.9441067712

And also tried it on my ipod, which is sloooooow in comparison
iPod 4th generation 8gb
Code (glbasic) Select
time for 15300000 loops

M_QSIN time: 5265.441406ms
last value SIN GLBasic =  .7071067691

SIN GLBasic time: 7395.682617ms
last value SIN GLBasic =  .7071067691

new QQSIN time: 5005.396484 ms
last value new QQSIN =  .7077865005

old QSIN time: 9279.095703ms
last alue old QSIN =  .7077654004

SIN GLBasic value -60.1 deg. =  -.8668967485
SIN GLBasic value 60.2 deg. =  .8677654862
SIN GLBasic value 289.3 deg. =  -.9438010454

new QQSIN value -60.1 deg. =  -.8675031066
new QQSIN value 60.2 deg. =  .8683695793
new QQSIN value 289.3 deg. =  -.9441066384

Slydog

Wow, amazing function!
So, calculating the value each time is faster than a lookup table?  Wouldn't have guessed that!
Interesting calculation, how did you figure that out?

Is there an equivalent COS function?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Qedo

FUNCTION QQCOS: x
   RETURN QQSIN(x+90)
ENDFUNCTION

Ciao