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
"""This module defines bitwise operations for fractions. | |
In the same way that rational numbers have repeating decimal expansions ie. 1/3 = 0.333... | |
they also have repeating binary expansions: 1/3 = 0.010101... | |
Bitwise operators can be extended to such expansions and then converted back to rational numbers. | |
Just like we usually don't write 1 as 0.999... this module follows the convention that | |
1 = 1.000... even when expanded in binary. | |
The inversion operator '~' is not defined as ~1 = ...1110.111... would violate this convention. | |
For the same reason bitwise operations between negative numbers result in undefined behaviour. | |
The option to use one's complement for negative numbers ie. -1 = ...1110.111... = ~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
--{-# LANGUAGE TemplateHaskell #-} | |
--import Test.QuickCheck | |
--import Test.QuickCheck.All | |
--prop_cbrt :: Double -> Bool | |
--prop_cbrt x = abs (x - cbrt x ^ 3) < 1e-12 | |
--main = ($quickCheckAll) | |
module Cbrt (cbrt) where |
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 __future__ import division | |
""" | |
This module defines a Ball object for performing lossless kinematics over two dimensional Galilean space. | |
Author: Pyry Pakkanen | |
""" | |
__author__ = "Pyry Pakkanen" | |
__copyright__ = "Copyright 2013" | |
__credits__ = ["Pyry Pakkanen"] |
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 __future__ import division | |
from math import pi, sin, cos, sqrt | |
from sys import version_info | |
if version_info < (3,): | |
from itertools import izip as zip | |
__author__ = "Lumi Pakkanen" |
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 __future__ import division | |
from math import pi, floor, sin, cos, atan2 | |
__author__ = "Lumi Pakkanen" | |
__copyright__ = "Copyright 2014, Lumi Pakkanen" | |
__credits__ = ["Lumi Pakkanen"] | |
__license__ = "MIT" | |
__version__ = "1.0" | |
__maintainer__ = "Lumi Pakkanen" |
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 __future__ import division | |
from math import pi, exp, cosh, cos, log, floor | |
from cmath import rect as from_polar, exp as cexp | |
__author__ = "Lumi Pakkanen" | |
__copyright__ = "Copyright 2014, Lumi Pakkanen" | |
__credits__ = ["Lumi Pakkanen"] | |
__license__ = "MIT" | |
__version__ = "1.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 __future__ import division | |
from math import pi, exp, sin, cos | |
from cmath import rect as from_polar | |
__author__ = "Lumi Pakkanen" | |
__copyright__ = "Copyright 2015, Lumi Pakkanen" | |
__credits__ = ["Lumi Pakkanen"] | |
__license__ = "MIT" | |
__version__ = "1.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
void mirror_d() pure nothrow @nogc @safe | |
in | |
{ | |
assert(valid); | |
assert(can_rotate); | |
} | |
out | |
{ | |
assert(valid); | |
assert(can_rotate); |
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 __future__ import division | |
from argparse import ArgumentParser | |
from itertools import cycle | |
from pylab import * | |
tau = 2 * pi | |
if __name__ == '__main__': | |
parser = ArgumentParser(description='Plot complex rational numbers') |
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
#!/usr/bin/env python3 | |
import argparse | |
BAILOUT = 16 | |
MAX_ITER = 56 | |
def escape_time(c): | |
z = 0j # Squaring accumulator |
OlderNewer