Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
math_tech_info
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orestis.malaspin
math_tech_info
Commits
cd5fc63c
Verified
Commit
cd5fc63c
authored
4 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
visualization cooler a bit. but still not great
parent
24f1ec05
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#12982
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
travaux_pratiques/tpChaos/Makefile
+2
-1
2 additions, 1 deletion
travaux_pratiques/tpChaos/Makefile
travaux_pratiques/tpChaos/map.c
+31
-10
31 additions, 10 deletions
travaux_pratiques/tpChaos/map.c
with
33 additions
and
11 deletions
travaux_pratiques/tpChaos/Makefile
+
2
−
1
View file @
cd5fc63c
CC
=
gcc
CFLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c11
-g
-fsanitize
=
leak
-fsanitize
=
undefined
-fsanitize
=
address
-O3
CFLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c11
-g
-O3
# -fsanitize=leak -fsanitize=undefined -fsanitize=address
LFLAGS
=
-lSDL2
TARGET
=
map
...
...
This diff is collapsed.
Click to expand it.
travaux_pratiques/tpChaos/map.c
+
31
−
10
View file @
cd5fc63c
...
...
@@ -3,16 +3,24 @@
#include
<unistd.h>
#include
"gfx.h"
double
map
(
double
x
,
double
lambda
)
{
static
void
gfx_clear_rect
(
struct
gfx_context_t
*
ctxt
,
int
x0
,
int
x1
,
int
y0
,
int
y1
)
{
for
(
int
x
=
x0
;
x
<
x1
;
++
x
)
{
for
(
int
y
=
y0
;
y
<
y1
;
++
y
)
{
gfx_putpixel
(
ctxt
,
x
,
y
,
COLOR_BLACK
);
}
}
}
static
double
map
(
double
x
,
double
lambda
)
{
return
lambda
*
x
*
(
1
.
0
-
x
);
}
int
main
()
{
const
double
lambda_min
=
0
;
const
double
lambda_min
=
3
;
const
double
lambda_max
=
4
;
const
int
N
=
1920
;
const
int
M
=
96
0
;
const
double
dl
=
(
lambda_max
-
lambda_min
)
/
N
;
const
int
M
=
100
0
;
double
dl
=
(
lambda_max
-
lambda_min
)
/
N
;
struct
gfx_context_t
*
ctxt
=
gfx_create
(
"Example"
,
N
,
M
);
if
(
!
ctxt
)
{
...
...
@@ -20,25 +28,38 @@ int main() {
return
EXIT_FAILURE
;
}
gfx_clear
(
ctxt
,
COLOR_BLACK
);
double
prop
=
0
.
2
;
int
num_points
=
M
/
10
;
int
max_iter
=
10000
0
;
for
(
double
i_lambda
=
0
;
i_lambda
<
N
;
++
i_lambda
)
{
int
max_iter
=
10000
;
for
(
int
i_lambda
=
0
;
i_lambda
<
N
;
++
i_lambda
)
{
double
x
=
0
.
5
;
for
(
int
i
=
0
;
i
<
max_iter
;
++
i
)
{
double
lambda
=
lambda_min
+
i_lambda
*
dl
;
double
x_new
=
map
(
x
,
lambda
);
x
=
x_new
;
if
(
i
>
max_iter
-
M
)
{
gfx_putpixel
(
ctxt
,
i_lambda
,
M
-
x
*
M
-
1
,
COLOR_WHITE
);
x
=
map
(
x
,
lambda
);
if
(
i
>
max_iter
-
num_points
)
{
gfx_putpixel
(
ctxt
,
i
%
(
num_points
/
2
),
(
M
-
1
)
-
(
M
-
1
)
*
x
*
prop
,
COLOR_WHITE
);
gfx_clear_rect
(
ctxt
,
(
i
+
1
)
%
(
num_points
/
2
),
(
i
+
2
)
%
(
num_points
/
2
),
(
1
-
prop
)
*
(
M
-
1
),
(
M
-
1
));
gfx_putpixel
(
ctxt
,
i_lambda
,
(
M
-
1
)
*
(
1
-
x
),
COLOR_WHITE
);
// printf("x(%d, %g) = %g\n", i, i_lambda * dl, x);
// usleep((unsigned int)1000);
// if (i % 512 == 0) {
// gfx_present(ctxt);
// }
}
}
gfx_clear_rect
(
ctxt
,
(
num_points
/
2
-
1
),
(
num_points
/
2
)
+
2
,
(
1
-
prop
)
*
(
M
-
1
),
(
M
-
1
));
gfx_present
(
ctxt
);
// printf("\n");
}
while
(
gfx_keypressed
()
!=
SDLK_ESCAPE
)
{
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment