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 matplotlib.pyplot as plt | |
import numpy as np | |
from matplotlib import cm | |
import matplotlib.mlab as mlab | |
plt.figure(facecolor="white") | |
F = plt.gcf() # get current frame. | |
DefaultSize = F.get_size_inches() | |
F.set_size_inches((DefaultSize[0]*1.5 ,DefaultSize[1]*1.0)) |
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
plt.subplot(2,3,3) | |
plt.axis('equal') | |
plt.title('New positions') |
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
extern "C" int sum(short len, short *costs) { | |
int i; | |
int sum=0; | |
for (i = 0; i < len; i++) { | |
sum += costs[i]; | |
} | |
return sum; | |
} |
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 ctypes | |
_sum = ctypes.CDLL('./sum.so') | |
_sum.our_function.argtypes = (ctypes.c_int, ctypes.POINTER(ctypes.c_int)) | |
def our_function(numbers): | |
global _sum | |
num_numbers = len(numbers) | |
array_type = ctypes.c_int * num_numbers | |
result = _sum.our_function(ctypes.c_int(num_numbers), array_type(*numbers)) |