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
# Gunvir Singh Ranu | |
# Last Updated: 2024-01-29 | |
# Options as of clang-format 19 | |
# Commented out some currently unsupported by CLion | |
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: BlockIndent | |
AlignArrayOfStructures: Right | |
AlignConsecutiveAssignments: None | |
AlignConsecutiveBitFields: Consecutive |
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
# Generating some parameters and the public-private key-pair | |
p, q = 997, 991 # Two "big" secret prime numbers | |
N = p * q # This is public | |
phi = (p - 1) * (q - 1) # This *must* be private! | |
public = 65537 # Choose some prime that's not a factor of `phi` | |
assert phi % public != 0 | |
# Inverse of `e` mod `phi` found using Euclidean algo | |
# The important part is that you *need* `phi` to calculate this | |
private = 919313 | |
assert (private * public) % phi == 1 # Make sure it's the inverse |
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
import struct | |
from decimal import * | |
getcontext().prec = 40 | |
x = 1.987654321987654321 | |
h = int.from_bytes(struct.pack(">d", x), "big") | |
f = h & ((1 << 52) - 1) | |
e = (h >> 52) & ((1 << 11) - 1) | |
s = h >> 63 |
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
import math | |
from decimal import * | |
# Max precision `prec` you'd want | |
getcontext().prec = 80 | |
def integral_root(num): | |
for i in range(int(num) + 1): | |
if i ** 2 == num: | |
return i |
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
// Created by: Gunvir Ranu | |
// License: WTFPL | |
// | |
// If you want to use another type or don't like the `real` alias, a simple | |
// find and replace should suffice. If you really wanna get generic, throw this | |
// bad boy in a `template <typename real>` and you're set. | |
#include <ostream> | |
#include <cmath> |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
""" | |
Bifurcation Diagram | |
""" | |
# Number of `r` steps in closed interval [0.5, 4] | |
rsteps = 1000 | |
# Values of r between [0.5, 4], but can be changed to zoom |
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
public class Vector2D { | |
public double x; | |
public double y; | |
public Vector2D() { } | |
public Vector2D(double x, double y) { | |
this.x = x; |