This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat fib.c | |
int fib(int n) { | |
int a = 0; | |
int b = 0; | |
int c = 1; | |
if (n <= 0) { | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpmath import mp, mpf | |
import struct | |
import sys | |
def cvt(f): | |
return struct.unpack('d', struct.pack('Q', f))[0] | |
def centroid(poly): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Point = (f64, f64); | |
const POLY: &[Point] = &[ | |
(40547359.805348977, 20991407.4519994), | |
(40547406.539216213, 20991408.345532853), | |
(40547405.607148655, 20991456.331498079), | |
(40547358.891922772, 20991455.404874228), | |
]; | |
fn naive_centroid(poly: &[Point]) -> Point { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iomanip> | |
#include <iostream> | |
#include <boost/geometry.hpp> | |
int main() { | |
using point_type = boost::geometry::model::d2::point_xy<double>; | |
using polygon_type = boost::geometry::model::polygon<point_type>; | |
polygon_type poly {{ | |
{40547359.805348977, 20991407.4519994}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
sim=qemu-system-alpha # insert any needed path/prefix here | |
$sim -smp 4 -m 1024 \ | |
-kernel vmlinux \ | |
-nographic \ | |
-serial null -monitor null \ | |
-drive file=disk.img,if=virtio,media=disk,format=raw,index=0 \ | |
-net nic,model=virtio -net tap,helper=/usr/libexec/qemu-bridge-helper,br=virbr0 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
************** | |
*** X86_64 *** | |
************** | |
~/alpha-test-programs/fib $ time echo 40 | ./a.out | |
102334155 | |
102334155 | |
real 0m0.661s | |
user 0m0.658s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn do_test(x: usize) { | |
let arr = vec![vec![0u8; 3]]; | |
let mut z = Vec::new(); | |
for arr_ref in arr { | |
for y in 0..x { | |
for _ in 0..1 { | |
z.extend(std::iter::repeat(0).take(x)); | |
let a = y * x; | |
let b = (y + 1) * x - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'main.7rcbfp3g-cgu.2' | |
source_filename = "main.7rcbfp3g-cgu.2" | |
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-unknown-linux-gnu" | |
%"alloc::vec::Vec<i32>" = type { [0 x i64], { i32*, i64 }, [0 x i64], i64, [0 x i64] } | |
%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] } | |
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] } | |
@vtable.0.llvm.14851218111650171626 = external hidden unnamed_addr constant { void (i8**)*, i64, i64, i32 (i8**)*, i32 (i8**)*, i32 (i8**)* }, align 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn do_test(x: usize) { | |
let arr = vec![vec![0u8; 3]]; | |
let mut z = vec![0]; | |
for arr_ref in arr { | |
for y in 0..x { | |
for _ in 0..1 { | |
z.reserve_exact(x); | |
let iterator = std::iter::repeat(0).take(x); | |
let mut cnt = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctype.h> | |
#include <stdio.h> | |
int openbsd_check(const char* line) { | |
if (isdigit((int)*line) && *(line + 1) == '.' && | |
isdigit((int)*line+2) && *(line + 3) == '.' && | |
isdigit((int)*line+4) && isspace((int)*(line + 5))) | |
return 1; | |
else | |
return 0; |