Skip to content

Commit

Permalink
Merge pull request #157 from ckormanyos/simplify_discovery
Browse files Browse the repository at this point in the history
Simplifying Discovery syntax
  • Loading branch information
ckormanyos authored Sep 14, 2024
2 parents 97f4974 + 01b4bf0 commit 2e7b6f0
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 286 deletions.
Binary file modified MandelbrotDiscovery/MandelbrotDiscovery.rc
Binary file not shown.
3 changes: 2 additions & 1 deletion MandelbrotDiscovery/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
auto dx_half() const noexcept -> value_type { return my_dx_half; }
auto dy_half() const noexcept -> value_type { return my_dy_half; }

auto center() const noexcept -> point_type { return my_center; }
auto center() const noexcept -> const point_type& { return my_center; }
auto center() noexcept -> point_type& { return my_center; }

auto recenter(const point_type& new_center) noexcept -> void
{
Expand Down
16 changes: 4 additions & 12 deletions MandelbrotDiscovery/mandelbrot_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ namespace local
static constexpr char str_mandelbrot_point_center_y[] = "+0.00";
} // namespace local

//static_assert(local::mandelbrot_calculation_pixels_x == local::mandelbrot_calculation_pixels_y,
// "Error: This program is only compilable for square geometry");

//static_assert(util::utility::equal(local::mandelbrot_point_dx_half(),
// local::mandelbrot_point_dx_half() + util::utility::strlen(local::cfg_type_0::mandelbrot_point_dx_half()),
// local::mandelbrot_point_dy_half()),
// "Error: This program is only compilable for square geometry");

template<const unsigned Digits10> auto dx_half () -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_dx_half }; }
template<const unsigned Digits10> auto dy_half () -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_dy_half }; }
template<const unsigned Digits10> auto center_x() -> typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type { using local_coord_pnt_type = typename local::cfg_type<Digits10>::mandelbrot_coord_pnt_type; return local_coord_pnt_type { local::str_mandelbrot_point_center_x }; }
Expand All @@ -62,10 +54,10 @@ using rectangle_ref_01_type = typename std::tuple_element<0x01, rectangle_tuple
using rectangle_ref_02_type = typename std::tuple_element<0x02, rectangle_tuple_type>::type;
using rectangle_ref_03_type = typename std::tuple_element<0x03, rectangle_tuple_type>::type;

using point_00_type = typename rectangle_00_type::point_type;
using point_01_type = typename rectangle_01_type::point_type;
using point_02_type = typename rectangle_02_type::point_type;
using point_03_type = typename rectangle_03_type::point_type;
using point_00_type = typename rectangle_00_type::point_type;
using point_01_type = typename rectangle_01_type::point_type;
using point_02_type = typename rectangle_02_type::point_type;
using point_03_type = typename rectangle_03_type::point_type;

using local_window_type = mandelbrot_discovery<static_cast<int>(INT16_C(800)),
static_cast<int>(INT16_C(800)),
Expand Down
331 changes: 87 additions & 244 deletions MandelbrotDiscovery/mandelbrot_discovery.h

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions MandelbrotDiscovery/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ The result of this dive ended up being:

![](https://github.com/ckormanyos/mandelbrot/blob/main/images/discovery/mandelbrot_discovery_dive_example.jpg)

## Additional Program Dynamic Behavior

The following features (and probably a few more) are TODO both in docs as well as in the program.

### Changing the Resolution

This feature is TODO both in docs as well as in the program.

### Saving and Restoring Previous Work

These features are TODO both in docs as well as in the program.

## Program Defaults and Dynamic Behavior

This feature is TODO both in docs as well as in the program.
15 changes: 4 additions & 11 deletions MandelbrotDiscovery/resource.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MandelbrotDiscovery.rc
//
#define IDI_MANDELBROT_DISCO 101

#ifndef RESOURCE_2024_08_28_H
#define RESOURCE_2024_08_28_H

#define IDI_MANDELBROT_DISCO 101

#endif // RESOURCE_2024_08_28_H
29 changes: 15 additions & 14 deletions mandelbrot/mandelbrot_generator_perturbative.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,25 @@
)
};

{
// Initialize the Zk-Components of the central point.
// Assumption: The max iterations is reached.

{
zkr.front() = static_cast<my_iteration_numeric_type>(UINT8_C(0));
zki.front() = static_cast<my_iteration_numeric_type>(UINT8_C(0));

my_coord_pnt_numeric_type zr { static_cast<my_coord_pnt_numeric_type>(UINT8_C(0)) };
my_coord_pnt_numeric_type zi { static_cast<my_coord_pnt_numeric_type>(UINT8_C(0)) };
my_coord_pnt_numeric_type zr2 { static_cast<my_coord_pnt_numeric_type>(UINT8_C(0)) };
my_coord_pnt_numeric_type zi2 { static_cast<my_coord_pnt_numeric_type>(UINT8_C(0)) };

my_coord_pnt_numeric_type zr { static_cast<unsigned>(UINT8_C(0)) };
my_coord_pnt_numeric_type zi { static_cast<unsigned>(UINT8_C(0)) };
my_coord_pnt_numeric_type zr2 { static_cast<unsigned>(UINT8_C(0)) };
my_coord_pnt_numeric_type zi2 { static_cast<unsigned>(UINT8_C(0)) };

auto iteration_result = static_cast<std::uint_fast32_t>(UINT8_C(0));

// Perform the iteration sequence for generating the Mandelbrot set.
// Use a perturbative iteration scheme.
// Here is the main work of the program.

while ((iteration_result < base_class_type::get_iterations()) && ((zr2 + zi2) < base_class_type::four_coord_pnt())) // NOLINT(altera-id-dependent-backward-branch)
{
// The inner loop performs optimized complex multiply and add.
// This is the main work of the fractal iteration scheme.

zi *= zr;

zi += (zi + y_center);
Expand Down Expand Up @@ -204,13 +203,16 @@
// The core functionality of the original formula is:
// z_{k+1} = z_{k}^2 + C

// -> delta transformation z_{k+1} -> z_{k+1} + e_{k+1}; z_{k} -> z_{k} + e_{k}; C -> c + d;
// -> delta transformation:
// z_{k+1} -> z_{k+1} + e_{k+1}; z_{k} -> z_{k} + e_{k},
// with C -> c + d;

// Get it in to the formula we end with:
// Insert this into to the above-mentioned equation(s).
// The result is:
// z_{k+1} + e_{k+1} = z_{k}^2 + c + e_{k}^2 + 2*z_{k}*e_{k} + d

// This replaces the original formula, resulting in:
// e_{k+1} = e_{k}^2 + 2*z_{k}*e_{k} + d
// e_{k+1} = e_{k}^2 + 2*z_{k}*e_{k} + d,
// where z_{k} is the pre-calculated value.

ei *= (er + zkr_temp);
Expand All @@ -226,7 +228,6 @@

zei = ei;
zei *= (zki_temp * static_cast<unsigned>(UINT8_C(2))) + ei;
//2*er *t + er *er = er * (2*t + er)

quad_length = (zer + (zkr_temp * zkr_temp)) + (zei + (zki_temp * zki_temp));

Expand Down

0 comments on commit 2e7b6f0

Please sign in to comment.