A tiny, bc-like compiler that emits LLVM IR (.ll).
- Numbers (floating point)
- Variables (identifiers)
- Arithmetic:
+ - * / % - Parentheses
- Assignment:
x = 1 + 2;
| import taichi as ti | |
| import taichi.math as tm | |
| import time | |
| import random | |
| ti.init(arch=ti.gpu) | |
| w = 256 | |
| h = 256 | |
| # pixels = ti.field(dtype=float, shape=(h, w)) |
| import taichi as ti | |
| import taichi.math as tm | |
| import time | |
| import random | |
| ti.init(arch=ti.gpu) | |
| w = 1440//2 | |
| h = 1440//2 | |
| # pixels = ti.field(dtype=float, shape=(h, w)) |
| import taichi as ti | |
| import taichi.math as tm | |
| import time | |
| import random | |
| ti.init(arch=ti.gpu) | |
| w = 1440//2 | |
| h = 1440//2 | |
| # pixels = ti.field(dtype=float, shape=(h, w)) |
| length = Compile[{{x, _Real}, {y, _Real}, {\[Theta], _Real}}, | |
| Sin[\[Theta]] + | |
| Sqrt[(x + Sin[\[Theta]])^2 + (y - Cos[\[Theta]])^2]]; | |
| wavelength = 1/128; | |
| phaseSum = Compile[ | |
| {{a, _Integer}, {b, _Integer}, {n, _Integer}, {\[Lambda], _Real}, \ | |
| {x, _Real}, {y, _Real}}, | |
| Module[{i = 0, t = 0. + 0. I}, | |
| For[i = a, i <= b, ++i, | |
| t += \[Pi]/n Exp[I length[x, y, \[Pi]/n i]/\[Lambda]]]; |
| #include <iostream> | |
| const long int N = 22; | |
| long int table[N][1 + 2 * (N + 3) / 4][2 * N + 2][2 * N + 2] = {}; | |
| long int count(long int n, long int w, long int x, long int y) | |
| { | |
| long int in = n; | |
| long int iw = w + 5; |