Skip to content

Instantly share code, notes, and snippets.

Maurizio Tomasi ziotom78

Block or report user

Report or block ziotom78

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ziotom78
ziotom78 / numbahpix.py
Last active Jan 29, 2020
Comparison between Healpy functions and a Numba-based implementation
View numbahpix.py
# -*- encoding: utf-8 -*-
import numpy as np
import math
from numba import njit, vectorize, int32, int64, float32, float64
@njit
def normalize_angle(ang):
result = ang
@ziotom78
ziotom78 / extract_bandpasses.jl
Created May 22, 2019
Save Strip bandpasses using Stripeline
View extract_bandpasses.jl
import Stripeline
import DelimitedFiles
db = Stripeline.InstrumentDB()
for horn in keys(db.focalplane) |> collect |> sort
curdet = db.detectors[db.focalplane[horn].polid]
curdet.band == "W" && continue
response = curdet.bandshape
freqs = range(response.lowest_frequency_hz, response.highest_frequency_hz, length=response.num_of_frequencies) ./ 1e9
filename = "$(horn).txt"
@ziotom78
ziotom78 / README.txt
Last active Aug 29, 2015
A CSS style for Nim documentation
View README.txt
To compile the SASS files into "nimdocs.css", install SASS
gem install sass
and then run
sass -t compressed nimdocs.scss:nimdocs.css
Maurizio Tomasi
December 2014
@ziotom78
ziotom78 / mean_test.cpp
Created Jun 22, 2012
Mean calculation test
View mean_test.cpp
#include <iostream>
#include <vector>
template<typename T> T
mean_with_accumulator(const std::vector<T> & vec)
{
T acc = 0.0;
for(T cur_element : vec)
acc += cur_element;
@ziotom78
ziotom78 / doubleWithReference.s
Created Oct 14, 2011
Assembly code produced by GCC 4.2.1 for the "doubleThis" function (with reference parameter)
View doubleWithReference.s
__Z24doubleThisRd:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movsd (%rax), %xmm0 # Put in xmm0 the value pointed by RAX
addsd %xmm0, %xmm0 # Calculate x+x instead of 2x
leave
ret
@ziotom78
ziotom78 / doubleWithReference.cpp
Created Oct 14, 2011
Double a floating-point value (with reference parameter)
View doubleWithReference.cpp
double
doubleThis(double & x)
{
return x * 2;
}
@ziotom78
ziotom78 / double.s
Created Oct 14, 2011
Assembly output of GCC 4.2.1 for the "doubleThis" function
View double.s
__Z11doubleThisd:
pushq %rbp
movq %rsp, %rbp
movsd %xmm0, -8(%rbp)
movsd -8(%rbp), %xmm0 # Directly copy the parameter into the FP register
addsd %xmm0, %xmm0 # Calculate x+x instead of 2x
leave
ret
@ziotom78
ziotom78 / double.cpp
Created Oct 14, 2011
Double a floating-point number (version without reference argument)
View double.cpp
double
doubleThis(double x)
{
return x * 2;
}
@ziotom78
ziotom78 / problem34.py
Created Sep 28, 2011
Solution of Project Euler's problem 34 (Python)
View problem34.py
def fact (n):
"Return n!."
if n < 2:
return 1
else:
result = 1
for i in xrange (2, n + 1):
result = result * i
return result
@ziotom78
ziotom78 / problem34.clj
Created Sep 28, 2011
Solution for Project Euler's problem 34 (Clojure)
View problem34.clj
(defn fact
"Return n!."
[^Integer n]
(if (< n 2)
1
(apply * (range 2 (+ n 1)))))
(def fast-fact
; This is a faster version of "fact", using a dictionary to return the
; factorial for any number between 0 and 9 (the only kind of number for which
You can’t perform that action at this time.