Skip to content

Instantly share code, notes, and snippets.

View amir734jj's full-sized avatar
🎮
Working from home

Seyedamirhossein Hesamian amir734jj

🎮
Working from home
  • Microsoft, Redmond
  • United States
  • LinkedIn in/hesamian
View GitHub Profile
Double N = new Double(
"16260595201356777876687102055392856230368799478725437225418970788404092751540966827614883675066492383688147288741223234174448378892794567789551235835087027626536919406320142455677084743499141155821894102610573207343199194327005172833989486958434982393556326206485954223151805798621294965926069728816780985683043030371485847746616146554612001066554175545753760388987584593091716701780398711910886679925612838955858736102229719042291682456480437908426849734556856917891628730543729446245974891735371991588505429152639045721840213451875487038496578525189542369448895368117152818687795094021869963915318643663536132393791");
double delta = 0.26;
System.out.print(Math.pow(N.doubleValue(), delta));
Ring ring1 = new Ring("x^2 + 23 *3y + x^3y^z");
Ring ring2 = new Ring("x^2 + 23 *3y + x*3y+z");
Ring ring3 = new Ring("x^2 + (23 *3y) + x^3y^z");
Ring ring4 = new Ring("x^2 + (23 *(2 + x)*3y)+z");
Ring ring5 = new Ring("2+16/2^4");
Ring ring6 = new Ring("2+16/2^4*2");
Ring ring7 = new Ring("2+16/2^4*2+(3-1*3-4^4^5)");
Ring ring8 = new Ring("4^4^5");
Ring ring9 = new Ring("4^4^5*3/3-1^4^5");
Ring ring10 = new Ring("4^4^5*3/3-1^(4^5)");
@amir734jj
amir734jj / Ring-LWE.sage
Created September 30, 2016 04:52
Ring LWE KE
from random import randint
def generate_matrix(dimention, modulus):
array = []
upper_limit = modulus * dimention
for i in range(0, dimention):
f = 0
for j in range(0, dimention):
f = f + (randrange(modulus, upper_limit) * x^j)
@amir734jj
amir734jj / flatten_unflatten_matrix .sage
Created October 21, 2016 03:28
flatten and unflatten matrix in Sage via numpy
import numpy as np
from sage.stats.distributions.discrete_gaussian_lattice import DiscreteGaussianDistributionLatticeSampler
n = 256
D = DiscreteGaussianDistributionLatticeSampler(ZZ^n, 3.0)
arr = [list(D()) for i in range(n)]
flat = flatten(list(arr))
import asyncio
from time import sleep
from threading import Thread, Lock
from .task_model import Task
from typing import List
lock = Lock()
class TaskManager:
@amir734jj
amir734jj / curry-compose.cs
Created March 10, 2019 17:43
csharp functional extensions
public static Func<TArg1, Func<TArg2, TResult>> Curry<TArg1, TArg2, TResult>(this Func<TArg1, TArg2, TResult> source)
{
return x => y => source(x, y);
}
public static Func<TArg1, Func<TArg2, Func<TArg3, TResult>>> Curry<TArg1, TArg2, TArg3, TResult>(this Func<TArg1, TArg2, TArg3, TResult> source)
{
return x => y => z => source(x, y, z);
}
"A,B\na,b".split(/\r?\n/).map(x => x.split(',').map(x => `"${x}"`).join(',')).join('\n')
@amir734jj
amir734jj / Makefile
Created April 5, 2021 07:35
make: *** No rule to make target 'grammar.aps'. Stop.
SPECS=First Follow
EXAMPLES_PATH=../..
ROOT_PATH=../${EXAMPLES_PATH}
SCALAV=2.12
APSLIB=${ROOT_PATH}/lib/aps-library-${SCALAV}.jar
SCALA_FLAGS=.:${APSLIB}
APS2SCALA=${ROOT_PATH}/bin/aps2scala
.PHONY:
all: $(addsuffix Spec.compile, $(SPECS)) $(addsuffix Spec.run, $(SPECS))
public record Cfg<T>(T Root, HashSet<T> Vertices, HashSet<(T, T)> Edges) where T : IEquatable<T>
{
private Dictionary<(T, T), bool> reach => Reach();
private readonly Dictionary<T, HashSet<T>> dom = new();
private readonly Dictionary<T, HashSet<T>> pred = new();
/// <summary>
/// <see href="https://en.wikipedia.org/wiki/Dominator_(graph_theory)#Algorithms"/>
@amir734jj
amir734jj / First-components.txt
Created July 8, 2022 13:13
SCC components of First
Components of Phylum Graph: Grammar
Component #0
G[Grammar]'shared_info$epsilon
Component #1
G[Grammar]'shared_info
Component #2
G[Grammar]'shared_info$firstTable!
G[Grammar]'shared_info$firstTable
Component #3
grammar_first