Does the vscode gistpad extension work well?
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
# %% | |
# Needs to have roster.csv available to convert netid to student name | |
import os | |
import re | |
import pandas as pd | |
AssignmentKey = r"Final Project" | |
# %% | |
allfiles = os.listdir() | |
files = [f for f in allfiles if re.match(r".*\.ipynb$", f)] |
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
## Create the virtual environment | |
conda create -n 'environment_name' | |
## Activate the virtual environment | |
conda activate 'environment_name' | |
## Make sure that ipykernel is installed | |
pip install --user ipykernel | |
## Add the new virtual environment to Jupyter |
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
# More for illustration than practical computation | |
# A "real" algorithm works modulo the determinant of the matrix to avoid blowup in the Euclid algorithm. | |
# See Cohen's book for details | |
# Note: this is designed to mimic the approach over a PID, so you can compute the generator of an ideal (a,b) but there's | |
# no size used (as opposed to in other implementations) | |
import numpy as np | |
def euclid(a,b): |
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
class Gaussian: | |
"Class representing Gaussian integers, with arithmetic operations" | |
def __init__(self,a,b): | |
self._real=a | |
self._imag=b | |
def real(self): | |
return self._real |
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.random import default_rng | |
rng=default_rng() | |
def rA(n): | |
"""make a random nxn integer matrix with entries in the range -30,30""" | |
A=rng.integers(-30,30,size=n*n).reshape(n,n) | |
return A | |
def swapcol(A,i,j): |
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
def euclid(a,b): | |
x0,x1=1,0 | |
y0,y1=0,1 | |
r0,r1=a,b | |
q="" | |
format_string="{:>14} {:>14} {:>14} {:>14}" | |
print(format_string.format("",a,x0,y0)) | |
while r1>0: | |
print(format_string.format(q,r1,x1,y1)) | |
q=r0//r1 |
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 sklearn.linear_model import Ridge | |
# generate data | |
x=np.random.random(n_points) | |
y=np.sin(2*np.pi*x)+np.random.normal(0,0.1,n_points) | |
# make a ridge object with alpha=whatever you want | |
clf = Ridge(alpha=0) | |
# fit the ridge object to the data |
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
def qr(x,y): | |
q=x//y | |
r=x-q*y | |
if r<0: | |
q+=1 | |
r-=y | |
return q,r | |
def eea(x, y): | |
r0=x |
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
%.html : %.md | |
pandoc -s --mathjax -t slidy $< -o $@ | |
%.pdf : %.md | |
pandoc -s --slide-level=2 --variable classoption=t --mathjax -t beamer $< -o $@ |
NewerOlder