Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions specs/physics/physical_limits.t27
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module physical_limits {
}

// Landauer: the least energy, in joules, to erase one bit at temperature t kelvin.
fn landauer_j(t: f64) -> f64 {
pub fn landauer_j(t: f64) -> f64 {
return K_B * t * LN2;
}

Expand Down Expand Up @@ -161,7 +161,7 @@ module physical_limits {
}

// Bits needed to name one of n symbols: the smallest k with 2^k >= n.
fn index_bits(n: f64) -> f64 {
pub fn index_bits(n: f64) -> f64 {
var k : f64 = 0.0;
var cap : f64 = 1.0;
while (cap < n) {
Expand All @@ -172,12 +172,12 @@ module physical_limits {
}

// The energy of one token, from the per-prompt figure and a reply length.
fn token_energy_j(prompt_j: f64, tokens: f64) -> f64 {
pub fn token_energy_j(prompt_j: f64, tokens: f64) -> f64 {
return prompt_j / tokens;
}

// How many times the energy spent exceeds the Landauer cost of erasing bits bits at t kelvin.
fn gap(e_j: f64, bits: f64, t: f64) -> f64 {
pub fn gap(e_j: f64, bits: f64, t: f64) -> f64 {
return e_j / (bits * landauer_j(t));
}

Expand Down
16 changes: 8 additions & 8 deletions specs/t27f/particle_engine.t27
Original file line number Diff line number Diff line change
Expand Up @@ -272,38 +272,38 @@ module particle_engine {

// ---- optics ----

fn fresnel_r0(n: f64) -> f64 {
pub fn fresnel_r0(n: f64) -> f64 {
const a = (n - 1.0) / (n + 1.0);
return a * a;
}

// Schlick reflectance at an angle of incidence whose cosine is c.
fn schlick(c: f64, n: f64) -> f64 {
pub fn schlick(c: f64, n: f64) -> f64 {
const r0 = fresnel_r0(n);
const k = 1.0 - c;
return r0 + (1.0 - r0) * k * k * k * k * k;
}

// Cosine of the incidence angle at which the camera sees, in the floor, a body at height y.
fn mirror_cos(y: f64) -> f64 {
pub fn mirror_cos(y: f64) -> f64 {
const d = CAM_D * CAM_H / (CAM_H + y);
return CAM_H / @sqrt(CAM_H * CAM_H + d * d);
}

fn mirror_alpha(y: f64, glow: f64) -> f64 {
pub fn mirror_alpha(y: f64, glow: f64) -> f64 {
return glow * schlick(mirror_cos(y), N_LACQUER);
}

fn glow_of(vx: f64, vy: f64) -> f64 {
pub fn glow_of(vx: f64, vy: f64) -> f64 {
return 1.0 + (vx * vx + vy * vy) / (V_REF * V_REF);
}

fn gauss(d2: f64, r: f64) -> f64 {
pub fn gauss(d2: f64, r: f64) -> f64 {
return @exp(0.0 - d2 / (2.0 * r * r));
}

// Exposure: light adds, the film never clips.
fn expose(l: f64) -> f64 {
pub fn expose(l: f64) -> f64 {
return 255.0 * (1.0 - @exp(0.0 - l));
}

Expand All @@ -329,7 +329,7 @@ module particle_engine {

// Hertz push between two elastic spheres whose centres are sqrt(r2) apart and touch at d0:
// F = K d^(3/2), U = (2/5) K d^(5/2) for an overlap d (H. Hertz, J. reine angew. Math. 92, 156, 1882).
fn contact_f_over_r(r2: f64, d0: f64) -> f64 {
pub fn contact_f_over_r(r2: f64, d0: f64) -> f64 {
if (r2 >= d0 * d0) {
return 0.0;
}
Expand Down
6 changes: 3 additions & 3 deletions specs/t27f/reel_particles.t27
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ pub const K_RING : u8 = 1;

// ---- pure pieces, each tested ----

fn lcg(seed: i64) -> i64 {
pub fn lcg(seed: i64) -> i64 {
return @mod(seed * 1103515245 + 12345, 2147483648);
}

fn unit(seed: i64) -> f64 {
pub fn unit(seed: i64) -> f64 {
return @as(f64, @floatFromInt(seed)) / 2147483648.0;
}

Expand Down Expand Up @@ -339,7 +339,7 @@ fn grain_level(seed: i64) -> f64 {
return GRAIN * (unit(seed) - 0.5);
}

fn quantize(x: f64) -> u8 {
pub fn quantize(x: f64) -> u8 {
var y : f64 = @round(x);
if (y < 0.0) { y = 0.0; }
if (y > 255.0) { y = 255.0; }
Expand Down
Loading
Loading