Fonction de type void() à plusieurs paramètres en langage C

andrypc4 - 7 juin 2013 à 14:20
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 - 12 juin 2013 à 14:18
Bonjour à tous!
Voici une fonction et son prototype:
/*
 * mygenerdatatest.c
 *
 * Code generation for function 'mygenerdatatest'
 *
 * C source code generated on: Mon Jun 03 11:39:57 2013
 *
 */
 
/* Include files */
#include "rt_nonfinite.h"
#include "mygenerdatatest.h"
#include "exp.h"
#include "norm.h"
#include "log10.h"
#include "randn.h"
#include "std.h"
#include "rand.h"
 
/* Type Definitions */
 
/* Named Constants */
 
/* Variable Declarations */
 
/* Variable Definitions */
 
/* Function Declarations */
static void eml_li_find(const boolean_T x[500], int32_T y_data[500], int32_T
  y_size[1]);
 
/* Function Definitions */
static void eml_li_find(const boolean_T x[500], int32_T y_data[500], int32_T
  y_size[1])
{
  int32_T k;
  int32_T i;
  k = 0;
  for (i = 0; i < 500; i++) {
    if (x[i]) {
      k++;
    }
  }
 
  y_size[0] = k;
  k = 0;
  for (i = 0; i < 500; i++) {
    if (x[i]) {
      y_data[k] = i + 1;
      k++;
    }
  }
}
 
creal_T eml_div(const creal_T x, real_T y)
{
  creal_T z;
  if (x.im == 0.0) {
    z.re = x.re / y;
    z.im = 0.0;
  } else if (x.re == 0.0) {
    z.re = 0.0;
    z.im = x.im / y;
  } else {
    z.re = x.re / y;
    z.im = x.im / y;
  }
 
  return z;
}
 
void mygenerdatatest(const real_T M[500], const real_T N[50], real_T nb_pic,
                     real_T NoiseLevel, creal_T y[50], creal_T Y[50], creal_T E
                     [25000], creal_T xbar[500], real_T Delta[500], creal_T
                     Eder[25000], creal_T Etrue[25000], creal_T *SNRspars,
                     creal_T *sigmanoise, real_T *grid_error, real_T
                     *linearisation_error, real_T *modeling_error)
{
  real_T Tau[50];
  int32_T i0;
  real_T bim;
  static const real_T b_y[4] = { 0.0002, -0.0008, -0.0006, 0.0004 };
 
  static const int16_T iv0[4] = { 99, 149, 199, 399 };
 
  real_T Nu[500];
  int32_T i;
  static const real_T Theta[500] = { 0.0, 0.002, 0.004, 0.006, 0.008, 0.01,
    0.012, 0.014, 0.016, 0.018, 0.02, 0.022, 0.024, 0.026, 0.028, 0.03, 0.032,
    0.034, 0.036, 0.038, 0.04, 0.042, 0.044, 0.046, 0.048, 0.05, 0.052, 0.054,
    0.056, 0.058, 0.06, 0.062, 0.064, 0.066, 0.068, 0.07, 0.072, 0.074, 0.076,
    0.078, 0.08, 0.082, 0.084, 0.086, 0.088, 0.09, 0.092, 0.094, 0.096, 0.098,
    0.1, 0.102, 0.104, 0.106, 0.108, 0.11, 0.112, 0.114, 0.116, 0.118, 0.12,
    0.122, 0.124, 0.126, 0.128, 0.13, 0.132, 0.134, 0.136, 0.138, 0.14, 0.142,
    0.144, 0.146, 0.148, 0.15, 0.152, 0.154, 0.156, 0.158, 0.16, 0.162, 0.164,
    0.166, 0.168, 0.17, 0.172, 0.174, 0.176, 0.178, 0.18, 0.182, 0.184, 0.186,
    0.188, 0.19, 0.192, 0.194, 0.196, 0.198, 0.2, 0.202, 0.204, 0.206, 0.208,
    0.21, 0.212, 0.214, 0.216, 0.218, 0.22, 0.222, 0.224, 0.226, 0.228, 0.23,
    0.232, 0.234, 0.236, 0.238, 0.24, 0.242, 0.244, 0.246, 0.248, 0.25, 0.252,
    0.254, 0.256, 0.258, 0.26, 0.262, 0.264, 0.266, 0.268, 0.27, 0.272, 0.274,
    0.276, 0.278, 0.28, 0.282, 0.284, 0.286, 0.288, 0.29, 0.292, 0.294, 0.296,
    0.298, 0.3, 0.302, 0.304, 0.306, 0.308, 0.31, 0.312, 0.314, 0.316, 0.318,
    0.32, 0.322, 0.324, 0.326, 0.328, 0.33, 0.332, 0.334, 0.336, 0.338, 0.34,
    0.342, 0.344, 0.346, 0.348, 0.35, 0.352, 0.354, 0.356, 0.358, 0.36, 0.362,
    0.364, 0.366, 0.368, 0.37, 0.372, 0.374, 0.376, 0.378, 0.38, 0.382, 0.384,
    0.386, 0.388, 0.39, 0.392, 0.394, 0.396, 0.398, 0.4, 0.402, 0.404, 0.406,
    0.408, 0.41, 0.412, 0.414, 0.416, 0.418, 0.42, 0.422, 0.424, 0.426, 0.428,
    0.43, 0.432, 0.434, 0.436, 0.438, 0.44, 0.442, 0.444, 0.446, 0.448, 0.45,
    0.452, 0.454, 0.456, 0.458, 0.46, 0.462, 0.464, 0.466, 0.468, 0.47, 0.472,
    0.474, 0.476, 0.478, 0.48, 0.482, 0.484, 0.486, 0.488, 0.49, 0.492, 0.494,
    0.496, 0.498, 0.5, 0.502, 0.504, 0.506, 0.508, 0.51, 0.512, 0.514, 0.516,
    0.518, 0.52, 0.522, 0.524, 0.526, 0.528, 0.53, 0.532, 0.534, 0.536, 0.538,
    0.54, 0.542, 0.544, 0.546, 0.548, 0.55, 0.552, 0.554, 0.556, 0.558, 0.56,
    0.562, 0.564, 0.566, 0.568, 0.57, 0.572, 0.574, 0.576, 0.578, 0.58, 0.582,
    0.584, 0.586, 0.588, 0.59, 0.592, 0.594, 0.596, 0.598, 0.6, 0.602, 0.604,
    0.606, 0.608, 0.61, 0.612, 0.614, 0.616, 0.618, 0.62, 0.622, 0.624, 0.626,
    0.628, 0.63, 0.632, 0.634, 0.636, 0.638, 0.64, 0.642, 0.644, 0.646, 0.648,
    0.65, 0.652, 0.654, 0.656, 0.658, 0.66, 0.662, 0.664, 0.666, 0.668, 0.67,
    0.672, 0.674, 0.676, 0.678, 0.68, 0.682, 0.684, 0.686, 0.688, 0.69, 0.692,
    0.694, 0.696, 0.698, 0.7, 0.702, 0.704, 0.706, 0.708, 0.71, 0.712, 0.714,
    0.716, 0.718, 0.72, 0.722, 0.724, 0.726, 0.728, 0.73, 0.732, 0.734, 0.736,
    0.738, 0.74, 0.742, 0.744, 0.746, 0.748, 0.75, 0.752, 0.754, 0.756, 0.758,
    0.76, 0.762, 0.764, 0.766, 0.768, 0.77, 0.772, 0.774, 0.776, 0.778, 0.78,
    0.782, 0.784, 0.786, 0.788, 0.79, 0.792, 0.794, 0.796, 0.798, 0.8, 0.802,
    0.804, 0.806, 0.808, 0.81, 0.812, 0.814, 0.816, 0.818, 0.82, 0.822, 0.824,
    0.826, 0.828, 0.83, 0.832, 0.834, 0.836, 0.838, 0.84, 0.842, 0.844, 0.846,
    0.848, 0.85, 0.852, 0.854, 0.856, 0.858, 0.86, 0.862, 0.864, 0.866, 0.868,
    0.87, 0.872, 0.874, 0.876, 0.878, 0.88, 0.882, 0.884, 0.886, 0.888, 0.89,
    0.892, 0.894, 0.896, 0.898, 0.9, 0.902, 0.904, 0.906, 0.908, 0.91, 0.912,
    0.914, 0.916, 0.918, 0.92, 0.922, 0.924, 0.926, 0.928, 0.93, 0.932, 0.934,
    0.936, 0.938, 0.94, 0.942, 0.944, 0.946, 0.948, 0.95, 0.952, 0.954, 0.956,
    0.958, 0.96, 0.962, 0.964, 0.966, 0.968, 0.97, 0.972, 0.974, 0.976, 0.978,
    0.98, 0.982, 0.984, 0.986, 0.988, 0.99, 0.992, 0.994, 0.996, 0.998 };
 
  real_T fi[4];
  boolean_T b_Nu[500];
  int32_T tmp_size[1];
  int32_T tmp_data[500];
  creal_T a;
  static const real_T Al[4] = { 0.5, 0.9, 1.0, 0.7 };
 
  int32_T loop_ub;
  creal_T sig[50];
  creal_T xx[24];
  creal_T b_sig[50];
  creal_T c_Nu[500];
  static const real_T dv0[500] = { 0.0, 0.002, 0.004, 0.006, 0.008, 0.01, 0.012,
    0.014, 0.016, 0.018, 0.02, 0.022, 0.024, 0.026, 0.028, 0.03, 0.032, 0.034,
    0.036, 0.038, 0.04, 0.042, 0.044, 0.046, 0.048, 0.05, 0.052, 0.054, 0.056,
    0.058, 0.06, 0.062, 0.064, 0.066, 0.068, 0.07, 0.072, 0.074, 0.076, 0.078,
    0.08, 0.082, 0.084, 0.086, 0.088, 0.09, 0.092, 0.094, 0.096, 0.098, 0.1,
    0.102, 0.104, 0.106, 0.108, 0.11, 0.112, 0.114, 0.116, 0.118, 0.12, 0.122,
    0.124, 0.126, 0.128, 0.13, 0.132, 0.134, 0.136, 0.138, 0.14, 0.142, 0.144,
    0.146, 0.148, 0.15, 0.152, 0.154, 0.156, 0.158, 0.16, 0.162, 0.164, 0.166,
    0.168, 0.17, 0.172, 0.174, 0.176, 0.178, 0.18, 0.182, 0.184, 0.186, 0.188,
    0.19, 0.192, 0.194, 0.196, 0.198, 0.2, 0.202, 0.204, 0.206, 0.208, 0.21,
    0.212, 0.214, 0.216, 0.218, 0.22, 0.222, 0.224, 0.226, 0.228, 0.23, 0.232,
    0.234, 0.236, 0.238, 0.24, 0.242, 0.244, 0.246, 0.248, 0.25, 0.252, 0.254,
    0.256, 0.258, 0.26, 0.262, 0.264, 0.266, 0.268, 0.27, 0.272, 0.274, 0.276,
    0.278, 0.28, 0.282, 0.284, 0.286, 0.288, 0.29, 0.292, 0.294, 0.296, 0.298,
    0.3, 0.302, 0.304, 0.306, 0.308, 0.31, 0.312, 0.314, 0.316, 0.318, 0.32,
    0.322, 0.324, 0.326, 0.328, 0.33, 0.332, 0.334, 0.336, 0.338, 0.34, 0.342,
    0.344, 0.346, 0.348, 0.35, 0.352, 0.354, 0.356, 0.358, 0.36, 0.362, 0.364,
    0.366, 0.368, 0.37, 0.372, 0.374, 0.376, 0.378, 0.38, 0.382, 0.384, 0.386,
    0.388, 0.39, 0.392, 0.394, 0.396, 0.398, 0.4, 0.402, 0.404, 0.406, 0.408,
    0.41, 0.412, 0.414, 0.416, 0.418, 0.42, 0.422, 0.424, 0.426, 0.428, 0.43,
    0.432, 0.434, 0.436, 0.438, 0.44, 0.442, 0.444, 0.446, 0.448, 0.45, 0.452,
    0.454, 0.456, 0.458, 0.46, 0.462, 0.464, 0.466, 0.468, 0.47, 0.472, 0.474,
    0.476, 0.478, 0.48, 0.482, 0.484, 0.486, 0.488, 0.49, 0.492, 0.494, 0.496,
    0.498, 0.5, 0.502, 0.504, 0.506, 0.508, 0.51, 0.512, 0.514, 0.516, 0.518,
    0.52, 0.522, 0.524, 0.526, 0.528, 0.53, 0.532, 0.534, 0.536, 0.538, 0.54,
    0.542, 0.544, 0.546, 0.548, 0.55, 0.552, 0.554, 0.556, 0.558, 0.56, 0.562,
    0.564, 0.566, 0.568, 0.57, 0.572, 0.574, 0.576, 0.578, 0.58, 0.582, 0.584,
    0.586, 0.588, 0.59, 0.592, 0.594, 0.596, 0.598, 0.6, 0.602, 0.604, 0.606,
    0.608, 0.61, 0.612, 0.614, 0.616, 0.618, 0.62, 0.622, 0.624, 0.626, 0.628,
    0.63, 0.632, 0.634, 0.636, 0.638, 0.64, 0.642, 0.644, 0.646, 0.648, 0.65,
    0.652, 0.654, 0.656, 0.658, 0.66, 0.662, 0.664, 0.666, 0.668, 0.67, 0.672,
    0.674, 0.676, 0.678, 0.68, 0.682, 0.684, 0.686, 0.688, 0.69, 0.692, 0.694,
    0.696, 0.698, 0.7, 0.702, 0.704, 0.706, 0.708, 0.71, 0.712, 0.714, 0.716,
    0.718, 0.72, 0.722, 0.724, 0.726, 0.728, 0.73, 0.732, 0.734, 0.736, 0.738,
    0.74, 0.742, 0.744, 0.746, 0.748, 0.75, 0.752, 0.754, 0.756, 0.758, 0.76,
    0.762, 0.764, 0.766, 0.768, 0.77, 0.772, 0.774, 0.776, 0.778, 0.78, 0.782,
    0.784, 0.786, 0.788, 0.79, 0.792, 0.794, 0.796, 0.798, 0.8, 0.802, 0.804,
    0.806, 0.808, 0.81, 0.812, 0.814, 0.816, 0.818, 0.82, 0.822, 0.824, 0.826,
    0.828, 0.83, 0.832, 0.834, 0.836, 0.838, 0.84, 0.842, 0.844, 0.846, 0.848,
    0.85, 0.852, 0.854, 0.856, 0.858, 0.86, 0.862, 0.864, 0.866, 0.868, 0.87,
    0.872, 0.874, 0.876, 0.878, 0.88, 0.882, 0.884, 0.886, 0.888, 0.89, 0.892,
    0.894, 0.896, 0.898, 0.9, 0.902, 0.904, 0.906, 0.908, 0.91, 0.912, 0.914,
    0.916, 0.918, 0.92, 0.922, 0.924, 0.926, 0.928, 0.93, 0.932, 0.934, 0.936,
    0.938, 0.94, 0.942, 0.944, 0.946, 0.948, 0.95, 0.952, 0.954, 0.956, 0.958,
    0.96, 0.962, 0.964, 0.966, 0.968, 0.97, 0.972, 0.974, 0.976, 0.978, 0.98,
    0.982, 0.984, 0.986, 0.988, 0.99, 0.992, 0.994, 0.996, 0.998 };
 
  real_T d;
  static creal_T b_E[25000];
  static creal_T dcv0[25000];
  real_T z[100];
  real_T brm;
  static real_T dv1[25000];
 
  /*  time samples */
  b_rand(Tau);
  for (i0 = 0; i0 < 50; i0++) {
    bim = (real_T)i0 + 0.5 * (Tau[i0] - 0.5);
    if ((0.0 >= bim) || rtIsNaN(bim)) {
      bim = 0.0;
    }
 
    if (bim <= 49.0) {
    } else {
      bim = 49.0;
    }
 
    Tau[i0] = bim;
  }
 
  /* frequences sur la grille */
  /* position of peaks */
  /* perturbation */
  memset(&Delta[0], 0, 500U * sizeof(real_T));
  for (i0 = 0; i0 < 4; i0++) {
    Delta[iv0[i0]] = b_y[i0];
  }
 
  /* frequences */
  for (i = 0; i < 500; i++) {
    Nu[i] = Theta[i] + Delta[i];
  }
 
  /* modulus of peaks */
  /* phase of peaks */
  c_rand(fi);
  for (i0 = 0; i0 < 4; i0++) {
    fi[i0] *= 6.2831853071795862;
  }
 
  /* exact sparse signal we want to estimate */
  for (i = 0; i < 500; i++) {
    xbar[i].re = 0.0;
    xbar[i].im = 0.0;
  }
 
  for (i = 0; i < 4; i++) {
    for (i0 = 0; i0 < 500; i0++) {
      b_Nu[i0] = (Nu[i0] == Nu[iv0[i]]);
    }
 
    eml_li_find(b_Nu, tmp_data, tmp_size);
    a.re = fi[i] * 0.0;
    a.im = fi[i];
    b_exp(&a);
    a.re *= Al[i];
    a.im *= Al[i];
    loop_ub = tmp_size[0] - 1;
    for (i0 = 0; i0 <= loop_ub; i0++) {
      xbar[tmp_data[i0] - 1] = a;
    }
  }
 
  /* exact cisoid (before adding noise) */
  for (i = 0; i < 50; i++) {
    sig[i].re = 0.0;
    sig[i].im = 0.0;
  }
 
  for (i0 = 0; i0 < 24; i0++) {
    xx[i0].re = 0.0;
    xx[i0].im = 0.0;
  }
 
  for (i = 0; i < 4; i++) {
    a.re = fi[i] * 0.0;
    a.im = fi[i];
    b_exp(&a);
    xx[i].re = Al[i] * a.re;
    xx[i].im = Al[i] * a.im;
    for (i0 = 0; i0 < 50; i0++) {
      b_sig[i0].re = Nu[iv0[i]] * (Tau[i0] * 0.0);
      b_sig[i0].im = Nu[iv0[i]] * (Tau[i0] * 6.2831853071795862);
    }
 
    c_exp(b_sig);
    for (i0 = 0; i0 < 50; i0++) {
      sig[i0].re += xx[i].re * b_sig[i0].re - xx[i].im * b_sig[i0].im;
      sig[i0].im += xx[i].re * b_sig[i0].im + xx[i].im * b_sig[i0].re;
    }
  }
 
  /* IFFT linear operator */
  for (i0 = 0; i0 < 500; i0++) {
    c_Nu[i0].re = dv0[i0];
    c_Nu[i0].im = 0.0;
    for (i = 0; i < 50; i++) {
      bim = Tau[i] * 0.0;
      d = Tau[i] * 6.2831853071795862;
      E[i + 50 * i0].re = bim * c_Nu[i0].re - d * 0.0;
      E[i + 50 * i0].im = bim * 0.0 + d * c_Nu[i0].re;
    }
  }
 
  d_exp(E);
 
  /* derivative */
  for (i0 = 0; i0 < 500; i0++) {
    c_Nu[i0].re = dv0[i0];
    c_Nu[i0].im = 0.0;
    for (i = 0; i < 50; i++) {
      bim = Tau[i] * 0.0;
      d = Tau[i] * 6.2831853071795862;
      b_E[i + 50 * i0].re = bim * c_Nu[i0].re - d * 0.0;
      b_E[i + 50 * i0].im = bim * 0.0 + d * c_Nu[i0].re;
    }
  }
 
  d_exp(b_E);
  for (i0 = 0; i0 < 50; i0++) {
    bim = 0.0 * Tau[i0];
    d = 6.2831853071795862 * Tau[i0];
    if (d == 0.0) {
      b_sig[i0].re = bim / 500.0;
      b_sig[i0].im = 0.0;
    } else if (bim == 0.0) {
      b_sig[i0].re = 0.0;
      b_sig[i0].im = d / 500.0;
    } else {
      b_sig[i0].re = bim / 500.0;
      b_sig[i0].im = d / 500.0;
    }
  }
 
  /*  exact frequency matrix */
  for (i0 = 0; i0 < 500; i0++) {
    c_Nu[i0].re = Nu[i0];
    c_Nu[i0].im = 0.0;
    for (i = 0; i < 50; i++) {
      dcv0[i + 50 * i0].re = b_sig[i].re - b_sig[i].im * 0.0;
      dcv0[i + 50 * i0].im = b_sig[i].re * 0.0 + b_sig[i].im;
      Eder[i + 50 * i0].re = dcv0[i + 50 * i0].re * b_E[i + 50 * i0].re - dcv0[i
        + 50 * i0].im * b_E[i + 50 * i0].im;
      Eder[i + 50 * i0].im = dcv0[i + 50 * i0].re * b_E[i + 50 * i0].im + dcv0[i
        + 50 * i0].im * b_E[i + 50 * i0].re;
      bim = Tau[i] * 0.0;
      d = Tau[i] * 6.2831853071795862;
      Etrue[i + 50 * i0].re = bim * c_Nu[i0].re - d * 0.0;
      Etrue[i + 50 * i0].im = bim * 0.0 + d * c_Nu[i0].re;
    }
  }
 
  d_exp(Etrue);
 
  /* observation */
  memcpy(&Y[0], &sig[0], 50U * sizeof(creal_T));
  a = b_std(sig);
  sigmanoise->re = 0.031622776601683791 * a.re;
  sigmanoise->im = 0.031622776601683791 * a.im;
  randn(z);
  a = eml_div(*sigmanoise, 1.4142135623730951);
  for (i = 0; i < 50; i++) {
    bim = z[i] + 0.0 * z[i + 50];
    d = z[i + 50];
    y[i].re = sig[i].re + (a.re * bim - a.im * d);
    y[i].im = sig[i].im + (a.re * d + a.im * bim);
  }
 
  if (sigmanoise->im == 0.0) {
    a.re = 0.5 / sigmanoise->re;
    a.im = 0.0;
  } else if (sigmanoise->re == 0.0) {
    a.re = 0.0;
    a.im = -(0.5 / sigmanoise->im);
  } else {
    brm = fabs(sigmanoise->re);
    bim = fabs(sigmanoise->im);
    if (brm > bim) {
      bim = sigmanoise->im / sigmanoise->re;
      d = sigmanoise->re + bim * sigmanoise->im;
      a.re = (0.5 + bim * 0.0) / d;
      a.im = (0.0 - bim * 0.5) / d;
    } else if (bim == brm) {
      bim = sigmanoise->re > 0.0 ? 0.5 : -0.5;
      d = sigmanoise->im > 0.0 ? 0.5 : -0.5;
      a.re = 0.5 * bim / brm;
      a.im = (-0.0 - 0.5 * d) / brm;
    } else {
      bim = sigmanoise->re / sigmanoise->im;
      d = sigmanoise->im + bim * sigmanoise->re;
      a.re = bim * 0.5 / d;
      a.im = (bim * 0.0 - 0.5) / d;
    }
  }
 
  b_log10(&a);
  SNRspars->re = 20.0 * a.re;
  SNRspars->im = 20.0 * a.im;
 
  /*  affiche */
  for (i0 = 0; i0 < 50; i0++) {
    bim = 0.0;
    d = 0.0;
    for (i = 0; i < 500; i++) {
      bim += E[i0 + 50 * i].re * xbar[i].re - E[i0 + 50 * i].im * xbar[i].im;
      d += E[i0 + 50 * i].re * xbar[i].im + E[i0 + 50 * i].im * xbar[i].re;
    }
 
    b_sig[i0].re = sig[i0].re - bim;
    b_sig[i0].im = sig[i0].im - d;
  }
 
  *grid_error = norm(b_sig);
  for (i0 = 0; i0 < 500; i0++) {
    for (i = 0; i < 50; i++) {
      dv1[i + 50 * i0] = Delta[i0];
      b_E[i + 50 * i0].re = E[i + 50 * i0].re + 500.0 * dv1[i + 50 * i0] *
        Eder[i + 50 * i0].re;
      b_E[i + 50 * i0].im = E[i + 50 * i0].im + 500.0 * dv1[i + 50 * i0] *
        Eder[i + 50 * i0].im;
    }
  }
 
  for (i0 = 0; i0 < 50; i0++) {
    bim = 0.0;
    d = 0.0;
    for (i = 0; i < 500; i++) {
      bim += b_E[i0 + 50 * i].re * xbar[i].re - b_E[i0 + 50 * i].im * xbar[i].im;
      d += b_E[i0 + 50 * i].re * xbar[i].im + b_E[i0 + 50 * i].im * xbar[i].re;
    }
 
    b_sig[i0].re = sig[i0].re - bim;
    b_sig[i0].im = sig[i0].im - d;
  }
 
  *linearisation_error = norm(b_sig);
  for (i0 = 0; i0 < 50; i0++) {
    bim = 0.0;
    d = 0.0;
    for (i = 0; i < 500; i++) {
      bim += Etrue[i0 + 50 * i].re * xbar[i].re - Etrue[i0 + 50 * i].im * xbar[i]
        .im;
      d += Etrue[i0 + 50 * i].re * xbar[i].im + Etrue[i0 + 50 * i].im * xbar[i].
        re;
    }
 
    b_sig[i0].re = sig[i0].re - bim;
    b_sig[i0].im = sig[i0].im - d;
  }
 
  *modeling_error = norm(b_sig);
}
 
/* End of code generation (mygenerdatatest.c) */

/*
 * mygenerdatatest.h
 *
 * Code generation for function 'mygenerdatatest'
 *
 * C source code generated on: Mon Jun 03 11:39:57 2013
 *
 */
 
#ifndef __MYGENERDATATEST_H__
#define __MYGENERDATATEST_H__
/* Include files */
#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "rt_defines.h"
#include "rt_nonfinite.h"
 
#include "rtwtypes.h"
#include "mygenerdatatest_types.h"
 
/* Type Definitions */
 
/* Named Constants */
 
/* Variable Declarations */
 
/* Variable Definitions */
 
/* Function Declarations */
extern creal_T eml_div(const creal_T x, real_T y);
extern void mygenerdatatest(const real_T M[500], const real_T N[50], real_T nb_pic, real_T NoiseLevel, creal_T y[50], creal_T Y[50], creal_T E[25000], creal_T xbar[500], real_T Delta[500], creal_T Eder[25000], creal_T Etrue[25000], creal_T *SNRspars, creal_T *sigmanoise, real_T *grid_error, real_T *linearisation_error, real_T *modeling_error);
#endif
/* End of code generation (mygenerdatatest.h) *
/

/
Voici la définition des types:
/*
 * rtwtypes.h
 *
 * Code generation for function 'mygenerdatatest'
 *
 * C source code generated on: Mon Jun 03 11:39:57 2013
 *
 */
 
#ifndef __RTWTYPES_H__
#define __RTWTYPES_H__
#ifndef TRUE
# define TRUE (1U)
#endif
#ifndef FALSE
# define FALSE (0U)
#endif
#ifndef __TMWTYPES__
#define __TMWTYPES__
 
#include <limits.h>
 
/*=======================================================================* 
 * Target hardware information
 *   Device type: Generic->MATLAB Host Computer
 *   Number of bits:     char:   8    short:   16    int:  32
 *                       long:  32      native word size:  32
 *   Byte ordering: LittleEndian
 *   Signed integer division rounds to: Undefined
 *   Shift right on a signed integer as arithmetic shift: off
 *=======================================================================*/
 
/*=======================================================================* 
 * Fixed width word size data types:                                     * 
 *   int8_T, int16_T, int32_T     - signed 8, 16, or 32 bit integers     * 
 *   uint8_T, uint16_T, uint32_T  - unsigned 8, 16, or 32 bit integers   * 
 *   real32_T, real64_T           - 32 and 64 bit floating point numbers * 
 *=======================================================================*/
 
typedef signed char int8_T;
typedef unsigned char uint8_T;
typedef short int16_T;
typedef unsigned short uint16_T;
typedef int int32_T;
typedef unsigned int uint32_T;
typedef float real32_T;
typedef double real64_T;
 
/*===========================================================================* 
 * Generic type definitions: real_T, time_T, boolean_T, int_T, uint_T,       * 
 *                           ulong_T, char_T and byte_T.                     * 
 *===========================================================================*/
 
typedef double real_T;
typedef double time_T;
typedef unsigned char boolean_T;
typedef int int_T;
typedef unsigned int uint_T;
typedef unsigned long ulong_T;
typedef char char_T;
typedef char_T byte_T;
 
/*===========================================================================* 
 * Complex number type definitions                                           * 
 *===========================================================================*/
#define CREAL_T     
   typedef struct {  
     real32_T re;  
     real32_T im;  
   } creal32_T;  
 
   typedef struct {  
     real64_T re;  
     real64_T im;  
   } creal64_T;  
 
   typedef struct {  
     real_T re;  
     real_T im;  
   } creal_T;  
 
   typedef struct {  
     int8_T re;  
     int8_T im;  
   } cint8_T;  
 
   typedef struct {  
     uint8_T re;  
     uint8_T im;  
   } cuint8_T;  
 
   typedef struct {  
     int16_T re;  
     int16_T im;  
   } cint16_T;  
 
   typedef struct {  
     uint16_T re;  
     uint16_T im;  
   } cuint16_T;  
 
   typedef struct {  
     int32_T re;  
     int32_T im;  
   } cint32_T;  
 
   typedef struct {  
     uint32_T re;  
     uint32_T im;  
   } cuint32_T;  
 
 
/*=======================================================================* 
 * Min and Max:                                                          * 
 *   int8_T, int16_T, int32_T     - signed 8, 16, or 32 bit integers     * 
 *   uint8_T, uint16_T, uint32_T  - unsigned 8, 16, or 32 bit integers   * 
 *=======================================================================*/
 
#define MAX_int8_T      ((int8_T)(127))
#define MIN_int8_T      ((int8_T)(-128))
#define MAX_uint8_T     ((uint8_T)(255))
#define MIN_uint8_T     ((uint8_T)(0))
#define MAX_int16_T     ((int16_T)(32767))
#define MIN_int16_T     ((int16_T)(-32768))
#define MAX_uint16_T    ((uint16_T)(65535))
#define MIN_uint16_T    ((uint16_T)(0))
#define MAX_int32_T     ((int32_T)(2147483647))
#define MIN_int32_T     ((int32_T)(-2147483647-1))
#define MAX_uint32_T    ((uint32_T)(0xFFFFFFFFU))
#define MIN_uint32_T    ((uint32_T)(0))
 
/* Logical type definitions */
#if !defined(__cplusplus) && !defined(__true_false_are_keywords)
#  ifndef false
#   define false (0U)
#  endif
#  ifndef true
#   define true (1U)
#  endif
#endif
 
/*
 * MATLAB for code generation assumes the code is compiled on a target using a 2's compliment representation
 * for signed integer values.
 */
#if ((SCHAR_MIN + 1) != -SCHAR_MAX)
#error "This code must be compiled using a 2's complement representation for signed integer values"
#endif
 
/*
 * Maximum length of a MATLAB identifier (function/variable)
 * including the null-termination character. Referenced by
 * rt_logging.c and rt_matrx.c.
 */
#define TMW_NAME_LENGTH_MAX    64
 
#endif
#endif
/* End of code generation (rtwtypes.h) */

Ma question est comment puis-je afficher SNRspars,grid_error,liearmodelin_error et sigmanoise en utilisant printf avec cette fonction void?
N.B: les paramètres d'entrée pour ce code sont M 500,N 50, nb_pic = 4, et NoiseLevel = 30.C'est pas toutes les headers et les déclarations des fonctions mais il y en a encore mais je pense que ces quelques codes contient l'essentiel.

5 réponses

cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
7 juin 2013 à 15:26
Bonjour.

Ma question est comment puis-je afficher SNRspars,grid_error,liearmodelin_error et sigmanoise en utilisant printf avec cette fonction void?

Ce sont des variables qui sont passées par adresses. Après l'appel à la fonction, leur valeur respective aura changé.
Ex:
void func(int* a)
{
  *a = 10;
}

int main()
{
  int a = 0;
  func(&a);
  printf("%i\n", a); // Affichera 10;

  return 0;
}


________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
j'ai compris et comment spécifié le type du var de comme %f ou %d pour ce type real_T et creal_T?
0
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
7 juin 2013 à 16:52
Ce sont des tableaux, du coup c'est à toi de coder ce qu'il faut pour les afficher, ce n'est pas automatique.

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
ces tableaux sont des structures de type complexe,ce qui ne m'arrange pas du tout alors si tu as une idée aide moi un peu
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cptpingu Messages postés 3837 Date d'inscription dimanche 12 décembre 2004 Statut Modérateur Dernière intervention 28 mars 2023 123
12 juin 2013 à 14:18
ces tableaux sont des structures de type complexe

Ce sont des structures, tu les lis donc comme des structures. Si tu ne sais pas faire ça, je t'invite à réviser les bases, ou à suivre des tutoriaux sur l'apprentissage du C.
Je peux t'aider pour un problème de technique, mais pas pour un problème de manque de connaissance.

________________________________________________________________________
Historique de mes créations, et quelques articles:
[ http://0217021.free.fr/portfolio http://0217021.free.fr/portfolio]
Merci d'utiliser Réponse acceptée si un post répond à votre question
0
Rejoignez-nous