This file contains hidden or 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
/** | |
Output in a typical compiler / architecture will be: | |
sizeof(a) = 24 | |
offset(a.f16) = 0 | |
offset(a.f32) = 4 | |
offset(a.f08) = 8 | |
offset(a.f64) = 16 | |
sizeof(b) = 16 | |
offset(b.f64) = 0 |
This file contains hidden or 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
package poisson; | |
import java.util.Random; | |
/** | |
* Simple implementation for poisson process random number generation. | |
* Check http://github.com/edrdo/PoissonProcess | |
* | |
* @author Eduardo R. B. Marques | |
* |
This file contains hidden or 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 containing a method to determine the number of days in a month. | |
// I use it sometimes for pedagogical purposes in software testing/engineering courses. | |
public class DaysInMonth { | |
/** | |
* Get number of days in a month. | |
* @param m Month. | |
* @param y Year. | |
* @return Number of days of given month and year. | |
*/ | |
public static int daysInMonth(int m, int y) { |
This file contains hidden or 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
% Reference: "A perfect smoother", PHC Eilers - Analytical chemistry, 2003 | |
% This is the simplest formulation - check Eilers' article for an alternative implementation making use of sparse matrixes. | |
function z = whittakerSmoother(y,lambda) | |
m = length(y); | |
I = eye(m); | |
D = diff(I); | |
z = (I + lambda * D' * D)\y; | |
end | |
% Test |
This file contains hidden or 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
*.aux | |
*.toc | |
*.out | |
*.bbl | |
*.blg | |
*.log | |
*.synctex.gz |
This file contains hidden or 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 random | |
class PoissonProcess(object): | |
def __init__(self, rate, seed=None): | |
self.prng = random.Random(seed) | |
self.rate = rate | |
def timeTillNextEvent(self): | |
return self.prng.expovariate(self.rate) |
This file contains hidden or 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 heapq | |
import time | |
import os | |
class EDFQueue(object): | |
def __init__(self): | |
self.heap = [] | |
def count(self): | |
return len(self.heap) |
This file contains hidden or 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
/** | |
* Eduardo R. B. Marques. | |
* | |
* Basic pthread_barrier_XXX functionality (not part of the standard Pthreads library). | |
* | |
* Note: no error checking for now. | |
*/ | |
typedef struct { | |
unsigned size; // threads that should join barrier |
This file contains hidden or 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
DROP PROCEDURE IF EXISTS string_split; | |
DELIMITER $ | |
CREATE PROCEDURE string_split | |
(IN string TEXT, IN sep CHAR(1), OUT num INT) | |
BEGIN | |
DECLARE pos INT; | |
DECLARE aux TEXT; | |
DECLARE str text; |
This file contains hidden or 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
package qses.tea; | |
/** | |
* Implementation of the Tiny Encryption Algorithm (TEA). | |
* The Tiny Encryption Algorithm is one of the fastest and most efficient | |
* cryptographic algorithms in existence. It was developed by David Wheeler and | |
* Roger Needham at the Computer Laboratory of Cambridge University. | |
* | |
* See http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps | |
* |
OlderNewer