Skip to content

Instantly share code, notes, and snippets.

@r9y9
Created January 24, 2016 10:26
Show Gist options
  • Save r9y9/20fb3ab5c4a1fccc3150 to your computer and use it in GitHub Desktop.
Save r9y9/20fb3ab5c4a1fccc3150 to your computer and use it in GitHub Desktop.
Julia and C++
julia> using ProgressMeter
julia> cxx"""
#include <iostream>
#include <cmath>
double FooBar(size_t N) {
double result = 0.0;
$:(global progress_meter = Progress(icxx"return N;", 1); nothing);
for (size_t i = 0; i < N; ++i) {
result = log(1+i) + log(2+i);
$:(next!(progress_meter); nothing);
}
return result;
}
"""
true
julia> @cxx FooBar(100000000)
Progress: 100% Time: 0:00:17
36.84136149790473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment