Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Qedo

#376
But where it is very useful in calculations of the type Bezier algorithm:
B(t)=(1-t)5P1 + 5t(1-t)4P2 + 10t2(1-t)3P3 + 10t3(1-t)2P4 + 5t4(1-t)P5+ t5P6
Ciao
#377
I forgot to add that the elevations should not be decimal.
3, 5, 6, -4, -6 yes
-3,5, 5.67   no
Ciao
#378
Right
Try this for negative elevations (not too complicated) :).   Is always faster
Obviously this program does not work for elevations greater than 0 and less than 1
Ciao

[attachment deleted by admin]
#379
Code Snippets / POW speed
2011-Sep-17
Don't use POW function  for value of power less or ugual to 40. It is very slow
Try this code
Ciao


[attachment deleted by admin]
#380
Thank you very much.
Excuse for the obvious question, but for me is not trivial the difference between
const char*** pArrayptr
and
DGInt** pArrayptr
I'm going to study  :)
Ciao
#381
Good example but it is possible have a example with integer and float array?
Thank you
Ciao
#382
I ask two things to those more experienced than me.
1) between GLB and C, in the float matrix multiplication benchmark, why there is a relationship in the rate of 5/1?   1400ms GLBasic and 300ms INLINE C. I think too high
2) Why the local arrays slow the program by 60%? LOCAL=2300ms against GLOBAL=1400ms.
To see this uncomment:
// LOCAL  a[]
// LOCAL  b[]
// LOCAL  c[]
Ciao

[attachment deleted by admin]
#383
It is  possible in GLBasic runs in parallel (multitasking?) two (or more) programs  and to share a common memory area?
I think it would be useful the use of pointers but is not possible in GLBasic
Perhaps using INLINE. Does anyone have any examples?
Ciao
#384
The program should be 8 years old
Surely with the use of integers should speed up but I was interested to see why it was so slow compared to the equivalent Blitz3D.
Blitz3D version also does not use the integer
Ciao
#385
In fact, with increasing zoom, the iterations of the loop increases to a maximum of Mmax (128)
Ciao
Code (glbasic) Select

WHILE (j < mMAX) AND (m < 4.0)
j=j+1
m = r * r - i * i
i = 2.0 * r * i + yval
r = m + xval
WEND
RETURN j / mMAX
#386
I found an old program of Mandelbrot written in  GlBasic and Blitx 3D and comparing the speed in pixels per second was disappointing:
150 Kpixel GLBasic  and 1000 Kpixel Blitx3D
I tried to understand why GlBasic was so slow and I found that the bottleneck was the command SETPIXEL.
I replaced it with the MEM2SPRITE and voila the program has jumped to 2000 Kpixel!!!
Great GLBasic  :good:
Ciao

[attachment deleted by admin]
#387
Kanonet,
for the negative angles you are right.

for the uselessness of the INTEGER() try this code:
the results are the same
ciao
Quote
x=759.1
LOCAL xx%
xx=x
DEBUG ( xx / 360 ) * 360 + CHR$(10)

x=759.1
xx=x
DEBUG INTEGER( xx / 360 ) * 360 + CHR$(10)
END


the code should be:
QuoteFUNCTION QQSIN: x   // by Kitty Hello, Qedo, Kanonet
   LOCAL xx%=x
   IF xx > 360
      DEC x, ( xx / 360 ) * 360
   ELSEIF  xx < 0
      INC x, ( 1 - xx / 360 ) * 360
   ENDIF

   IF x < 180
      x = ( 0.02222144652331750907567718514381 - 0.00012346049003081125437778164739108 * x )* x
      RETURN ( 0.775 + 0.225 *x ) * x
   ENDIF
   x = 180 - x
   x = ( 0.02222144652331750907567718514381 + 0.00012346049003081125437778164739108 * x ) * x
   RETURN ( 0.775 - 0.225 * x ) * x
ENDFUNCTION
#388
Kanonet, the float var controls the negative angles between -1 and 0.
The  integer xx truncated  to 0.
Also the two INTEGER() cast don't need because the whole operations are with integer variables

I like "// by Kitty Hello, Qedo, Kanonet"  :good:

ciao

Code (glbasic) Select
Qedo, you forgot one float, it should be:
Code: [Select]

FUNCTION QQSIN: x // by Kitty Hello, Qedo, Kanonet
LOCAL xx%=x
IF xx > 360
DEC x, INTEGER( xx / 360 ) * 360
ELSEIF  xx < 0
INC x, INTEGER( 1 - xx / 360 ) * 360
ENDIF
#389
The Ocean's code use a lookup table and take a value from a matrix.
It's the fastest.
Ciao
#390
in the Kanonet code eliminated the integer cast  (see code) Now >10% faster (on my computer)

Code (glbasic) Select

FUNCTION QQSIN1: x // Kanonet
LOCAL xx%
xx=x
IF xx >= 360
DEC x, ( xx / 360 ) * 360  // was DEC x, INTEGER( x / 360 ) * 360
ELSEIF  x < 0
INC x, ( 1 - xx / 360 ) * 360 // was INC x, INTEGER( 1 - x / 360 ) * 360
ENDIF

IF x < 180
x = ( 0.02222144652331750907567718514381 - 0.00012346049003081125437778164739108 * x )* x
RETURN ( 0.775 + 0.225 *x ) * x
ENDIF
x = 180 - x
x = ( 0.02222144652331750907567718514381 + 0.00012346049003081125437778164739108 * x ) * x
RETURN ( 0.775 - 0.225 * x ) * x
ENDFUNCTION


@Ocean
your code is very very fast (40% faster) congratulations.
Ingenious the & bAnd control in: return _cos_tbl_[ (int)(x * __d__) & __c__] ;
the other side of the coin is the increased use of memory of the lookup table.
Ciao