分形/mightymandel
mightymandel 是由 Claude Heiland-Allen 建立的 Mandelbrot 集合探索器。這裡可以找到關於它的非官方文件
- 繪製具有 Mandelbrot 集合邊界的復二次多項式的引數平面
- 許可證 GPL3+ [1]
- 使用級數逼近的擾動技術。 [2]
- 基於 OpenGL 4 的 GPGPU [3] (“我的 GPU 比我的 CPU 快得多”)
- 使用 C(C99)編寫,提供完整的原始碼 [4]
- 多精度
Claude Heiland-Allen [4] 使用中心和半徑來 描述引數平面。
半徑定義為“中心和軸對齊的檢視矩形的頂部之間的虛座標差”。
因此平面由 3 個數字描述
- center_re
- center_im
- radius
其中 center = center_re + center_im * i
可以使用 ldd 檢查它
ldd -d -v ./src/mightymandel
或者檢視 /src/Makefile
-lGLEW -lGL -lrt -lmpfr -lm
在 Debian Jessie 上,這足以安裝編譯所需的一切:[9]
sudo aptitude install \
build-essential \
git \
libglew-dev \
libglfw3-dev \
libmpfr-dev \
pkg-config
首次
git clone https://gitorious.org/maximus/mightymandel.git
要更新原始碼,請執行(從程式目錄)
git pull
然後可以 構建程式。
git remote show origin
結果
* remote origin
Fetch URL: https://gitorious.org/maximus/mightymandel.git
Push URL: https://gitorious.org/maximus/mightymandel.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (fast-forwardable)
git describe
示例輸出
v14-164-g9cd6fc7
進入 mightymandel 目錄
cd ~/mightymandel
然後 make
make -C src clean
make -C src
或者,如果遇到問題:[10]
make -C src EXTRA_LINK_FLAGS="-lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi"
或者編輯 Makefile 並新增額外的標誌,但之後更新原始碼就會遇到問題。
還可以構建並執行 測試套件
Package glfw3 was not found in the pkg-config search path.
下載並安裝 glfw:[11]
cd glfw-3.0.4
hash -r
cmake -G "Unix Makefiles"
make
sudo make install
Ubuntu 14.10 (utopic) 有 glfw3 的軟體包 [12](但 CUDA 軟體包僅適用於 Ubuntu 的 LTS 版本,現在是 13.04)
下一個錯誤
LINK mightymandel /usr/bin/ld: /usr/local/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to symbol 'XConvertSelection' /usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
在 makefile 中新增(在 Ubuntu 13.10 64 位上)
-lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi \
file ./mightymandel ./mightymandel: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x2a424b6dcad8de5e29e3f0b17524dbf34de18aaa, not stripped
轉到程式目錄並
./src/mightymandel
./src/mightymandel—version
示例結果
v16-10-gd079448+2015-01-20-16-40-55
可以使用以下方法執行(從程式目錄)示例引數檔案 fp32.mm:
./src/mightymandel ./examples/mm/fp32.mm
現在 mightymandel 無法載入原生 fractint par 檔案。它們需要被轉換為 ppar 檔案。
如何預處理 Fractint par 檔案?
- 將 txt 檔案(包含多個影像的引數)拆分為單個影像檔案(包含原始檔案 7 行內容)
- 將包含多個引數的行拆分為每行一個引數的行(將空格替換為換行符)
- 新增 ppar 副檔名:[13]
- 刪除所有不包含以下內容的 par 檔案:
- "type=mandel"(mightymandel 只能繪製曼德勃羅集合)
- "corners=" 或 "center-mag="
#!/usr/bin/env bash
# chmod +x s.sh
# ./s.sh
for f in *.txt;
do
echo " found "$f " file ";
#split -l 7 $f;
awk '/{/{n++}{print > n".p" }' $f
echo $f "- split when { is found and add p extension " ;
rm $f;
echo " input file " $f " is removed " ;
done
for f in *.p;
do
echo " in "$f " file replace space with newline and add ppar extension"
# tr '{}' '()' < infile > outfile
tr ' ' '\n' < $f >$f"par"
rm $f;
done
for f in *.ppar;
do
echo "remove blank= empty lines"
sed -i '/^$/d' $f
done
評論: "預處理指令碼會移除輸入檔案而不提示,這有點粗魯!而且它不支援合併以 \ 結尾的行" Claude
以下是 Claude 編寫的 split2ppar.sh 指令碼
#!/bin/bash
tmp="$(mktemp -d --tmpdir=. split2ppar.XXXXXXXX)"
for file in "${@}"
do
name="$(basename "${file}")"
file="$(readlink -e "${file}")"
pushd "${tmp}"
awk "/{/{n++}{print > \"${name}_\"n\".par\" }" "${file}"
popd
done
pushd "${tmp}"
for file in *.par
do
ident="$(head -n 1 "${file}" | sed 's/ .*$//')"
mv "${file}" "${ident}.par" # rename input
cat < "${ident}.par" | # read input
sed 's/;.*$//' | # delete ; comments
tr '\n' ' ' | # join on one line with spaces
sed 's/\\ *//g' | # merge lines ended with '\'
tr -s ' ' | # compress multiple ' ' to single ' '
sed 's/^.*{\([^}]*\)}.*$/\1/' | # extract the part between { }
tr ' ' '\n' | # split into separate lines
cat > "${ident}.ppar" # write output
done
popd
ls "${tmp}/"*
ppar
[edit | edit source]預處理後的 par 檔案位於 /examples/ppar 目錄中。請使用以下方法進行測試:
./src/mightymandel ./examples/ppar/1_02.ppar
test
[edit | edit source]可以執行測試套件
make -C src test EXTRA_LINK_FLAGS="-lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi"
示例輸出
real 56m25.351s user 33m50.995s sys 21m38.976s
另請參閱
- test 目錄中 csv 檔案的內容
- test 目錄中的影像
基準測試
[edit | edit source]有關更多詳細資訊,請參見程式目錄中的 BENCHMARKS 檔案
檢查硬體
[edit | edit source]示例輸出
cat /proc/cpuinfo | grep model\ name
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GK104 [GeForce GTX 770] (rev a1)
glxinfo | grep OpenGL\ version
OpenGL version string: 4.3.0 NVIDIA 319.32
執行基準測試
[edit | edit source] time ./src/mightymandel --verbose warn --one-shot --de --weight -1.5 --glitch --size "1280x720" examples/mm/fp32-large-minibrot.mm
fp32-large-minibrot.mm,ok,fp32,322.402263,85.265842,14.734158,,
real 0m0.643s
user 0m0.188s
sys 0m0.236s
影像
[edit | edit source]畫廊
- 在維基共享資源中有一個類別: commons:Category:Fractals created with Mightymandel
- 官方線上文件畫廊[19]
評論
[edit | edit source]要從 ppm 檔案中提取評論:[20]
identify -format "%c" 1.ppm
或者
head -n 2 1.ppm | tail -n 1
示例輸出
mightymandel -1.8605739600158748e+00 + -9.3437424499999996e-07 i @ 3.5884749956982262e-09
以及從 png 檔案中提取評論
extract k2000.png
顏色
[edit | edit source]- 白色 = 曼德勃羅集合的外部
- 黑色 = 曼德勃羅集合的邊界(使用 DEM)
- 紅色 = 故障
- 黃色 = RGB(255,178,0) = 已知的曼德勃羅集合內部
- 藍色 = 未計算
文件
[edit | edit source]- 官方線上文件[21]
如何使用 doxygen 生成離線文件?
[edit | edit source]如何貢獻?
[edit | edit source]git checkout master
git pull # get up to date
git checkout -b new-feature-42 # create a branch for your new feature
# make your changes, check that they compile and run ok
git add your-changed-files
git commit # write a description of your changes
git format-patch master # save your changes to file(s)
如果路徑檔案未建立,請嘗試
git format-patch origin/master # https://eothred.wordpress.com/2011/07/02/git-and-patches/
然後將 .patch 檔案傳送電子郵件給 Claude
參考文獻
[edit | edit source]- ↑ License GPL3+
- ↑ Perturbation glitches
- ↑ General-purpose computing on graphics processing units in wikipedia
- ↑ Git repository
- ↑ The OpenGL Extension Wrangler Library
- ↑ OpenGl in C
- ↑ The GNU MPFR Library
- ↑ librt library
- ↑ README for mightymandel
- ↑ Fractal Forum - mightymandel
- ↑ and Ubuntu
- ↑ Package: glfw3 (3.0.4-1) [universe]
- ↑ how-to-add-an-extension-to-all-files-via-terminal
- ↑ CPU in wikipedia)
- ↑ GPU in wiki[edia
- ↑ Video card in wiki
- ↑ Device driver in wikipedia
- ↑ OpenGl in wikipedia
- ↑ online official doc gallery
- ↑ stackexchange question : How to extract comment from ppm file?
- ↑ official online doc