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 numpy as np | |
from numpy.polynomial import Polynomial | |
def polynomial_modulo(polynomial, mod): | |
q, r = divmod(polynomial, mod) | |
return r | |
def mod_on_coefficients(polynomial, modulo): | |
coefs = polynomial.coef | |
mod_coefs = [c % modulo for c in coefs] |
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
## ----setup---- | |
library(polynom) | |
library(HEtools) | |
## ----params---- | |
d = 4 | |
n = 2^d | |
p = (n/2)-1 | |
t = p | |
q = 868 |
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
// ==UserScript== | |
// @name Google Docs Side Panel Hide | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-04-21 | |
// @description Hide the Google Docs Side Panel (Calendar, Keep, Maps, etc.) toggle button for a clean slate. | |
// @author Bastiaan Quast | |
// @match https://docs.google.com/document/d/* | |
// @icon none | |
// @grant GM_addStyle | |
// ==/UserScript== |
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 numpy as np | |
from numpy.polynomial import Polynomial | |
def polynomial_modulo(polynomial, mod): | |
""" | |
Perform polynomial modulo operation using divmod. | |
""" | |
q, r = divmod(polynomial, mod) | |
return r |
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 numpy as np | |
from numpy.polynomial import Polynomial | |
def polynomial_modulo(polynomial, mod): | |
""" | |
Perform polynomial modulo operation using divmod. | |
""" | |
q, r = divmod(polynomial, mod) | |
return r |
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
library(polynom) | |
M <- 8 | |
N <- M %/% 2 | |
scale <- 64 | |
xi <- complex(real = cos(2 * pi / M), imaginary = sin(2 * pi / M)) | |
vandermonde <- function(xi, M) { | |
N <- M %/% 2 | |
# Initialize an empty matrix with complex data type |
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 numpy as np | |
from numpy.polynomial import Polynomial | |
# Set the parameters | |
M = 8 | |
N = M // 2 | |
scale = 64 | |
xi = np.exp(2 * np.pi * 1j / M) | |
def vandermonde(xi: np.complex128, M: int) -> np.array: |
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
library(matrixStats) | |
# Softmax function | |
softmax <- function(x) { | |
exp_x <- exp(x - max(x)) | |
exp_x / sum(exp_x) | |
} | |
# Scaled dot product attention | |
scaled_dot_product_attention <- function(Q, K, V, mask = NULL) { |
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
# HE illustrated primer | |
# define some parameters (small as an example) | |
# N.B. these parameters are not secure, they are completely insecure | |
d = 4 | |
n = 2^d | |
t = (n/2)-1 | |
q = 874 | |
# load library to create polynomials |
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
# HE illustrated primer | |
# define some parameters (small as an example) | |
# N.B. these parameters are not secure, they are completely insecure | |
n = 4 | |
d = 2^n | |
t = 7 | |
q = 874 | |
# load library to create polynomials |
NewerOlder