#%% argument generation
def beamforming_arg_gen_funct(
        dim, num_args):  #generate num_cells_x,num_cells_y as dim
    return [dim, np.cdouble]


def beamforming_arg_gen_funct_single(
        dim, num_args):  #generate num_cells_x,num_cells_y as dim
    return [dim, np.csingle]


#%% now run
[solve_stats_double,
 _] = fancy_timeit_matrix_sweep([beamform_speed], ['beamforming'], [2],
                                dim_list,
                                num_reps,
                                arg_gen_funct=beamforming_arg_gen_funct)
[solve_stats_single,
 _] = fancy_timeit_matrix_sweep([beamform_speed], ['beamforming'], [2],
                                dim_list,
                                num_reps,
                                arg_gen_funct=beamforming_arg_gen_funct_single)

stats_np_double.update(solve_stats_double)
stats_np_single.update(solve_stats_single)

#%% now save out (single is not used)
import scipy.io as sio
sio.savemat(out_file, {'single': stats_np_single, 'double': stats_np_double})
Пример #2
0
out_file = os.path.join(output_directory, 'stats_py_np_extended.mat')

#%%
'''
NUMPY TESTS
'''
#%% Test the fancy_timeit_matrix_sweep capability
functs = [np.sum]
funct_names = ['sum']
num_args = [1]

#% now run
[stats_np_double, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.cdouble)
[stats_np_single, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.csingle)

#%% now measure our fft
fft_reps = num_reps


#%% generate our arguments
def fft_arg_gen_funct(dim, num_args):  #vector generation function
Пример #3
0

def ssolve_arg_gen_funct_single(dim,
                                num_args):  #generate A and b for dense solving
    numel = np.floor(dim * 5).astype(np.uint32)
    return [
        generate_random_sparse((dim, dim), numel, np.csingle),
        (np.random.rand(dim) + 1j * np.random.rand(dim)).astype(np.csingle)
    ]


#now get the results
[ssolve_stats_double,
 _] = fancy_timeit_matrix_sweep([scipy.sparse.linalg.spsolve], ['ssolve'], [2],
                                ssolve_dim_list,
                                ssolve_reps,
                                arg_gen_funct=ssolve_arg_gen_funct,
                                no_fail=True)
#now get the results
[ssolve_stats_single,
 _] = fancy_timeit_matrix_sweep([scipy.sparse.linalg.spsolve], ['ssolve'], [2],
                                ssolve_dim_list,
                                ssolve_reps,
                                arg_gen_funct=ssolve_arg_gen_funct_single,
                                no_fail=True)

stats_np_double = ssolve_stats_double
stats_np_single = ssolve_stats_single

#%% now save out
import scipy.io as sio
Пример #4
0
    mat_dim_list = np.floor(np.linspace(1, 10000, 51)).astype(np.uint32)
    solve_dim_list = np.floor(np.linspace(1, 5000, 51)).astype(np.uint32)
    num_reps = 25

out_file = os.path.join(output_directory, 'stats_py_np_matrix.mat')

#%% Test the fancy_timeit_matrix_sweep capability
#lu_factor is used as opposed to lu to match the output of MATLAB's lu() function
functs = [scipy.linalg.lu_factor, np.matmul]
funct_names = ['lu', 'matmul']
num_args = [1, 2]

#% now run
[stats_np_double, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.cdouble)
[stats_np_single, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.csingle)

#%% and now matrix solving
import scipy.linalg
solve_reps = num_reps


#argument generation functions
Пример #5
0
#argument generation
def fdfd_arg_gen_funct(dim,
                       num_args):  #generate num_cells_x,num_cells_y as dim
    return [dim, dim, np.cdouble]


def fdfd_arg_gen_funct_single(
        dim, num_args):  #generate num_cells_x,num_cells_y as dim
    return [dim, dim, np.csingle]


#now run
[solve_stats_double,
 _] = fancy_timeit_matrix_sweep([FDFD_2D], ['fdfd'], [3],
                                dim_list,
                                num_reps,
                                arg_gen_funct=fdfd_arg_gen_funct)
[solve_stats_single,
 _] = fancy_timeit_matrix_sweep([FDFD_2D], ['fdfd'], [3],
                                dim_list,
                                num_reps,
                                arg_gen_funct=fdfd_arg_gen_funct_single)

#stats_np_double.update(solve_stats_double)
stats_np_single.update(solve_stats_single)

#%% now save out (single is not used)
import scipy.io as sio
sio.savemat(out_file, {'single': stats_np_single, 'double': stats_np_double})
Пример #6
0
out_file_nb = os.path.join(output_directory, 'stats_py_nb_basic.mat')

#%%
'''
NUMPY TESTS
'''
#%% Test the fancy_timeit_matrix_sweep capability
combo_fun = lambda x, y: x + y * np.exp(x)
functs = [np.add, np.subtract, np.multiply, np.divide, np.exp, combo_fun]
funct_names = ['add', 'sub', 'mult', 'div', 'exp', 'combo']
num_args = [2, 2, 2, 2, 1, 2]

#% now run
[stats_np_double, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.cdouble)
[stats_np_single, _] = fancy_timeit_matrix_sweep(functs,
                                                 funct_names,
                                                 num_args,
                                                 mat_dim_list,
                                                 num_reps,
                                                 dtype=np.csingle)

#%%
'''
NUMBA TESTS
'''
#%% Function declarations
import cmath