mandelbrot | multicore implementation of the mandelbrot fractal | Game Engine library

 by   tvcutsem Java Version: Current License: MIT

kandi X-RAY | mandelbrot Summary

kandi X-RAY | mandelbrot Summary

mandelbrot is a Java library typically used in Gaming, Game Engine applications. mandelbrot has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. However mandelbrot build file is not available. You can download it from GitHub.

Renders the famous Mandelbrot fractal in parallel using multiple CPU cores, using the java.util.concurrent Fork/Join framework. This code was originally written as part of my university course on Multicore Programming to show students a textbook example of an "embarrasingly parallel" computation that can be nicely sped up using the Fork/Join abstraction.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              mandelbrot has a low active ecosystem.
              It has 5 star(s) with 3 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              mandelbrot has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of mandelbrot is current.

            kandi-Quality Quality

              mandelbrot has 0 bugs and 0 code smells.

            kandi-Security Security

              mandelbrot has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              mandelbrot code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              mandelbrot is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              mandelbrot releases are not available. You will need to build from source code and install.
              mandelbrot has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              It has 144 lines of code, 8 functions and 1 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed mandelbrot and discovered the below as its top functions. This is intended to give you an instant insight into mandelbrot implemented functionality, and help decide if they suit your requirements.
            • Draws a polyline
            • Draw a rectangular outline of the grid
            • Entry point for the program
            • Convert an array of pixels to a BufferedImage
            • Paints the message
            Get all kandi verified functions for this library.

            mandelbrot Key Features

            No Key Features are available at this moment for mandelbrot.

            mandelbrot Examples and Code Snippets

            Compute the mandelbrot .
            pythondot img1Lines of Code : 20dot img1License : Non-SPDX
            copy iconCopy
            def compute_mandelbrot(N_max, some_threshold, nx, ny):
                # A grid of c-values
                x = np.linspace(-2, 1, nx)
                y = np.linspace(-1.5, 1.5, ny)
            
                c = x[:,newaxis] + 1j*y[newaxis,:]
            
                # Mandelbrot iteration
            
                z = c
            
                # The code below ove  
            Compute mandelbrot set
            pythondot img2Lines of Code : 16dot img2License : Non-SPDX
            copy iconCopy
            def compute_mandelbrot(N_max, some_threshold, nx, ny):
                # A grid of c-values
                x = np.linspace(-2, 1, nx)
                y = np.linspace(-1.5, 1.5, ny)
            
                c = x[:,newaxis] + 1j*y[newaxis,:]
            
                # Mandelbrot iteration
            
                z = c
                for j in range(N_max)  

            Community Discussions

            QUESTION

            Why is the output different with Python 2.7 than Python 3.10?
            Asked 2022-Mar-25 at 16:50
            $ /usr/bin/python2 simple.py 200 > out2.pbm
            $ /opt/src/Python-3.10.1/bin/python3 simple.py 200 > out3.pbm
            $ cmp out2.pbm out3.pbm
            out2.pbm out3.pbm differ: byte 304, line 3
            
            ...

            ANSWER

            Answered 2022-Mar-25 at 16:50

            I can't run this under Python 3.10.1 (Windows, 64-bit):

            Source https://stackoverflow.com/questions/71609086

            QUESTION

            Why are labels in BASIC increments of 10?
            Asked 2022-Mar-05 at 19:03

            In BASIC, tags are in increments of 10. For example, mandlebrot.bas from github/linguist:

            ...

            ANSWER

            Answered 2022-Mar-05 at 19:03

            The short answer is that BASIC numbering is in increments of one, but programmers can and do skip some of the increments. BASIC grew out of Fortran, which also used numeric labels, and often used increments of 10. Unlike Fortran, early BASIC required numbering all lines, so that they changed from labels to line numbers.

            BASIC is numbered in increments greater than one to allow adding new lines between existing lines.

            1. Most early home computer BASIC implementations did not have a built-in means of renumbering lines.
            2. Code execution in BASIC implementations with line numbers happened in order of line number.

            This meant that if you wanted to add new lines, you needed to leave numbers free between those lines. Even on computers with a RENUM implementation, renumbering could take time. So if you wanted standard increments you’d still usually only RENUM at the end of a session or when you thought you were mostly finished.

            Speculation: Programmers use increments of 10 specifically for BASIC line numbers for at least two reasons. First, tradition. Fortran code from the era appears to use increments of 10 for its labels when it uses any standard increments at all. Second, appearance. On the smaller screens of the era it is easier to see where BASIC lines start if they all end in the same symbol, and zero is a very useful symbol for that purpose. Speaking from personal experience, I followed the spotty tradition of starting different routines on hundreds boundaries and thousands boundaries to take advantage of the multiple zeroes at the beginning of the line. This made it easier to recognize the starts of those routines later when reading through the code.

            BASIC grew from Fortran, which also used numbers, but as labels. Fortran lines only required a label if they needed to be referred to, such as with a GO TO, to know where a loop can be exited, or as a FORMAT for a WRITE. Such lines were also often in increments greater than 1—and commonly also 10—so as to allow space to add more in between if necessary. This wasn’t technically necessary. Since they were labels and not line numbers, they didn’t need to be sequential. But most programmers made them sequential for readability.

            In his commonly-used Fortran 77 tutorial, Erik Boman writes:

            Typically, there will be many loops and other statements in a single program that require a statement label. The programmer is responsible for assigning a unique number to each label in each program (or subprogram). The numerical value of statement labels have no significance, so any integer numbers can be used. Typically, most programmers increment labels by 10 at a time.

            BASIC required that all lines have numbers and that the line numbers be sequential; that was part of the purpose of having line numbers: a BASIC program could be entered out of order. This allowed for later edits. Thus, line 15 could be added after lines 10 and 20 had been added. This made leaving potential line numbers between existing line numbers even more useful.

            If you look at magazines with BASIC program listings, such as Rainbow Magazine or Creative Computing, you’ll often see numbers sandwiched somewhat randomly between the tens. And depending on style, many people used one less than the line number at the start of a routine or subroutine to comment the routine. Routines and DATA sections might also start on even hundreds or even thousands.

            Programmers who used conventions like this might not even want to renumber a program, as it would mess up their conventions. BASIC programs were often a mass of text; any convention that improved readability was savored.

            Ten was a generally accepted spacing even before the home computer era. In his basic basic, second edition (1978, and expecting that the user would be using “a remote terminal”), James S. Coan writes (page 2):

            It is conventional although not required to use intervals of 10 for the numbers of adjacent lines in a program. This is because any modification in the program must also have line numbers. So you can use the in-between numbers for that purpose. It should be comforting to know at this point that the line numbers do not have to be typed in order. No matter what order they are typed in, the computer will follow the numerical order in executing the program.

            There are examples of similar patterns in Coan’s Basic Fortran. For example, page 46 has a simple program to “search for pythagorean triples”; while the first label is 12, the remaining labels are 20, 30, and 40, respectively.

            He used similar patterns without increments of 10; for example, on page 132 of Basic Fortran, Coan uses increments of 2 for his labels, and keeps the calculation section of the program in the hundreds with the display section of the program in the two hundreds. The END statement uses label 9900.

            Similarly, in their 1982 Elementary BASIC, Henry Ledgard and Andrew Singer write (page 27):

            Depending on the version of Basic you are using, a line number can consist of 1 to 4 or 5 digits. Here, all line numbers will consist of 4 digits, a common practice accepted by almost every version of Basic. The line numbers must be in sequential order. Increasing line numbers are often given in increments of 10, a convention we will also follow. This convention allows you to make small changes to a program without changing all the line numbers.

            And Jerald R. Brown’s 1982 Instant BASIC: 2nd Astounding Edition (p. 7):

            You don’t have to enter or type in a program in line number order. That is, you don’t have to enter line 10 first, then line 20, and then line 30. If we type in a program out of line number order, the computer doesn’t care. It follows the line numbers not the order they were entered or typed in. This makes it easy to insert more statements in a program already stored in the computer’s memory. You may have noticed how we cleverly number the statements in our programs by 10's. This makes it easy to add more statements between the existing line numbers -- up to nine more statements between lines 10 and 20, for example.

            Much of the choice of how to number lines in a BASIC program was based on tradition and a vague sense of what worked. This was especially true in the home computer era where most users didn’t take classes on how to use BASIC but rather learned by reading other people’s programs, typing them in from the many books and magazines that provided program listings. The tradition of incrementing by 10 and inserting new features between those increments was an obvious one.

            You can see it scanning through old books of code, such as 101 BASIC Computer Games. The very first program, “Amazin” increments its line numbers by 10. But at some point, a user/coder decided they needed an extra space after the code prints out how many dollars the player has; so that extra naked PRINT is on line 195. And the display of the instructions for the game are all kept between lines 100 and 109, another common pattern.

            The program listing on page 30 for Basket displays the common habit of starting separate routines at even hundreds and thousands. Line numbers within those routines continue to increment by 10. The pattern is fairly obvious even though new features (and possibly other patterns) have added several lines outside the pattern.

            As BASIC implementations began to get RENUM commands, more BASIC code listings appeared with increments of one. This is partly because using an increment of one used less memory. While the line number itself used a fixed amount of RAM (with the result that the maximum line number was often somewhere around FFFF, or 65525), references to line numbers did not tend to use a fixed length. Thus, smaller line numbers used less RAM overall.

            Depending on how large the program was, and how much branching it used, this could be significant compared to the amount of RAM the machine itself had.

            For example, I recently typed in the SKETCH.BAS program from the October 1984 Rainbow Magazine, page 97. This is a magazine, and a program, for the TRS-80 Color Computer. This program uses increments of 1 for its line numbering. On CLOADing the program in, free memory stands at 17049. After using RENUM 10,1,10 to renumber it in increments of 10, free memory stands at 16,953.

            A savings of 96 bytes may not sound like much, but this is a very small program; and it’s still half a percent of available RAM. The difference could be the difference between a program fitting into available RAM or not fitting. This computer only has 22823 bytes of RAM free even with no program in memory at all.

            Source https://stackoverflow.com/questions/71330902

            QUESTION

            Mandelbrot Set function crashes
            Asked 2022-Feb-28 at 13:53

            i made a sim for the Mandelbrot Set function, zn + 1 = power(zn) + c and it work but when i get to the point were the function is unstable it crashes, now i have a boolen that when true makes a wire that connects all the circles, when its false its fine(dosent crash) but when its on it does, the code works like this:

            start: building a list of circles and making there pos by the equation, and then crating a wire between the circle and the last circle, update: then when you move the circle it uses the already made list of gameobj to update there pos.

            you can try it here: build github: git

            but it crashes:(, heres the code:

            ...

            ANSWER

            Answered 2022-Feb-28 at 13:53

            I looked briefly into your code and you seem to get some invalid positions like infinite / undefined from your calculations or just some positions too far away for Unity.

            I could remove these by simply limiting positions to e.g.

            Source https://stackoverflow.com/questions/71291966

            QUESTION

            Drawing a Mandelbrot Set
            Asked 2022-Feb-27 at 19:21

            I'm trying to make the function of the Mandelbrot Set, and I'm not sure what I'm doing wrong or right, here's the code:

            ...

            ANSWER

            Answered 2022-Feb-27 at 19:21

            i manged to get my code working after some time and i got some answars to share if anyone has my problen:

            well i only wanted to make the function of the zn + 1 = zn * zn + c i dident made the full set only this function, heres my code:

            Source https://stackoverflow.com/questions/71263009

            QUESTION

            How to return for loop values without any html template in flask
            Asked 2022-Jan-28 at 10:04

            How to return for loop values without any html template in flask , in the below code I need to get all jokes values having multiple jokes route but i want them to be displayed as a list one below the other , currently the output I am getting is as a whole list item , I am aware i can use jinja for this but here i want to do without creating any html page

            ...

            ANSWER

            Answered 2022-Jan-28 at 09:55

            you can use this function, adding a
            separator between each joke:

            Source https://stackoverflow.com/questions/70891038

            QUESTION

            CUDA- Invalid __global__ write of size 4
            Asked 2022-Jan-23 at 18:08

            I have implemented the Mandelbrot set in Cuda. When I input the height and width present in the attached code I get this error by running the cuda-memcheck command. What is it caused by? I believe that it may be due to an overflow error of the index index of the output result vector, but I would not understand why I would have the error in this case, and when I input other values, this does not happen (for example, when i have a height= 16384 * 4 and width=8192 * 4). Thanks everyone for your time.

            ...

            ANSWER

            Answered 2022-Jan-23 at 18:08

            I believe that it may be due to an overflow error of the index

            That is certainly a problem.

            I would not understand why I would have the error in this case, and when I input other values, this does not happen (for example, when i have a height= 16384 * 4 and width=8192 * 4).

            Source https://stackoverflow.com/questions/70824479

            QUESTION

            "Big Float" Mandelbrot runs slower on GPU than CPU
            Asked 2022-Jan-09 at 18:29

            I just ported over my "big float" implementation over to OpenCL, but it turns out that the GPU was slower than the CPU? That's quite surprising as I thought that Mandelbrot was an embarrassingly parallel problem.

            ...

            ANSWER

            Answered 2022-Jan-09 at 18:29

            That's quite surprising as I thought that Mandelbrot was an embarrassingly parallel problem.

            It is, but the mapping of work is not steady between work-items in both dimensions. Some work-items complete only in 5 iterations while some require 100 iterations. Those complete early simply start idling until the last(200 iterations?) pixel in same tile is computed.

            To optimize the idle cycles during waiting on busy pixels (high-iteration pixels), you can do this:

            • have 1 GPU workitem take a 8x8 tile of pixels. (10k workitems for 800x800 image)
            • "sample" 4 corners of the tile using the GPU workitem running the kernel
            • if sampled iteration values are relatively close to each other, spawn a mini-kernel by that work-item (using dynamic parallelism) and compute the 8x8 region using that mini-kernel on 64 workitems (GPU threads)
            • if sampled iteration values are very different between each other, then have the parent workitem compute the whole 8x8 region without having any idle cycles between pixel computations.

            Another option could be sending those "divergent" tiles to CPU and computing only "steady" tiles on the GPU. This way best of both worlds can be combined with relatively less wasting of GPU cycles. Or you can sort all tiles on their guessed-average-iteration values and run highest ones only on GPU and lowest ones only on CPU.

            Sampling corners of a 8x8 tile takes roughly 1/16 of its total compute effort. So with the relatively cheap preprocessing, you can distribute it fairly.

            Source https://stackoverflow.com/questions/70330020

            QUESTION

            Numba parallel code slower than its sequential counterpart
            Asked 2021-Dec-25 at 01:21

            I'm new to Numba and I'm trying to implement an old Fortran code in Python using Numba (version 0.54.1), but when I add parallel = True the program actually slows down. My program is very simple: I change the positions x and y in a L x L grid and for each position in the grid I perform a summation

            ...

            ANSWER

            Answered 2021-Dec-25 at 01:00

            One main issue is that the second function call compile the function again. Indeed, the types of the provided arguments change: in the first call the third argument is an integer (int transformed to a np.int_) while in the second call the third argument (k) is a floating point number (float transformed to a np.float64). Numba recompiles the function for different parameter types because they are deduced from the type of the arguments and it does not know you want to use a np.float64 type for the third argument (since the first time the function is compiled with for a np.int_ type). One simple solution to fix the problem is to change the first call to:

            Source https://stackoverflow.com/questions/70475773

            QUESTION

            Use CppADCodeGen with CMake FetchContent or ExternalProject
            Asked 2021-Nov-25 at 10:56

            I am not good with CMake, and I cannot find good explanations about how to use its FetchContent functionality. Indeed, most repositories seem to require different treatment, and the rules of such treatment defy my comprehension.

            That said, here is my problem. I would like to use CppADCodeGen in my project using CMake FetchContent. Here is my code:

            ...

            ANSWER

            Answered 2021-Oct-26 at 20:48
            Problems Overview

            As seen in the output you've provided, there are 2 problems:

            1. There is a target name conflict between probably CppAD and eigen. They both have the uninstall target. It can be seen here:

            Source https://stackoverflow.com/questions/69686099

            QUESTION

            Issue with Mandelbrot smooth coloring
            Asked 2021-Nov-25 at 09:40

            I implemented the regular algorithm to display the Mandelbrot set and colour it, and now I'm working on the smooth colouring features using a 255 colourmap.

            This part is already well documented online (and even on this forum) and I choose the most popular way with the renormalization of the escape:

            ...

            ANSWER

            Answered 2021-Nov-25 at 09:40

            There were two deviations from the linked algorithm that were causing issues:

            1. You were setting the escape radius to a low value (~2) in some cases
            2. You were dividing by the log(R) which was not correct. You should divide by log(2)

            Additionally some of the banding was because you were still using a discrete color map. You could use a continuous mapping of value -> hue, but if you want a particular cycle of colors, you can use lerpColor() to smoothly transition from one color and the next based on the difference between the continuous/smooth value and the current index.

            Source https://stackoverflow.com/questions/70107312

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install mandelbrot

            You can download it from GitHub.
            You can use mandelbrot like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the mandelbrot component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/tvcutsem/mandelbrot.git

          • CLI

            gh repo clone tvcutsem/mandelbrot

          • sshUrl

            git@github.com:tvcutsem/mandelbrot.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Game Engine Libraries

            godot

            by godotengine

            phaser

            by photonstorm

            libgdx

            by libgdx

            aseprite

            by aseprite

            Babylon.js

            by BabylonJS

            Try Top Libraries by tvcutsem

            harmony-reflect

            by tvcutsemJavaScript

            es-lab

            by tvcutsemJavaScript

            proxy-handlers

            by tvcutsemJavaScript

            schemeken

            by tvcutsemC

            tinyc

            by tvcutsemC++