/* Copyright 2013 Perttu Luukko * This file is part of libeemd. * libeemd is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * libeemd is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with libeemd. If not, see . */ #include #include #include #include const double pi = M_PI; #include "../src/eemd.h" const size_t ensemble_size = 500; const unsigned int S_number = 4; const unsigned int num_siftings = 50; const double noise_strength = 0.02; const unsigned long int rng_seed = 0; const char outfile[] = "ceemdan_example.out"; const size_t N = 512; int main(void) { libeemd_error_code err; // As an example decompose a Dirac signal as in the original CEEMDAN paper double* inp = (double*) malloc(N*sizeof(double)); memset(inp, 0x00, N*sizeof(double)); inp[N/2] = 1.0; // Allocate memory for output data size_t M = emd_num_imfs(N); double* outp = (double*) malloc(M*N*sizeof(double)); // Run CEEMDAN err = ceemdan(inp, N, outp, M, ensemble_size, noise_strength, S_number, num_siftings, rng_seed); if (err != EMD_SUCCESS) { emd_report_if_error(err); exit(1); } // Write output to file FILE* fp = fopen(outfile, "w"); for (size_t j=0; j