Skip to content

Instantly share code, notes, and snippets.

View odarbelaeze's full-sized avatar
:shipit:
Ship it.

Oscar Arbeláez-Echeverri odarbelaeze

:shipit:
Ship it.
View GitHub Profile
@odarbelaeze
odarbelaeze / gist:5867459
Created June 26, 2013 13:43
Using std::copy to cast between container types with c++11.
#include <algorithm>
#include <iostream>
#include <valarray>
#include <vector>
template<typename T>
std::ostream& operator<< (std::ostream& os, std::valarray<T> va)
{
for (auto&& i : va)
os << i << " ";
@odarbelaeze
odarbelaeze / sho.cc
Last active December 16, 2015 07:39
A [VMC](http://en.wikipedia.org/wiki/Variational_Monte_Carlo) implementation to find the ground state of the Simple Harmonic Oscillator.
// Compile with g++ -O2 -std=c++0x sho_test.cc -o sho_test
// or (gnu gcc 4.7 or above)
// Compile with g++ -O2 -std=c++11 sho_test.cc -o sho_test
// This package finds the ground state of the Simple Harmonic Oscillator
// with a test function \frac{\sqrt\alpha}{\pi^{\frac{1}{4}}} \exp( - \frac{1}{2} x^2\alpha^2)
#include <cmath>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <exception>
#include <iostream>
#include <sstream>
#include <string>
// 1234--------
template<typename T>
class Stack
@odarbelaeze
odarbelaeze / problem3nplus1.cpp
Last active December 16, 2015 05:59
The 3n + 1 problem with some error
#include <iostream>
int cycle_lenght (int i)
{
int lenght = 1;
int n = i;
while (n != 1)
{
n = n % 2 == 0? n / 2 : 3 * n + 1;
lenght++;
@odarbelaeze
odarbelaeze / QeueArray.cpp
Last active October 11, 2020 17:52
A FIFO Stack implementation using a simple array.
#include <iostream>
#include <exception>
#include <stdexcept>
#include <functional>
#include <string>
// 1234--------
template<typename T>
class QeueArray
@odarbelaeze
odarbelaeze / DEQueue.cpp
Last active October 11, 2020 17:52
A DEQeue implementation in C++.
#include <exception>
#include <functional>
#include <iostream>
#include <stdexcept>
#include <string>
template<typename T>
class DEQeue
{
public: