## reb Class REB_TentMap_Switch

```Object
common:Generic
common:Formula
reb:Switch
reb:REB_TentMap_Switch
```

`class Switch:REB_TentMap_Switch`

Ultra Fractal Source
``` class REB_TentMap_Switch(Switch) {
public:
import "common.ulb"

; constructor
func REB_TentMap_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
inv = (1e-10,1e-10)
endfunc

; initialize the formula
complex func Init(complex pz)
Switch.Init(pz)
if m_jul
complex z1 = pz
if @invert
pz = 1/(z1+inv)
endif
endif
if m_mand
m_c = pz
if @invert
pz = 1/(m_c+inv)
else
pz = m_c
endif
endif
if @flavor == "Flavor 1"
pz = @tentfn(pz)
endif
return pz
endfunc

; call for each iterated point
complex func Iterate(complex pz)
Switch.Iterate(pz)
if @flavor == "Flavor 2"
pz = @tentfn(pz)
endif
if @invert
if @type == "cabs"
if cabs(@tentfn2(pz)) <= @tent3
pz = @tent1*pz/(m_c+inv)
else
pz = @tent1*(@tent2-pz)/(m_c+inv)
endif
elseif @type == "real"
if real(@tentfn2(pz)) <= @tent3
pz = @tent1*pz/(m_c+inv)
else
pz = @tent1*(@tent2-pz)/(m_c+inv)
endif
elseif @type == "imag"
if imag(@tentfn2(pz)) <= @tent3
pz = @tent1*pz/(m_c+inv)
else
pz = @tent1*(@tent2-pz)/(m_c+inv)
endif
else
if imag(@tentfn2(pz)) > @tent3
pz = @tent1*(@tent2-pz)/(m_c+inv)
elseif real(@tentfn2(pz)) > @tent3
pz = @tent1*(@tent2-pz)/(m_c+inv)
else
pz = @tent1*pz/(m_c+inv)
endif
endif
else
if @type == "cabs"
if cabs(@tentfn2(pz)) <= @tent3
pz = @tent1*pz*m_c
else
pz = @tent1*(@tent2-pz)*m_c
endif
elseif @type == "real"
if real(@tentfn2(pz)) <= @tent3
pz = @tent1*pz*m_c
else
pz = @tent1*(@tent2-pz)*m_c
endif
elseif @type == "imag"
if imag(@tentfn2(pz)) <= @tent3
pz = @tent1*pz*m_c
else
pz = @tent1*(@tent2-pz)*m_c
endif
else
if imag(@tentfn2(pz)) > @tent3
pz = @tent1*(@tent2-pz)*m_c
elseif real(@tentfn2(pz)) > @tent3
pz = @tent1*(@tent2-pz)*m_c
else
pz = @tent1*pz*m_c
endif
endif
endif
return pz
endfunc

private:
complex inv

; Override the default function for bailout
bool func IsBailedOut(complex pz)
bool bail = false
if m_test == 0
bail = (|pz| > m_bailout)
elseif m_test == 1
bail = (sqr(real(pz)) > m_bailout)
elseif m_test == 2
bail = (sqr(imag(pz)) > m_bailout)
elseif m_test == 3
bail = (sqr(real(pz)) > m_bailout || sqr(imag(pz)) > m_bailout)
elseif m_test == 4
bail = (sqr(real(pz)) > m_bailout && sqr(imag(pz)) > m_bailout)
elseif m_test == 5
bail = (sqr(abs(real(pz)) + abs(imag(pz))) > m_bailout)
elseif m_test == 6
bail = (sqr(real(pz) + imag(pz)) > m_bailout)
endif
return bail
endfunc

default:
title = "TentMap Switch"
int param v_TentMapswitch
caption = "Version (TentMap 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_TentMapswitch < 100
endparam
text = "Based upon the Tent Map function:"
text = "   T(x) = s*x for x <= 0.5"
text = "   T(x) = s*(1-x) for x > 0.5"
text = "and the code for the Barnsley type fractals."
param type
caption = "Tent type"
default = 3
enum = "cabs" "real" "imag" "Pinsky"
endparam
param flavor
caption = "Flavor"
default = 0
enum = "Flavor 1" "Flavor 2"
endparam
bool param invert
caption = "Inversion"
default = false
endparam
float param tent1
caption ="Tent param #1"
default = 1
endparam
float param tent2
caption ="Tent param #2"
default = 1
endparam
float param tent3
caption ="Tent param #3"
default = 0.5
endparam
func tentfn
caption = "Tent function"
default = ident()
endfunc
func tentfn2
caption = "Tent function #2"
default = ident()
endfunc
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."
endparam
float param p_upperbailout
caption = "Bailout value (Divergent)"
default = 1e10
min = 1.0
endparam
float param p_lowerbailout
caption = "Bailout value"
default = 1e-10
visible = false
endparam
complex param p_power ; Overrides p_power from Formula
caption = "Power"
default = (2,0)
visible = false
endparam
}
```

Constructor Summary
`REB_TentMap_Switch()`

`REB_TentMap_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_TentMap_Switch

`public REB_TentMap_Switch(Generic pparent)`
constructor

### REB_TentMap_Switch

`public REB_TentMap_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)