Skip to content

Commit 0eb4070

Browse files
committed
update c (openmp), gnuplot
1 parent b1d9ba3 commit 0eb4070

File tree

4 files changed

+137
-48
lines changed

4 files changed

+137
-48
lines changed

gamedev/graphics/raytracing.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- article: ps https://seriot.ch/projects/postscript_tiny_ray_tracer.html
1616
- article: clojure https://www.abhirag.com/ray_tracer/
1717
- article: C https://fabiensanglard.net/postcard_pathtracer/
18+
- article: C https://drakeor.com/2021/06/14/simple-software-based-raytracer-in-c/
1819
- article: C++ https://fabiensanglard.net/rayTracing_back_of_business_card/
1920
- c++ -O3 -o card card.cpp
2021

languages/compiled/c/libraries.org

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,32 @@
1414
- (24) https://github.com/begriffs/libderp
1515
- (10) https://github.com/lelanthran/libds
1616
- (480) coroutines https://github.com/tidwall/neco
17+
18+
* OpenMP
19+
20+
- wiki https://en.wikipedia.org/wiki/OpenMP
21+
- not OpenMPI
22+
- Mark variable thread local
23+
#+begin_src c
24+
#pragma omp parallel
25+
#pragma omp parallel for
26+
#pragma omp parallel for schedule(dynamic, 1) private(r)
27+
#pragma omp threadprivate (generator)
28+
#+end_src
29+
- options
30+
|-------------+---------------------+------------------------------------|
31+
| <c> | <c> | |
32+
| num_threads | N | |
33+
| private | [VAR] | variables private to each thread |
34+
| shared | [VAR] | variables shared among each thread |
35+
| default | private¦shared¦none | default variable behaviour |
36+
| for | _ | a loop that can be parallelized |
37+
| sections | _ | a block that can be parallelized |
38+
| single | _ | |
39+
| master | _ | |
40+
|-------------+---------------------+------------------------------------|
41+
- compile
42+
#+begin_src sh
43+
$ export OMP_NUM_THREADS=4
44+
$ gcc -fopenmp hello.c -o hello -ldl
45+
#+end_src

languages/compiled/c/self.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ As a pointer type
461461
| complex.h | | ~Complex number~ arithmetic |
462462
| fenv.h | | Floating-point environment |
463463
| inttypes.h | | Format conversion of integer types |
464-
| tgmath.h | | Type-generic math (macros wrapping math.h and complex.h) |
464+
| [[https://en.wikibooks.org/wiki/C_Programming/tgmath.h][tgmath.h]] | | Type-generic math (macros wrapping math.h and complex.h) |
465465
| stdbool.h | bool | Macros for boolean type |
466466
| | false (0) | |
467467
| | true (1) | |

terminal/tools/visualization/gnuplot/self.org

Lines changed: 106 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,25 @@
3030

3131
* language
3232

33-
#+begin_src sh
33+
#+begin_src gnuplot
3434
#!/usr/bin/gnuplot -persist
35+
a = 7 # variable assignent
36+
f(x,d) = d * x**2 # functions
37+
g(x) = x <= 0 ? sin(x) : NaN
3538
#+end_src
3639

37-
- has variable assignment
40+
- NaN type
3841
- "(/Symbol p)" - replaces parens with 𝛑
3942
- curve fitting https://www.youtube.com/watch?v=vHM_5AeKwXE
4043
- do for [i=1:96] { plot f(x,i*0.1) }
41-
44+
- operators http://www.gnuplot.info/docs_4.2/node55.html
45+
46+
** functions
47+
- http://www.gnuplot.info/docs/loc1283.html
48+
- math
49+
- string
50+
- time
51+
- other
4252
** input data
4353

4454
- space separated by default
@@ -58,19 +68,31 @@
5868
*** plot
5969

6070
- [re]plot [PLOT_A OPTS], [PLOT_B OPTS]
71+
- for [n = 1 : 5]
72+
- widths = "30 15 5"
73+
for [width in widths]
74+
- "+" (previous filename)
6175
- "filename.txt"
6276
- /dev/stdin
6377
- using N:N+1:N+n
6478
- smooth [bezier¦mcsplines]
65-
- title (for legend box)
79+
- title S (for legend box)
6680
- index N
6781
- reference block N of data (aka separated by 2 \n)
6882
- blocks index start at 0
6983
- with
84+
- histograms
85+
- filledcurves
86+
- fillstyle pattern N
7087
- linespoint
7188
- lines
72-
- linestyle N
73-
- linecolor rgb "#0b0000"
89+
- [d]ash[t]ype N
90+
- [d]ash[t]ype S
91+
- [l]ine[s]tyle N
92+
- [l]ine[t]ype N
93+
- [l]ine[c]olor rgb "#0b0000"
94+
- [l]ine[c]olor rgb "green"
95+
- [l]ine[w]ith N
7496
- points
7597
- pointsize N
7698
- imagesc - matrix/heatmap - 2d contour
@@ -80,49 +102,85 @@
80102
** options (setteable)
81103

82104
*** general
83-
#+CAPTION: S = a quoted string, N = a number
84-
|--------------+-------------------+------------------------------------|
85-
| <c> | <c> | |
86-
| | argument | description |
87-
|--------------+-------------------+------------------------------------|
88-
| border | [N] | axis lines (takes the bitsum) |
89-
| [x¦y¦z]tics | [nomirror¦rotate] | axis numbers |
90-
| | START,STEP,END | |
91-
| | (S N[,S N]) | custom labels S at point N |
92-
| [x¦y¦z]label | S | axis label |
93-
| | offset N | |
94-
| [x¦y¦z]range | [N:N] | axis range |
95-
| grid | - | axis grid |
96-
| key | [BLTR] [[no]box] | enable/disable/position legend box |
97-
| | width N | |
98-
| | font S | use ",14" to only change it's size |
99-
| | at N,N | |
100-
|--------------+-------------------+------------------------------------|
101-
| samples | N | ???? |
102-
| xdata | time | tells x axis is a date/time |
103-
| encoding | utf8 | |
104-
| timefmt | S | format of the INPUT date |
105-
| datafile | separator S | input separator (default: space) |
106-
|--------------+-------------------+------------------------------------|
107-
| title | S | the |
108-
| format | [x¦y] FMT | tic format string |
109-
| scale | N | |
110-
| logscale | [x¦y] [N] | with step N |
111-
| autoscale | [[x¦y]fix] | prevents autoextend of scale |
112-
| output | S | saves into filepath at S |
113-
|--------------+-------------------+------------------------------------|
114-
| pause | N | seconds to pause |
115-
| +reread+ | - | REMOVED in 6.0 +reread input+ |
116-
|--------------+-------------------+------------------------------------|
105+
106+
#+CAPTION: S ="string", N=number, F=float
107+
|------------+------------+-----------------------------------|
108+
| <c> | <c> | |
109+
| table | "FILENAME" | save plot to file, unset it after |
110+
| encoding | utf8 | |
111+
|------------+------------+-----------------------------------|
112+
| title | S | the |
113+
| scale | N | |
114+
| output | S | saves into filepath at S |
115+
| monochrome | _ | |
116+
|------------+------------+-----------------------------------|
117+
| pause | N | seconds to pause |
118+
| +reread+ | - | REMOVED in 6.0 +reread input+ |
119+
|------------+------------+-----------------------------------|
120+
121+
*** general: file parsing
122+
123+
|-----------+-----------------+----------------------------------|
124+
| <c> | <c> | |
125+
|-----------+-----------------+----------------------------------|
126+
| datafile | separator S | |
127+
| | separator tab | |
128+
| | separator comma | input separator (default: space) |
129+
|-----------+-----------------+----------------------------------|
130+
| samples | N | sampling frequency |
131+
| [xyz]data | time | tells ? axis is a date/time |
132+
| timefmt | FMT | INPUT format date |
133+
| format | [x¦y] FMT | OUTPUT format string |
134+
|-----------+-----------------+----------------------------------|
135+
136+
*** general: axis styling
137+
138+
#+CAPTION: S ="string", N=number, F=float
139+
|---------------+----------------+----------------------------------|
140+
| <c> | <c> | |
141+
|---------------+----------------+----------------------------------|
142+
| border | [N] | pick axis lines (takes a bitsum) |
143+
| grid | - | axis grid |
144+
| logscale | [x¦y] [N] | with step N |
145+
| autoscale | [[x¦y]fix] | prevents autoextend of scale |
146+
| xdata | time | tells ? axis is a date/time |
147+
| format | [x¦y] FMT | OUTPUT format string |
148+
| [xyz][2]range | [N:N] | axis range |
149+
| [xyz][2]tics | nomirror | axis numbers |
150+
| | rotate | |
151+
| | START,STEP,END | |
152+
| | (S N[,S N]) | custom labels S at point N |
153+
| [xyz][2]label | S | axis label |
154+
| | offset N | |
155+
|---------------+----------------+----------------------------------|
156+
*** key
157+
158+
|-----+---------------+-------------------------------|
159+
| | <c> | |
160+
| key | [BLTR] | position legend box |
161+
| | [no]box | enable/disable |
162+
| | at graph F, F | |
163+
| | width N | |
164+
| | font S | use ",14" to change size only |
165+
| | at N,N | |
166+
|-----+---------------+-------------------------------|
167+
117168
*** style
118169

119-
|------------------+---------------------------------|
120-
| fill transparent | |
121-
| solid F | |
122-
| noborder | |
123-
| data lines | |
124-
| line N | can be later referenced on plot |
125-
|------------------+---------------------------------|
170+
|-----------+-------------+----------------------------------|
171+
| <c> | <c> | |
172+
| fill | transparent | |
173+
| | solid | |
174+
| solid | F | |
175+
| noborder | _ | |
176+
| data | lines | sets default for *plot* with ... |
177+
| | histograms | |
178+
| line | N | can be later referenced on plot |
179+
| histogram | gap N | |
180+
| | cluster | |
181+
| | clustered | |
182+
| | rowstacked | |
183+
|-----------+-------------+----------------------------------|
126184

127185
#+CAPTION: gnuplot "test" command output
128186
#+ATTR_HTML: :width 500
@@ -172,6 +230,7 @@ http://gnuplot.info/demo/pm3dcolors.html
172230

173231
* tools
174232

233+
- emacs: [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html][Org-babel-gnuplot]]
175234
- wrapper: plot realtime and stored data from the cli https://github.com/dkogan/feedgnuplot
176235
- config https://github.com/Gnuplotting/gnuplot-configs
177236
- pallettes

0 commit comments

Comments
 (0)