Skip to content

Commit c7f82cb

Browse files
authored
Merge branch 'main' into coconut_compilation
2 parents ca96786 + 6b592d5 commit c7f82cb

File tree

98 files changed

+1303
-660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1303
-660
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/ubuntu
1+
// For format details, see https://aka.ms/devcontainer.json.
32
{
4-
"name": "Ubuntu",
5-
"build": {
6-
"dockerfile": "../Dockerfile",
7-
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
8-
"args": { "VARIANT": "focal" }
9-
},
3+
"name": "Arcane Algorithm Archive All Languages",
4+
5+
// Comment out 'image' and uncomment 'build' to test changes to the dockerfile locally
6+
"image": "ghcr.io/algorithm-archivists/aaa-langs:latest",
7+
// "build": {\
8+
// // For config options, see the README at:https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/ubuntu
9+
// "dockerfile": "../Dockerfile",
10+
// // Update 'VARIANT' to pick an Ubuntu version: focal, bionic
11+
// "args": { "VARIANT": "focal" }
12+
// },
1013

1114
// Set *default* container specific settings.json values on container create.
1215
"settings": {},
1316

14-
1517
// Add the IDs of extensions you want installed when the container is created.
1618
"extensions": [],
1719

18-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19-
// "forwardPorts": [],
20-
21-
// Use 'postCreateCommand' to run commands after the container is created.
22-
// "postCreateCommand": "uname -a",
23-
24-
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
25-
// "remoteUser": "vscode"
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally (outside the container).
21+
// Port : Usage
22+
// 4000 : Honkit serves by default on this port
23+
"forwardPorts": [4000]
2624
}

.github/workflows/build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on: pull_request
44
jobs:
55
build:
66
runs-on: ubuntu-latest
7+
container:
8+
options: --entrypoint /bin/bash --user 0
9+
image: ghcr.io/algorithm-archivists/aaa-langs:latest
10+
defaults:
11+
run:
12+
shell: bash --rcfile /root/.bashrc -eo pipefail {0}
713
steps:
814
- name: Checkout
915
uses: actions/checkout@v2
@@ -14,3 +20,10 @@ jobs:
1420
run: |
1521
npm install
1622
npx honkit build
23+
24+
- name: Initalize cargo and run SCons
25+
env:
26+
HOME: /root
27+
run: |
28+
. "$HOME/.cargo/env"
29+
scons -Q

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Deploy
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66

77
jobs:
88
build-and-deploy:

.github/workflows/publish_container.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ name: Publish Docker
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9+
if: github.repository == 'algorithm-archivists/algorithm-archive'
910
steps:
1011
- uses: actions/checkout@master
1112
- name: Publish to Registry
@@ -14,4 +15,4 @@ jobs:
1415
name: algorithm-archivists/aaa-langs
1516
username: ${{ github.actor }}
1617
password: ${{ secrets.GITHUB_TOKEN }}
17-
registry: ghcr.io
18+
registry: ghcr.io

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ paket-files/
478478
# Python Tools for Visual Studio (PTVS)
479479
__pycache__/
480480
*.pyc
481-
481+
*.ipynb_checkpoints*
482482
# Cake - Uncomment if you are using it
483483
# tools/**
484484
# !tools/packages.config
@@ -528,3 +528,6 @@ build/
528528
# Cargo artifacts
529529
Cargo.lock
530530
target/
531+
532+
*.out
533+
*.class

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

CONTRIBUTORS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This file lists everyone, who contributed to this repo and wanted to show up her
5151
- Vincent Zalzal
5252
- Jonathan D B Van Schenck
5353
- James Goytia
54-
- Sammy Plat
54+
- Sammy Plat
5555
- Jonathan Dönszelmann
5656
- Ishaan Verma
5757
- Delphi1024
@@ -60,4 +60,6 @@ This file lists everyone, who contributed to this repo and wanted to show up her
6060
- Ridham177
6161
- Hugo Salou
6262
- Dimitri Belopopsky
63-
+ Henrik Abel Christensen
63+
- Henrik Abel Christensen
64+
- K. Shudipto Amin
65+
- Peanutbutter_Warrior

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env = Environment(ENV=os.environ,
2626
'Coconut': coconut_builder},
2727
tools=['gcc', 'gnulink', 'g++', 'gas', 'gfortran'])
2828

29-
env['CCFLAGS'] = ''
29+
env['CFLAGS'] = '-Wall -Wextra -Werror'
3030
env['CXXFLAGS'] = '-std=c++17'
3131
env['ASFLAGS'] = '--64'
3232
env['COCONUTFLAGS'] = '--target 3.8'

SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* [Algorithm Archive](README.md)
44
* [Introduction](contents/introduction/introduction.md)
55
* [How To Contribute](contents/how_to_contribute/how_to_contribute.md)
6+
* [Code Reviewers](contents/code_reviews/code_reviewers.md)
67
* [Plotting](contents/plotting/plotting.md)
78
* [Domain Coloring](contents/domain_coloring/domain_coloring.md)
89
* [Iterated Function Systems](contents/IFS/IFS.md)
@@ -19,9 +20,11 @@
1920
* [Multiplication as a Convolution](contents/convolutions/multiplication/multiplication.md)
2021
* [Convolutions of Images (2D)](contents/convolutions/2d/2d.md)
2122
* [Convolutional Theorem](contents/convolutions/convolutional_theorem/convolutional_theorem.md)
23+
* [Probability Distributions](contents/probability/distributions/distributions.md)
2224
* [Tree Traversal](contents/tree_traversal/tree_traversal.md)
2325
* [Euclidean Algorithm](contents/euclidean_algorithm/euclidean_algorithm.md)
2426
* [Monte Carlo](contents/monte_carlo_integration/monte_carlo_integration.md)
27+
* [Metropolis](contents/metropolis/metropolis.md)
2528
* [Matrix Methods](contents/matrix_methods/matrix_methods.md)
2629
* [Gaussian Elimination](contents/gaussian_elimination/gaussian_elimination.md)
2730
* [Thomas Algorithm](contents/thomas_algorithm/thomas_algorithm.md)

contents/IFS/IFS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ Here, instead of tracking children of children, we track a single individual tha
146146
[import:4-16, lang:"coconut"](code/coconut/IFS.coco)
147147
{% sample lang="java" %}
148148
[import:16-39, lang:"java"](code/java/IFS.java)
149+
{% sample lang="ps1" %}
150+
[import:2-19, lang:"powershell"](code/powershell/IFS.ps1)
149151
{% endmethod %}
150152

151153
If we set the initial point to the on the equilateral triangle we saw before, we can see the Sierpinski triangle again after a few thousand iterations, as shown below:
@@ -232,6 +234,8 @@ In addition, we have written the chaos game code to take in a set of points so t
232234
[import, lang:"coconut"](code/coconut/IFS.coco)
233235
{%sample lang="java" %}
234236
[import, lang:"java"](code/java/IFS.java)
237+
{% sample lang="ps1" %}
238+
[import, lang:"powershell"](code/powershell/IFS.ps1)
235239
{% endmethod %}
236240

237241
### Bibliography
@@ -246,7 +250,7 @@ MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
246250

247251
##### Code Examples
248252

249-
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/master/LICENSE.md)).
253+
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/main/LICENSE.md)).
250254

251255
##### Text
252256

contents/IFS/code/c/IFS.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void chaos_game(struct point *in, size_t in_n, struct point *out,
2020

2121
struct point cur_point = {drand(), drand()};
2222

23-
for (int i = 0; i < out_n; ++i) {
23+
for (size_t i = 0; i < out_n; ++i) {
2424
out[i] = cur_point;
2525
struct point tmp = random_element(in, in_n);
2626
cur_point.x = 0.5 * (cur_point.x + tmp.x);
@@ -29,21 +29,22 @@ void chaos_game(struct point *in, size_t in_n, struct point *out,
2929
}
3030

3131
int main() {
32+
const int point_count = 10000;
33+
3234
struct point shape_points [3] = {{0.0,0.0}, {0.5,sqrt(0.75)}, {1.0,0.0}};
33-
struct point out_points[1000];
35+
struct point out_points[point_count];
3436

3537
srand(time(NULL));
3638

37-
chaos_game(shape_points, 3, out_points, 1000);
39+
chaos_game(shape_points, 3, out_points, point_count);
3840

3941
FILE *fp = fopen("sierpinksi.dat", "w+");
4042

41-
for (int i = 0; i < 1000; ++i) {
43+
for (int i = 0; i < point_count; ++i) {
4244
fprintf(fp, "%f\t%f\n", out_points[i].x, out_points[i].y);
4345
}
4446

4547
fclose(fp);
4648

4749
return 0;
4850
}
49-

contents/IFS/code/clisp/ifs.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
`((0 0) (0.5 ,(sqrt 0.75)) (1 0))))
2222

2323
;; output the data to the "out.dat" file
24-
(with-open-file (out "out.dat" :direction :output :if-exists :supersede)
24+
(with-open-file (out "sierpinski.dat" :direction :output :if-exists :supersede)
2525
(flet ((format-point (p)
2626
;; this is not very clean, but it's the simplest way to insert a tab into a string.
2727
(format nil "~f~c~f" (point-x p) #\tab (point-y p))))

contents/IFS/code/haskell/IFS.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ main = do
2727
points = chaosGame g 10000 sierpinski
2828
showPoint (Point x y) = show x ++ "\t" ++ show y
2929

30-
writeFile "out.dat" $ intercalate "\n" $ map showPoint points
30+
writeFile "sierpinski.dat" $ intercalate "\n" $ map showPoint points

contents/IFS/code/powershell/IFS.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This function simulates a "chaos game"
2+
function Simulate-ChaosGame($n, $shapePoints) {
3+
$outputPoints = New-Object System.Collections.ArrayList
4+
5+
# Initialize the starting point
6+
$point = @($(Get-Random -Minimum 0.0 -Maximum 1.0), $(Get-Random -Minimum 0.0 -Maximum 1.0))
7+
8+
for ($i = 0; $i -lt $n; $i++) {
9+
$outputPoints.add($point) | Out-Null
10+
$temp = $shapePoints[$(Get-Random -Maximum $shapePoints.Count)]
11+
12+
$point = @(
13+
0.5 * ($point[0] + $temp[0])
14+
0.5 * ($point[1] + $temp[1])
15+
)
16+
}
17+
18+
return $outputPoints
19+
}
20+
21+
22+
# This will generate a Sierpinski triangle with a chaos game of n points for an
23+
# initial triangle with three points on the vertices of an equilateral triangle:
24+
# A = (0.0, 0.0)
25+
# B = (0.5, sqrt(0.75))
26+
# C = (1.0, 0.0)
27+
# It will output the file sierpinski.dat, which can be plotted after
28+
$shapePoints = @(
29+
@(0.0, 0.0),
30+
@(0.5, [math]::sqrt(0.75)),
31+
@(1.0, 0.0)
32+
)
33+
34+
Simulate-ChaosGame -n 10000 -shapePoints $shapePoints | % { "$($_[0])`t$($_[1])" } | Out-File -Path "sierpinski.dat"

contents/affine_transformations/affine_transformations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
308308

309309
##### Code Examples
310310

311-
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/master/LICENSE.md)).
311+
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/main/LICENSE.md)).
312312

313313
##### Text
314314

contents/approximate_counting/approximate_counting.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ As we do not have any objects to count, we will instead simulate the counting wi
366366
[import, lang:"cpp"](code/cpp/approximate_counting.cpp)
367367
{% sample lang="python" %}
368368
[import, lang:"python"](code/python/approximate_counting.py)
369+
{% sample lang="java" %}
370+
[import, lang:"java"](code/java/ApproximateCounting.java)
369371
{% endmethod %}
370372

371373
### Bibliography
@@ -380,7 +382,7 @@ MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
380382

381383
##### Code Examples
382384

383-
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/master/LICENSE.md)).
385+
The code examples are licensed under the MIT license (found in [LICENSE.md](https://github.com/algorithm-archivists/algorithm-archive/blob/main/LICENSE.md)).
384386

385387
##### Text
386388

0 commit comments

Comments
 (0)