Skip to content

Instantly share code, notes, and snippets.

View aflaag's full-sized avatar
💭
coding

Alessio Bandiera aflaag

💭
coding
  • Sapienza University of Rome
  • Italy
View GitHub Profile
@aflaag
aflaag / f.s
Last active March 21, 2024 09:18
.globl main
.text
main:
addi $a0, $a0, -3 # a0 = -3
addi $a1, $a1, 4 # a1 = 4
addi $a2, $a2, 5 # a2 = 5
addi $a3, $a3, 8 # a3 = 8
jal f # f(a0, a1, a2, a3)
.globl main
.data
N: .word 5
.text
main:
lw $a0, N($zero) # a0 = N[0]
move $v0, $zero # v0 = 0
@aflaag
aflaag / line.py
Last active October 19, 2023 15:23
Python example that approximates the line passing through the given points.
from numpy import random
EPOCHS = 40_000
RANDOM_ADJUSTMENTS = 32
STEP_SIZE = 0.0001
VERBOSE = True
def cost_function(outputs, expected_values):
total_cost = 0
fn build_max_heap(array: &mut [usize], heap_size: usize) {
(1..=array.len() / 2).rev().for_each(|index| {println!("{}", index);max_heapify(array, index, heap_size);
println!("{:?}", array)});
}
fn get_left_child_index(index: usize) -> usize {
2 * index
}
.globl main
.text
main:
addi $a0, $a0, -3 # a0 = -3
addi $a1, $a1, 4 # a1 = 4
addi $a2, $a2, 5 # a2 = 5
addi $a3, $a3, 8 # a3 = 8
jal f # f(a0, a1, a2, a3)
.globl main
.data
N: .word 3
M: .word 0, 1, 2, 3, 4, 5, 6, 7, 8
.text
main:
la $a0, M # a0 = M pointer
.globl main
.data
L: .word 3
A: .half 0x002A, 0xA5FF, 0x5BE1
.text
main:
# prepare arguments for the parity function
lw $a1, L
@aflaag
aflaag / es.s
Last active March 21, 2024 09:18
.globl main
.data
W: .asciiz "+6-4+3-2"
.text
main:
la $a0, W # a0 = W_address
jal calc
import sys
HEADER_LINES = 7
PADDING_MAP = {
"CodiceLRT": 0,
"Part Name": 0,
"CodiceFornitore": 0,
"Descrizione": 0,
"Valore": 0,
from functools import partial
import jax.numpy as jnp
import jax
# STEP_SIZE = 0.0010
STEP_SIZES = jnp.array([1., 0.5, 0.1, 0.05, 0.01, 0.005, 0.001])
k = STEP_SIZES.shape[0]
STEP_SIZES = STEP_SIZES.reshape((1, k, 1))