reb
Class REB_Newton_Switch

Object
  extended by common:Generic
      extended by common:Formula
          extended by reb:Switch
              extended by reb:REB_Newton_Switch

class 
Switch:REB_Newton_Switch



Ultra Fractal Source

Toggle UF Source Code Display

 class REB_Newton_Switch(Switch) {
 public:
   import "common.ulb"
 
   ; constructor
   func REB_Newton_Switch(Generic pparent)
      Switch.Switch(pparent)
      m_power = @p_power
      m_mand = @p_mand
      m_jul = @p_jul
      m_bailout = @p_upperbailout
      m_bailout2 = @p_lowerbailout
      m_c = @m_c
      m_test = @test
    endfunc
 
   ; initialize the formula
   complex func Init(complex pz)
     Switch.Init(pz)
     m_fz = 0
     m_fzp = 0
     m_fzp2 = 0
     m_pwrtest = 10^(100/cabs(m_power))
     m_bTest = false
     m_isnear = m_bailout2*cabs(@p2)^cabs(m_power)
     m_cz = 0
     return pz
   endfunc
 
   ; call for each iterated point
   complex func Iterate(complex pz)
     Switch.Iterate(pz)
     m_fz = pz^m_power - @p2
     m_fzp = m_power*pz^(m_power-1)
     m_fzp2 = m_power*(m_power-1)*pz^(m_power-2)
     if @converge == 0                          ; Newton
       pz = pz - m_fz/m_fzp
     elseif @converge == 1                      ; Householder
       pz = pz - m_fz/m_fzp*(1 + m_fz*m_fzp2/(2*m_fzp^2))
     elseif @converge == 2                      ; Halley
       pz = pz - 2*m_fz*m_fzp/(2*m_fzp^2 - m_fz*m_fzp2)
     elseif @converge == 3                      ; Schroder
       pz = pz - m_fz*m_fzp/(m_fzp^2 - m_fz*m_fzp2)
     elseif @converge == 4                      ; Ho custom
       pz = pz - m_fz/m_fzp*(1 + m_fz*m_fzp2/(@custom*m_fzp^2))
     elseif @converge == 5                      ; Ha custom
       pz = pz - 2*m_fz*m_fzp/(@custom*m_fzp^2 - m_fz*m_fzp2)
     elseif @converge == 6                      ; H_S custom
       pz = pz - @custom*m_fz*m_fzp/(@custom*m_fzp^2 - m_fz*m_fzp2)
     endif
     m_btest = (|m_zold-pz| < m_isnear)
     m_cz = |pz|
     return pz
   endfunc
 
   ; Override the default function for bailout
   bool func IsBailedOut(complex pz)
     return  !(!m_btest && (m_cz < m_pwrtest))
   endfunc
   
 private:
   complex m_fz
   complex m_fzp
   complex m_fzp2
   float m_pwrtest
   bool m_bTest
   float m_isnear
   float m_cz
   
   
 default:
   title = "Newton Switch"
   int param v_newtonswitch
     caption = "Version (Newton Switch)"
     default = 100
     hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
     visible = @v_Newtonswitch < 100
   endparam
   heading
     text = "This formula does not have Mandel like and Julia like forms, but when \
             used with formulas that do in a dual formula capacity, interesting \
             results can be obtained."
   endheading
   bool param p_mand
     caption = "Mandel Type"
     default = true
     visible = false
   endparam
   bool param p_jul
     caption = "Julia Type"
     default = false
     visible = false
   endparam
   complex param m_c
     caption = "Julia Seed"
     default = (0,0)
     visible = false
   endparam
   param test
     caption = "Bailout Test"
     default = 0
     enum = "mod" "real" "imag" "or" "and" "manh" "manr"
     hint = "mod is the standard bailout. The remaining bailout methods are \
             from Fractint."
   visible = false
   endparam
   float param p_upperbailout
     caption = "Bailout value (Divergent)"
     default = 1e10
     min = 1.0
     visible = false
   endparam
   float param p_lowerbailout
     caption = "Bailout value"
     default = 1e-12
   endparam
   param p_power
     caption = "Power"
     default = (3,0)
   endparam
   param p2
     caption = "Root"
     default = (1,0)
   endparam
   heading
     caption = "Convergence Methods"
   endheading
   param converge
     caption = "Convergence Method"
     default = 0
     enum = "Newton" "Householder" "Halley" "Schroder" "Ho Custom" \
            "Ha Custom" "H_S Custom"
   endparam
   float param custom
     caption = "H_S Constant"
     default = 1.5
     visible = @converge==4 || @converge==5  || @converge==6
   endparam
 }
 


Constructor Summary
REB_Newton_Switch()
           
REB_Newton_Switch(Generic pparent)
          constructor
 
Method Summary
 complex Init(complex pz)
          initialize the formula
 boolean IsBailedOut(complex pz)
          Override the default function for bailout
 complex Iterate(complex pz)
          call for each iterated point
 
Methods inherited from class reb:Switch
GetParams, SetParams
 
Methods inherited from class common:Formula
GetLowerBailout, GetPrimaryExponent, GetUpperBailout
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

REB_Newton_Switch

public REB_Newton_Switch(Generic pparent)
constructor


REB_Newton_Switch

public REB_Newton_Switch()
Method Detail

Init

public complex Init(complex pz)
initialize the formula

Overrides:
Init in class Switch
Parameters:
pz - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

Iterate

public complex Iterate(complex pz)
call for each iterated point

Overrides:
Iterate in class Switch
Parameters:
pz - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence

IsBailedOut

public boolean IsBailedOut(complex pz)
Override the default function for bailout

Overrides:
IsBailedOut in class Switch
Parameters:
pz - last sequence value to test; this should be the value returned from the previous Iterate() call. Note that it is acceptable to ignore pz and use m_BailedOut, but any code calling IsBailedOut() should pass in the correct pz for Formula classes which do not use m_BailedOut.
Returns:
true if the sequence has bailed out (i.e. should be terminated)