##// END OF EJS Templates
Switched to CMake, added a basic python test (with ctypes), simplified kcoef init function
Switched to CMake, added a basic python test (with ctypes), simplified kcoef init function

File last commit:

r23:2e08872d5b98 tip TCH
r23:2e08872d5b98 tip TCH
Show More
Tests_LFR_BasicParams.ipynb
195 lines | 70.4 KiB | text/plain | TextLexer
/ Tests_LFR_BasicParams.ipynb
In [1]:
from ctypes import *   
import matplotlib.pyplot as plt
import numpy as np
import os
import sys

%matplotlib notebook
In [2]:
lib_basic_params = cdll.LoadLibrary('../build-LFR_basic-parameters-Desktop-Default/liblfr_basic_params.so')

Code C:

void init_k_coefficients_f0(float *k_coefficients, unsigned char nb_binscompressed_matrix )
In [3]:
nb_bins = 11
nb_binscompressed_matrix = c_char(nb_bins)
k_coefficients           = (c_float * (32 * nb_bins))() 

for i in range(len(k_coefficients)):
    k_coefficients[i] = 100.*np.random.random()
    
plt.plot(k_coefficients)
Out[3]:
[<matplotlib.lines.Line2D at 0x7f466118c050>]
In [4]:
plt.figure()
lib_basic_params.init_k_coefficients(k_coefficients, nb_binscompressed_matrix)
plt.plot(k_coefficients)
Out[4]:
[<matplotlib.lines.Line2D at 0x7f4661137a90>]
In [9]:
arr = np.array(k_coefficients)
np.where(arr == 0.)
Out[9]:
(array([  2,   3,  34,  35,  66,  67,  98,  99, 130, 131, 162, 163, 194,
        195, 226, 227, 258, 259, 290, 291, 322, 323]),)