This file contains 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
void inplace_merge(int *first, int *mid, int *end) { | |
int *datacopy[size of data]; | |
int *left = first; | |
int *right = end; | |
int next = 0; | |
int n = end - first; | |
while (next < n) { | |
if (left < mid && *left < *right) { | |
datacopy[next++] = *left; | |
} else if (right < end) { |
This file contains 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
for (int size = 1; size < n; size = 2 * size) { | |
int nSegments = n / size; | |
#pragma omp for | |
for(int segment = 0; segment < nSegments; ++segment) { | |
int leftStart = segment * size; | |
int mid = min(leftStart + (size / 2), n-1); | |
int rightEnd = min(leftStart + size, n-1); | |
merge(data, leftStart, mid, rightEnd); | |
} |
This file contains 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 fs from 'fs'; | |
function oldStyleAsynchronousFunction(callback) { | |
fs.readFile('somefile.txt', 'utf8', function(err, result) { | |
if (err) { | |
callback(err, null); | |
return; | |
} | |
callback(result); |
This file contains 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
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) |
This file contains 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
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) |
This file contains 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
def both_objectives(layout, columns, *args): | |
return (frequency_objective(layout,*args), | |
similarity_objective(layout,*args)) | |
def random_evaluated_design(seed_design, objective_function, *args): | |
"""Return a new random design, evaluated by objective_function""" | |
candidate = random.sample(seed_design, len(seed_design)) | |
return (candidate, *objective_function(candidate, *args)) | |
This file contains 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 | |
def random_search(array, iterations, objective, *args): | |
"""Do a random search over the array for :iterations:.""" | |
best = array[0] | |
best_value = objective(best, *args) | |
for i in range(iterations): | |
candidate = random.sample(best, len(best)) | |
value = objective(candidate, *args) |
This file contains 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
# So generally speaking, if you want to be opening files with Python | |
# its better to observe the "Easier to ask for forgiveness than permission" | |
# principle (EAFP) where just blindly try to open the file as though it | |
# existed and then handle exceptions where it does not: | |
# | |
# The reason why you should do this is two fold: | |
# (1) Checking first always imposes a performance cost due | |
# to the extra system call overhead. | |
# (1.1) Unlike languages like C++, you always pay the | |
# cost of exception paths in Python, so it makes |
This file contains 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
M /metadata | |
M /files/manifest.json | |
M /files/lib/libcontentfeed-0.so.0.0.0 | |
M /files/lib/libeknr-0.so.0.0.0 | |
M /files/lib/libendless-0.so.0.500.0 | |
M /files/lib/libeoscompanion-1.so.0.0.0 | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/__init__.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/applications_query.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/constants.cpython-35.opt-1.pyc | |
M /files/lib/python3.5/site-packages/eoscompanion/__pycache__/content_streaming.cpython-35.opt-1.pyc |
This file contains 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
auto translationMat = glm::translate ( | |
glm::mat4 (1.0), | |
glm::vec3 (agd::get <0> (translation), | |
agd::get <1> (translation), | |
0.0) | |
); | |
auto invCenterMat = glm::translate ( | |
glm::mat4 (1.0), | |
glm::vec3 (-1 * agd::get <0> (intendedCenter), | |
-1 * agd::get <1> (intendedCenter), |
NewerOlder