Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 062941a1 authored by hhakim's avatar hhakim
Browse files

Add C++ .mat backup/restore test of MatDense and MatSparse.

parent f58068f8
Branches
Tags
No related merge requests found
......@@ -144,7 +144,7 @@ endif()
if(NOT NOCPPTESTS)
foreach(TEST_FPP float double)
foreach(FILE faust_mult2 faust_mult faust_mult_cplx test_Vect_min test_MatDense_get_row test_MatDense_lower_upper_tri test_MatDense_nonzeros_indices test_Transform_move test_TransformHelper_and_Transform_copy_ctor test_TransformHelper_and_Transform_fac_iterato test_TransformHelper_variadic_template_ctor test_MatDense_min test_TH_pack_factors faust_transform_omp_mul faust_pruneout faust_transform_optimize_storage faust_transform_optimize faust_prox_blockdiag test_MatSparse_vstack test_MatSparse_hstack)
foreach(FILE faust_mult2 faust_mult faust_mult_cplx test_Vect_min test_MatDense_get_row test_MatDense_lower_upper_tri test_MatDense_nonzeros_indices test_Transform_move test_TransformHelper_and_Transform_copy_ctor test_TransformHelper_and_Transform_fac_iterato test_TransformHelper_variadic_template_ctor test_MatDense_min test_TH_pack_factors faust_transform_omp_mul faust_pruneout faust_transform_optimize_storage faust_transform_optimize faust_prox_blockdiag test_MatSparse_vstack test_MatSparse_hstack test_matio_save_read)
if(USE_GPU_MOD AND ${FILE} MATCHES test_TH_pack_factors|test_TransformHelper_variadic_template_ctor|faust_transform_optimize|test_TransformHelper_and_Transform_fac_iterato|faust_mult2|faust_transform_omp_mul|test_Transform_move|test_TransformHelper_and_Transform_copy_ctor AND ${TEST_FPP} MATCHES float)# gpu_mod handles float but not FaustGPU
message(STATUS ${FILE}_${TEST_FPP} " skipped")
continue()
......
#include "faust_MatDense.h"
using namespace Faust;
typedef @TEST_FPP@ FPP;
int main(int argc, char** argv)
{
// test MatDense backup and restore
auto mat = MatDense<FPP, Cpu>::randMat(32, 128);
mat->save_to_mat_file("rand_matdense.mat", "test");
MatDense<FPP, Cpu> read_mat;
read_mat.read_from_mat_file("rand_matdense.mat", "test");
*mat -= read_mat;
assert(mat->norm() == 0);
//test MatSparse backup and restore
auto smat = MatSparse<FPP, Cpu>::randMat(32, 128, .1);
smat->save_to_mat_file("rand_matsparse.mat", "test");
MatSparse<FPP, Cpu> read_smat;
read_smat.read_from_mat_file("rand_matsparse.mat", "test");
MatDense<FPP, Cpu> diff = *smat;
diff -= read_smat;
assert(diff.norm() == 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment