Author Topic: new QSIN (QQSIN)  (Read 14156 times)

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 167
  • UNUS SED LEO
    • View Profile
new QSIN (QQSIN)
« on: 2011-Jun-09 »
new QSIN (QQSIN).
on my computer (notebook):
QQSIN = 230 ms
QSIN   = 580 ms
SIN GLBasic= 1150 ms
Wait your time


[attachment deleted by admin]

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2628
    • View Profile
Re: new QSIN (QQSIN)
« Reply #1 on: 2011-Jun-09 »
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)

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: new QSIN (QQSIN)
« Reply #2 on: 2011-Jun-09 »
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

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 167
  • UNUS SED LEO
    • View Profile
Re: new QSIN (QQSIN)
« Reply #3 on: 2011-Jun-09 »

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

[attachment deleted by admin]

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10714
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: new QSIN (QQSIN)
« Reply #4 on: 2011-Jun-09 »
Can I use that for distribution with the new SDK? Awesome work!

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 288
    • View Profile
    • my personal website
Re: new QSIN (QQSIN)
« Reply #5 on: 2011-Jun-09 »
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

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 167
  • UNUS SED LEO
    • View Profile
Re: new QSIN (QQSIN)
« Reply #6 on: 2011-Jun-09 »

feel free to use it   :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10714
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: new QSIN (QQSIN)
« Reply #7 on: 2011-Jun-10 »
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

 

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: new QSIN (QQSIN)
« Reply #8 on: 2011-Jun-10 »
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

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
Re: new QSIN (QQSIN)
« Reply #9 on: 2011-Jun-10 »
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
 

« Last Edit: 2011-Jun-10 by matchy »

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: new QSIN (QQSIN)
« Reply #10 on: 2011-Jun-10 »
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

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Re: new QSIN (QQSIN)
« Reply #11 on: 2011-Jun-12 »
Only just tried this now. Great going. :)

Offline BdR

  • Dr. Type
  • ****
  • Posts: 303
    • View Profile
    • BdR Games
Re: new QSIN (QQSIN)
« Reply #12 on: 2011-Aug-04 »
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

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: new QSIN (QQSIN)
« Reply #13 on: 2011-Aug-05 »
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]

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 167
  • UNUS SED LEO
    • View Profile
Re: new QSIN (QQSIN)
« Reply #14 on: 2011-Aug-05 »
FUNCTION QQCOS: x
   RETURN QQSIN(x+90)
ENDFUNCTION

Ciao