Skip to content

Commit 4c95e98

Browse files
Merge branch 'master' into implement-stacks-queues-rust
2 parents 962e854 + 0aa5333 commit 4c95e98

File tree

41 files changed

+292
-125
lines changed

Some content is hidden

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

41 files changed

+292
-125
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Ubuntu",
55
"build": {
6-
"dockerfile": "Dockerfile",
6+
"dockerfile": "../Dockerfile",
77
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
88
"args": { "VARIANT": "focal" }
99
},
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish Docker
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@master
11+
- name: Publish to Registry
12+
uses: elgohr/Publish-Docker-Github-Action@master
13+
with:
14+
name: algorithm-archivists/aaa-langs
15+
username: ${{ github.actor }}
16+
password: ${{ secrets.GITHUB_TOKEN }}
17+
registry: ghcr.io

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -524,3 +524,7 @@ vscode/
524524

525525
# SCons build directory
526526
build/
527+
528+
# Cargo artifacts
529+
Cargo.lock
530+
target/

.nojekyll

Whitespace-only changes.

.devcontainer/Dockerfile renamed to Dockerfile

+13-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
66

77
# [Optional] Uncomment this section to install additional OS packages.
88
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9-
&& apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk rustc libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch libfftw3-dev
9+
&& apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch libfftw3-dev cmake
1010

1111
# Setup Crystal
1212
RUN echo 'deb http://download.opensuse.org/repositories/devel:/languages:/crystal/xUbuntu_20.04/ /' | sudo tee /etc/apt/sources.list.d/devel:languages:crystal.list
@@ -40,17 +40,16 @@ ENV PATH=$PATH:~/dlang/dmd-$DLANG_VERSION/linux/bin64/
4040
RUN sudo sh -c 'wget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local'
4141
ENV PATH=$PATH:/usr/local/go/bin
4242

43-
# Setup Kotlin (doesnt unzip right maybe?)
44-
RUN sudo sh -c 'wget -c https://github.com/JetBrains/kotlin/releases/download/v1.5.30/kotlin-compiler-1.5.30.zip -O /usr/local/kotlinc.zip'
45-
RUN unzip /usr/local/kotlinc.zip
46-
ENV PATH=$PATH:/usr/local/kotlinc/bin
43+
# Setup Kotlin
44+
RUN mkdir -p ~/kotlin && wget -c https://github.com/JetBrains/kotlin/releases/download/v1.5.30/kotlin-compiler-1.5.30.zip -O ~/kotlin/kotlinc.zip && cd ~/kotlin && unzip kotlinc.zip
45+
ENV PATH=$PATH:~/kotlin/kotlinc/bin
4746

4847
# Setup lolcode
49-
## Use: https://github.com/justinmeza/lci
48+
RUN git clone https://github.com/justinmeza/lci.git ~/lolcode && cd ~/lolcode && mkdir build && cd build && cmake .. && make -B
49+
ENV PATH=$PATH:~/lolcode/build
5050

5151
# Setup Piet
52-
## Use: https://github.com/boothby/repiet
53-
52+
RUN pip install repiet
5453

5554
# Setup Matlab
5655
# ?????? This is a licensed language???
@@ -73,6 +72,9 @@ RUN sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu fo
7372
RUN sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D9D33FCD84D82C17288BA03B3C9A6980F827E01E
7473
RUN sudo add-apt-repository 'deb http://ppa.launchpad.net/plt/racket/ubuntu focal main'
7574

75+
# Setup Rust
76+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
77+
7678
# Setup Scratch
7779
## using 1.x right now.... in future checkout snap or adobe air?
7880

@@ -86,7 +88,8 @@ ENV PATH=$PATH:~/swift/usr/bin
8688
RUN export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends vim
8789

8890
# Setup whitespace
89-
## ?
91+
RUN mkdir -p ~/whitespace && git clone https://github.com/wspace/whitespace-haskell ~/whitespace && cd ~/whitespace && make -B
92+
ENV PATH=$PATH:~/whitespace
9093

9194
# Setup Elm
9295
RUN mkdir -p ~/elm && curl -L -o ~/elm/elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz && \
@@ -102,6 +105,7 @@ ENV PATH=$PATH:~/vlang/v
102105
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
103106
&& apt-get -y install --no-install-recommends crystal dart nim powershell scala dotnet-sdk-5.0 r-base racket
104107

108+
105109
RUN pip install wheel matplotlib numpy coconut scons
106110

107111
RUN sudo sh -c 'npm install -g typescript'

SConscript

-10
This file was deleted.

SConstruct

+54-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,66 @@ This provides Builder objects for each of the language implementations in the AA
55
66
Currently, the aim is to provide a way to compile or copy the implementation files to the build directory, as well as to provide ways to run them and capture their output.
77
8-
To run the compilation for all implmeentations in one language, e.g. Rust, run the command `scons build/c`, and the resulting executables will be available in the `cuild/c` directory, each in their respective algorithm directory, containing the executable."""
8+
To run the compilation for all implementations in one language, e.g. C, run the command `scons build/c`, and the resulting executables will be available in the `build/c` directory, each in their respective algorithm directory, containing the executable."""
99

1010
from pathlib import Path
11+
import os
1112

12-
env = Environment()
13+
rust_cargo_builder = Builder(action=['cargo build --bins --manifest-path $MANIFEST',
14+
Move('$TARGET$PROGSUFFIX', '$SOURCE_DIR/target/debug/main$PROGSUFFIX')])
15+
16+
rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX')
17+
18+
go_builder = Builder(action='go build -o $TARGET$PROGSUFFIX $SOURCE')
19+
20+
env = Environment(ENV=os.environ,
21+
BUILDERS={'rustc': rust_rustc_builder,
22+
'cargo': rust_cargo_builder,
23+
'Go': go_builder},
24+
tools=['gcc', 'gnulink', 'g++', 'gas', 'gfortran'])
25+
26+
env['CCFLAGS'] = ''
27+
env['CXXFLAGS'] = '-std=c++17'
28+
env['ASFLAGS'] = '--64'
1329

1430
# Add other languages here when you want to add language targets
15-
languages = ['c']
31+
# Put 'name_of_language_directory' : 'file_extension'
32+
languages = {
33+
'c': 'c',
34+
'cpp': 'cpp',
35+
'asm-x64': 's',
36+
'rust': 'rs',
37+
'go': 'go',
38+
'fortran': 'f90',
39+
}
1640

1741
env.C = env.Program
42+
env.CPlusPlus = env.Program
43+
env.X64 = env.Program
44+
env.Fortran = env.Program
45+
46+
Export('env')
47+
48+
sconscripts = []
49+
files_to_compile = {language: [] for language in languages}
50+
51+
for chapter_dir in Path.cwd().joinpath('contents').iterdir():
52+
if (code_dir := (chapter_dir / 'code')).exists():
53+
for path in code_dir.iterdir():
54+
if path.stem in languages:
55+
# Check for overriding sconscript
56+
if (sconscript_path := path / 'SConscript').exists():
57+
sconscripts.append(sconscript_path)
58+
SConscript(sconscript_path, exports='env')
59+
else:
60+
files_to_compile[path.stem].extend(path.glob(f'*.{languages[path.stem]}'))
1861

19-
SConscript('SConscript', exports='env languages')
62+
sconscript_dir_path = Path('sconscripts')
63+
for language, files in files_to_compile.items():
64+
if files:
65+
if (sconscript_path := sconscript_dir_path / f"{language}_SConscript").exists():
66+
SConscript(sconscript_path, exports = {'files_to_compile': files,
67+
'language': language})
68+
else:
69+
print(f'{language} file found at {files[0]}, but no sconscript file is present ')
2070

contents/approximate_counting/code/c/approximate_counting.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,24 @@ void test_approximation_count(size_t n_trials, size_t n_items, double a,
6363
}
6464
double avg = sum / n_trials;
6565

66-
assert(fabs((avg - n_items) / n_items) < threshold);
66+
if (fabs((avg - n_items) / n_items) < threshold){
67+
printf("passed\n");
68+
}
69+
else{
70+
printf("failed\n");
71+
}
6772
}
6873

6974
int main()
7075
{
7176
srand(time(NULL));
7277

73-
printf("Counting Tests, 100 trials\n");
74-
printf("testing 1000, a = 30, 10%% error\n");
78+
printf("[#]\nCounting Tests, 100 trials\n");
79+
printf("[#]\ntesting 1,000, a = 30, 10%% error\n");
7580
test_approximation_count(100, 1000, 30, 0.1);
76-
printf("testing 12345, a = 10, 10%% error\n");
81+
printf("[#]\ntesting 12,345, a = 10, 10%% error\n");
7782
test_approximation_count(100, 12345, 10, 0.1);
78-
printf("testing 222222, a = 0.5, 20%% error\n");
83+
printf("[#]\ntesting 222,222, a = 0.5, 20%% error\n");
7984
test_approximation_count(100, 222222, 0.5, 0.2);
8085

8186
return 0;

contents/approximate_counting/code/cpp/approximate_counting.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ auto test_approximate_count(
5555
for (auto i = 0; i < n_trials; ++i)
5656
sum += approximate_count(n_items, a);
5757
const auto avg = sum / n_trials;
58-
return std::abs((avg - n_items) / n_items) < threshold ? "pass" : "fail";
58+
return std::abs((avg - n_items) / n_items) < threshold ? "passed" : "failed";
5959
}
6060

6161
int main() {
62-
std::cout << "Counting Tests, 100 trials\n";
62+
std::cout << "[#]\nCounting Tests, 100 trials\n";
6363

64-
std::cout << "testing 1,000, a = 30, 10% error "
64+
std::cout << "[#]\ntesting 1,000, a = 30, 10% error \n"
6565
<< test_approximate_count(100, 1000, 30, 0.1) << "\n";
66-
std::cout << "testing 12,345, a = 10, 10% error "
66+
std::cout << "[#]\ntesting 12,345, a = 10, 10% error \n"
6767
<< test_approximate_count(100, 12345, 10, 0.1) << "\n";
6868
// Note : with a lower a, we need more trials, so a higher % error here.
69-
std::cout << "testing 222,222, a = 0.5, 20% error "
69+
std::cout << "[#]\ntesting 222,222, a = 0.5, 20% error \n"
7070
<< test_approximate_count(100, 222222, 0.5, 0.2) << "\n";
7171
}

contents/approximate_counting/code/julia/approximate_counting.jl

+16-10
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,21 @@ function test_approximate_count(n_trials, n_items, a, threshold)
4747

4848
avg = sum(samples)/n_trials
4949

50-
@test (abs((avg - n_items) / n_items) < threshold)
50+
if (abs((avg - n_items) / n_items) < threshold)
51+
println("passed")
52+
else
53+
println("failed")
54+
end
5155
end
5256

53-
@testset "Counting Tests, 100 trials" begin
54-
println("testing 1,000, a = 30, 10% error")
55-
test_approximate_count(100, 1000, 30, 0.1)
56-
println("testing 12,345, a = 10, 10% error")
57-
test_approximate_count(100, 12345, 10, 0.1)
58-
# Note: with a lower a, we need more trials, so a higher % error here.
59-
println("testing 222,222, a = 0.5, 20% error")
60-
test_approximate_count(100, 222222, 0.5, 0.2)
61-
end
57+
println("[#]\nCounting Tests, 100 trials")
58+
59+
println("[#]\ntesting 1,000, a = 30, 10% error")
60+
test_approximate_count(100, 1000, 30, 0.1)
61+
62+
println("[#]\ntesting 12,345, a = 10, 10% error")
63+
test_approximate_count(100, 12345, 10, 0.1)
64+
65+
# Note: with a lower a, we need more trials, so a higher % error here.
66+
println("[#]\ntesting 222,222, a = 0.5, 20% error")
67+
test_approximate_count(100, 222222, 0.5, 0.2)

contents/approximate_counting/code/python/approximate_counting.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ def test_approximate_count(n_trials, n_items, a, threshold):
4040

4141
if abs((avg - n_items)/n_items) < threshold:
4242
print("passed")
43+
else:
44+
print("failed")
4345

44-
print("testing 1,000, a = 30, 10% error")
46+
print("[#]\nCounting Tests, 100 trials")
47+
print("[#]\ntesting 1,000, a = 30, 10% error")
4548
test_approximate_count(100, 1000, 30, 0.1)
46-
print("testing 12,345, a = 10, 10% error")
49+
print("[#]\ntesting 12,345, a = 10, 10% error")
4750
test_approximate_count(100, 12345, 10, 0.1)
48-
print("testing 222,222, a = 0.5, 20% error")
51+
print("[#]\ntesting 222,222, a = 0.5, 20% error")
4952
test_approximate_count(100, 222222, 0.5, 0.2)

contents/barnsley/barnsley.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ In this chapter, I hope to provide a slightly more satisfying answer by introduc
2424

2525
| Hutchinson Operator | Attractor |
2626
| ------------------- | --------- |
27-
| $$\begin{align} f_1(P) &= \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix} \\ f_2(P) &= \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix} \\ f_3(P) &= \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix} \\ f_4(P) &= \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix} \end{align}$$ | <img class="center" src="res/full_fern.png" alt="Barnsley Chaos Game" style="width:100%"> |
27+
| $$\begin{align} f_1(P) &= \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix} \\ f_2(P) &= \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix} \\ f_3(P) &= \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix} \\ f_4(P) &= \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix} \end{align}$$ | <img class="center" src="res/full_fern.png" alt="Barnsley Chaos Game" style="width:100%"> |
2828

2929
At first glance, this set of functions looks like an incomprehensible mess of magic numbers to create a specific result, and in a sense, that is precisely correct.
3030
That said, we will go through each function and explain how it works, while also providing a simple chaos game implementation in code.
@@ -54,7 +54,7 @@ Now let's hop into disecting the Barnsley fern by seeing how each transform affe
5454
| -------- | --------- |
5555
| $$f_1(P) = \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ <p> This operation moves every point to a single line. | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_rnd_0.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
5656
| $$f_2(P) = \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation moves every point up and to the right. | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_rnd_1.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
57-
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation rotates every point to the left. | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_rnd_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
57+
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> This operation rotates every point to the left. | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_rnd_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
5858
| $$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix}$$ <p> This operation flips every point and rotates to the right.| <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_rnd_3.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
5959

6060
At this stage, it *might* be clear what is going on, but it's not exactly obvious.
@@ -71,7 +71,7 @@ The easiest way to make sense of this is to show the operations on the Barnsley
7171
| -------- | --------- |
7272
| $$f_1(P) = \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_fern_0.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
7373
| $$f_2(P) = \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_fern_1.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
74-
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_fern_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
74+
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_fern_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
7575
| $$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix}$$ | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/affine_fern_3.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
7676

7777
Here, the self-similar nature of the fern becomes apparent.
@@ -86,7 +86,7 @@ To account for this, each function is also given a probability of being chosen:
8686
| -------- | ----------- |
8787
| $$f_1(P) = \begin{bmatrix} 0 &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ | 0.01 |
8888
| $$f_2(P) = \begin{bmatrix} 0.85 &0.04 \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | 0.85 |
89-
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | 0.07 |
89+
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ | 0.07 |
9090
| $$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0.44 \end{bmatrix}$$ | 0.07 |
9191

9292
## Playing around a bit...
@@ -98,7 +98,7 @@ Here are a few examples of ferns that can be generated by modifying constituent
9898
| -------- | --------- |
9999
| $$f_1(P) = \begin{bmatrix} \tau &0 \\ 0 &0.16 \end{bmatrix}P + \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5 $$ <p> Turning stems to leaves | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/fern_twiddle_0.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
100100
| $$f_2(P) = \begin{bmatrix} 0.85 & \tau \\ -0.04 &0.85 \end{bmatrix}P + \begin{bmatrix} 0 \\ 1.6 \end{bmatrix}$$ <p> where $$ -0.01 < \tau < 0.09 $$ <p> Changing fern tilt | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/fern_twiddle_1.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
101-
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &022 \end{bmatrix}P + \begin{bmatrix} \tau \\ 1.6 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking left leaves | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/fern_twiddle_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
101+
| $$f_3(P) = \begin{bmatrix} 0.2 &-0.26 \\ 0.23 &0.22 \end{bmatrix}P + \begin{bmatrix} \tau \\ 1.6 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking left leaves | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/fern_twiddle_2.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
102102
| $$f_4(P) = \begin{bmatrix} -0.15 &0.28 \\ 0.26 &0.24 \end{bmatrix}P + \begin{bmatrix} \tau \\ 0.44 \end{bmatrix}$$ <p> where $$-0.5 < \tau < 0.5$$ <p> Plucking right leaves | <div style="text-align:center"> <video style="width:100%" controls loop> <source src="res/fern_twiddle_3.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> |
103103

104104
As an important note: the idea of modifying a resulting image by twiddling the knobs of an affine transform is the heart of many interesting methods, including fractal image compression where a low resolution version of an image is stored along with a reconstructing function set to generate high-quality images on-the-fly {{ "fractal-compression" | cite }}{{ "saupe1994review" | cite }}.
@@ -135,6 +135,8 @@ The biggest differences between the two code implementations is that the Barnsle
135135
[import, lang:"java"](code/java/Barnsley.java)
136136
{% sample lang="coco" %}
137137
[import, lang:"coconut"](code/coconut/barnsley.coco)
138+
{% sample lang="hs" %}
139+
[import, lang:"haskell"](code/haskell/Barnsley.hs)
138140
{% endmethod %}
139141

140142
### Bibliography

contents/barnsley/code/c/SConscript

-6
This file was deleted.

0 commit comments

Comments
 (0)