POV-Ray : Newsgroups : povray.advanced-users : function optimization question Server Time
29 Jul 2024 22:27:22 EDT (-0400)
  function optimization question (Message 26 to 35 of 65)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Peter Popov
Subject: Re: function optimization question
Date: 17 Mar 2002 17:30:21
Message: <ft5a9uohspmhdva28oajq30ttitpgld9eb@4ax.com>
On 17 Mar 2002 16:28:29 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  I really don't see the problem here. If someone wants to make an infinite
>loop, then let them make one. It's not your headache.

Infinite loops have their uses. We're talking infinite recursion here,
and on less memory-protected systems a stack fault can cost more than
an interrupted render.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:49:53
Message: <4o9b9uk060bfb0orvu43ltcf2v6rsaamhp@4ax.com>
On Mon, 11 Mar 2002 03:17:07 -0500, "Slime" <noo### [at] hotmailcom> wrote:
>
> function{
>    f_noise3d(
>        x/(remember(1): sqrt(x^2+y^2+z^2)),
>        y/(recall:1),
>        z/(recall:1)
>    )
> }
>
> Where the 1 indicates that the remembered item labeled "1" should be
> recalled. The syntax I made up here is ugly, but is there any chance of this
> functionality appearing in the future?

It can appear tomorrow :-) if you just write:

 function{
    #local Function_With_One_Sqrt=function(x,y,z,sqrtxyz){
      f_noise3d(
          x/sqrtxyz,
          y/sqrtxyz,
          z/sqrtxyz
      )
    };
    Function_With_One_Sqrt(x,y,z,sqrt(x^2+y^2+z^2))
 }

The difference between your simple example and my case is very important.
While your subexpresssion is used three times in every function call, my
subexpression was used with apropriate condition in select(). I can't
precalculate it as subfunction with additional parameter becouse statisticaly
it is used only in 30% calls for example. Of course I can separate content of
select as sub function but it can slow down evaluation a lot when
subexpression is builded with hundreds of selects.

ABX


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:56:50
Message: <vgab9uk6h9gik1v2lr4qdata0advargi60@4ax.com>
On Sat, 16 Mar 2002 16:02:52 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...

Personally I think that internally functions are ready for recursions :-)
I've got message "Possible infinite recursive function call." some time.
I've also got message like "Reached maximum number of
recursion in functions". In both cases messages were produced as a result of
bug as I reported in povray.beta-test but the fact they are builded in POV-Ray
lead me to conclusion that recursion is a part of design :-)

ABX


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 18 Mar 2002 03:59:03
Message: <90bb9uou3kmgj2ld4rm2k0pbpg8rdnmdlk@4ax.com>
On 16 Mar 2002 14:21:26 -0500, Warp <war### [at] tagpovrayorg> wrote:
> It would just give a "max recursion depth limit reached" error.

I've got such a message in 3.5 as I reported.

ABX
--
disc{z,-z 5#macro O()asc(substr("-+((1*(,1,/.-,*/(,&.323/'1"e,1))*.1-4#declare
e=e-1;#end#local e=26;pigment{#local g=function(_){ceil(_)-_}function#local//X
k=function{pattern{object{sphere_sweep{linear_spline 13#while(e>0)<O(),O()//AB
>.01#end}}}}{k(g(atan2(x,y)),g(ln((y+x)^2+1e-5)),0)}}finish{ambient 1}}//POV35


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 10:30:40
Message: <slrna9emd1.ei2.ron.parker@fwi.com>

> On Sat, 16 Mar 2002 16:02:52 +0100, "Jan Walzer" <jan### [at] lzernet> wrote:
>> All we miss then yet is only iteration/recursion inside of these functions, and
they're turing-complete ...
> 
> Personally I think that internally functions are ready for recursions :-)
> I've got message "Possible infinite recursive function call." some time.
> I've also got message like "Reached maximum number of
> recursion in functions". In both cases messages were produced as a result of
> bug as I reported in povray.beta-test but the fact they are builded in POV-Ray
> lead me to conclusion that recursion is a part of design :-)

Loops, too.  They're just not part of the syntax.  The 3.5 beta has some
debugging features built in, though, so you can actually use them.  For 
example, here's a simple iterative factorial function:

#declare Fact=function(x) {"fact.out","fact.func" };

#debug concat(str(Fact(0),3,3), "\n")
#debug concat(str(Fact(1),3,3), "\n")
#debug concat(str(Fact(2),3,3), "\n")
#debug concat(str(Fact(3),3,3), "\n")
#debug concat(str(Fact(4),3,3), "\n")

and here are the contents of the file "fact.func":

grow    2
load    SP(0),r2
loadi   1,r0
cmpi    0,r2
ble     8
mul     r2,r0
subi    1, r2
jmp     3
rts

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 10:36:07
Message: <7ime9ukggvcv8thtubar3a94hadk998qn1@4ax.com>
On 19 Mar 2002 10:30:40 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> Loops, too.

Sounds great.

> They're just not part of the syntax.

Is this a bonus pack for patch writers or it will be boundled with Profesional
Edition ? ;-)

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 10:41:16
Message: <slrna9en0s.eie.ron.parker@fwi.com>

> On 19 Mar 2002 10:30:40 -0500, Ron Parker <ron### [at] povrayorg> wrote:
>> Loops, too.
> 
> Sounds great.
> 
>> They're just not part of the syntax.
> 
> Is this a bonus pack for patch writers or it will be boundled with Profesional
> Edition ? ;-)

What, assembly-language-like bytecode isn't good enough for you?  Kids these
days...

I think at the moment that it's a bonus pack for patch writers.  I don't know
what the Team's plans are WRT the debugging features, but you can probably
place large bets on the syntax not changing before 3.5.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From: Christoph Hormann
Subject: Re: function optimization question
Date: 19 Mar 2002 11:04:02
Message: <3C976170.93CD802F@gmx.de>
Ron Parker wrote:
> 
> [...]
> > Is this a bonus pack for patch writers or it will be boundled with Profesional
> > Edition ? ;-)
> 
> What, assembly-language-like bytecode isn't good enough for you?  Kids these
> days...
> 

;-)

Anyway it would be great if there was some kind of documentation for such
hidden features.  Not neccessarily in the user docs, but maybe included in
the source code package.

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 18 Mar. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From:
Subject: Re: function optimization question
Date: 19 Mar 2002 11:09:28
Message: <2foe9u0noelccpuqc58519jv8h45lk153b@4ax.com>
On 19 Mar 2002 10:41:16 -0500, Ron Parker <ron### [at] povrayorg> wrote:
> What, assembly-language-like bytecode isn't good enough for you?  Kids these
> days...

My asked for my daughter. She likes building functions in macros and render in
one pass ;-)

> I think at the moment that it's a bonus pack for patch writers.  I don't know
> what the Team's plans are WRT the debugging features

http://news.povray.org/3c2caae6@news.povray.org

> but you can probably
> place large bets on the syntax not changing before 3.5.

it's dream of many people I think

ABX


Post a reply to this message

From: Ron Parker
Subject: Re: function optimization question
Date: 19 Mar 2002 11:11:22
Message: <slrna9eopc.ejm.ron.parker@fwi.com>
On Tue, 19 Mar 2002 17:04:00 +0100, Christoph Hormann wrote:
> 
> 
> Ron Parker wrote:
>> 
>> [...]
>> > Is this a bonus pack for patch writers or it will be boundled with Profesional
>> > Edition ? ;-)
>> 
>> What, assembly-language-like bytecode isn't good enough for you?  Kids these
>> days...
>> 
> 
> ;-)
> 
> Anyway it would be great if there was some kind of documentation for such
> hidden features.  Not neccessarily in the user docs, but maybe included in
> the source code package.

There is no source code package yet, right?  And when there is, there will
be the same documentation I used to find this feature.

That documentation looks something like this:

    else if(Token.Token_Id == STRING_LITERAL_TOKEN)
        {
                FNCode_SetFlag(2, Token.Token_String);
                Get_Token();
                if(Token.Token_Id == COMMA_TOKEN)
                {
                        Get_Token();
                        if(Token.Token_Id != STRING_LITERAL_TOKEN)
                                Expectation_Error("valid function expression");
                        FNCode_SetFlag(1, Token.Token_String);
                }
                else
                {
                        Unget_Token();
                        expression = FNSyntax_ParseExpression();
                }
        }

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.