/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * repmat.c
 *
 * Code generation for function 'repmat'
 *
 */

/* Include files */
#include "repmat.h"
#include "assertValidSizeArg.h"
#include "digital_option_price_cg_data.h"
#include "digital_option_price_cg_emxutil.h"
#include "digital_option_price_cg_types.h"
#include "eml_int_forloop_overflow_check.h"
#include "rt_nonfinite.h"
#include "mwmathutil.h"

/* Variable Definitions */
static emlrtRSInfo
    ic_emlrtRSI =
        {
            34,       /* lineNo */
            "repmat", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pathName */
};

static emlrtRSInfo
    mc_emlrtRSI =
        {
            70,       /* lineNo */
            "repmat", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pathName */
};

static emlrtRSInfo
    nc_emlrtRSI =
        {
            77,       /* lineNo */
            "repmat", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pathName */
};

static emlrtRSInfo
    oc_emlrtRSI =
        {
            72,       /* lineNo */
            "repmat", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pathName */
};

static emlrtRSInfo
    pc_emlrtRSI =
        {
            75,       /* lineNo */
            "repmat", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pathName */
};

static emlrtDCInfo
    e_emlrtDCI =
        {
            37,       /* lineNo */
            14,       /* colNo */
            "repmat", /* fName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m", /* pName */
            4           /* checkKind */
};

static emlrtRTEInfo
    pc_emlrtRTEI =
        {
            59,       /* lineNo */
            9,        /* colNo */
            "repmat", /* fName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pName */
};

static emlrtRTEInfo
    wc_emlrtRTEI =
        {
            65,       /* lineNo */
            28,       /* colNo */
            "repmat", /* fName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elmat/"
            "repmat.m" /* pName */
};

/* Function Definitions */
void b_repmat(const emlrtStack *sp, real_T a, real_T varargin_1,
              real_T varargin_2, emxArray_real_T *b)
{
  emlrtStack st;
  real_T *b_data;
  int32_T i;
  int32_T loop_ub_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  st.site = &ic_emlrtRSI;
  assertValidSizeArg(&st, varargin_1, varargin_2);
  if (!(varargin_2 >= 0.0)) {
    emlrtNonNegativeCheckR2012b(varargin_2, &e_emlrtDCI, (emlrtConstCTX)sp);
  }
  i = b->size[0] * b->size[1];
  b->size[0] = (int32_T)varargin_1;
  b->size[1] = (int32_T)varargin_2;
  emxEnsureCapacity_real_T(sp, b, i, &pc_emlrtRTEI);
  b_data = b->data;
  loop_ub_tmp = (int32_T)varargin_1 * (int32_T)varargin_2;
  for (i = 0; i < loop_ub_tmp; i++) {
    b_data[i] = a;
  }
}

void c_repmat(const emlrtStack *sp, const emxArray_real_T *a,
              const real_T varargin_1[2], emxArray_real_T *b)
{
  emlrtStack b_st;
  emlrtStack st;
  const real_T *a_data;
  real_T *b_data;
  int32_T i;
  int32_T i1;
  int32_T ibtile;
  int32_T jtilecol;
  int32_T k;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  a_data = a->data;
  st.site = &ic_emlrtRSI;
  b_assertValidSizeArg(&st, varargin_1);
  i = a->size[0];
  ibtile = b->size[0] * b->size[1];
  b->size[0] = a->size[0];
  i1 = (int32_T)varargin_1[1];
  b->size[1] = (int32_T)varargin_1[1];
  emxEnsureCapacity_real_T(sp, b, ibtile, &wc_emlrtRTEI);
  b_data = b->data;
  st.site = &mc_emlrtRSI;
  if ((int32_T)varargin_1[1] > 2147483646) {
    b_st.site = &hc_emlrtRSI;
    check_forloop_overflow_error(&b_st);
  }
  for (jtilecol = 0; jtilecol < i1; jtilecol++) {
    ibtile = jtilecol * i;
    st.site = &nc_emlrtRSI;
    if (i > 2147483646) {
      b_st.site = &hc_emlrtRSI;
      check_forloop_overflow_error(&b_st);
    }
    for (k = 0; k < i; k++) {
      b_data[ibtile + k] = a_data[k];
    }
  }
}

void d_repmat(const emlrtStack *sp, const emxArray_real_T *a,
              const real_T varargin_1[2], emxArray_real_T *b)
{
  emlrtStack b_st;
  emlrtStack st;
  const real_T *a_data;
  real_T *b_data;
  int32_T i;
  int32_T i1;
  int32_T ibmat;
  int32_T itilerow;
  int32_T jcol;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  a_data = a->data;
  st.site = &ic_emlrtRSI;
  b_assertValidSizeArg(&st, varargin_1);
  i = (int32_T)varargin_1[0];
  ibmat = b->size[0] * b->size[1];
  b->size[0] = (int32_T)varargin_1[0];
  i1 = a->size[1];
  b->size[1] = a->size[1];
  emxEnsureCapacity_real_T(sp, b, ibmat, &wc_emlrtRTEI);
  b_data = b->data;
  st.site = &oc_emlrtRSI;
  if (a->size[1] > 2147483646) {
    b_st.site = &hc_emlrtRSI;
    check_forloop_overflow_error(&b_st);
  }
  for (jcol = 0; jcol < i1; jcol++) {
    ibmat = jcol * i;
    st.site = &pc_emlrtRSI;
    if (i > 2147483646) {
      b_st.site = &hc_emlrtRSI;
      check_forloop_overflow_error(&b_st);
    }
    for (itilerow = 0; itilerow < i; itilerow++) {
      b_data[ibmat + itilerow] = a_data[jcol];
    }
  }
}

void e_repmat(const emlrtStack *sp, const emxArray_creal_T *a,
              const real_T varargin_1[2], emxArray_creal_T *b)
{
  emlrtStack b_st;
  emlrtStack st;
  const creal_T *a_data;
  creal_T *b_data;
  int32_T i;
  int32_T i1;
  int32_T ibmat;
  int32_T itilerow;
  int32_T jcol;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  a_data = a->data;
  st.site = &ic_emlrtRSI;
  b_assertValidSizeArg(&st, varargin_1);
  i = (int32_T)varargin_1[0];
  ibmat = b->size[0] * b->size[1];
  b->size[0] = (int32_T)varargin_1[0];
  i1 = a->size[1];
  b->size[1] = a->size[1];
  emxEnsureCapacity_creal_T(sp, b, ibmat, &wc_emlrtRTEI);
  b_data = b->data;
  st.site = &oc_emlrtRSI;
  if (a->size[1] > 2147483646) {
    b_st.site = &hc_emlrtRSI;
    check_forloop_overflow_error(&b_st);
  }
  for (jcol = 0; jcol < i1; jcol++) {
    ibmat = jcol * i;
    st.site = &pc_emlrtRSI;
    if (i > 2147483646) {
      b_st.site = &hc_emlrtRSI;
      check_forloop_overflow_error(&b_st);
    }
    for (itilerow = 0; itilerow < i; itilerow++) {
      b_data[ibmat + itilerow] = a_data[jcol];
    }
  }
}

void f_repmat(const emlrtStack *sp, real_T varargin_1, real_T varargin_2,
              emxArray_creal_T *b)
{
  emlrtStack st;
  creal_T *b_data;
  int32_T i;
  int32_T loop_ub_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  st.site = &ic_emlrtRSI;
  assertValidSizeArg(&st, varargin_1, varargin_2);
  if (!(varargin_2 >= 0.0)) {
    emlrtNonNegativeCheckR2012b(varargin_2, &e_emlrtDCI, (emlrtConstCTX)sp);
  }
  i = b->size[0] * b->size[1];
  b->size[0] = (int32_T)varargin_1;
  b->size[1] = (int32_T)varargin_2;
  emxEnsureCapacity_creal_T(sp, b, i, &pc_emlrtRTEI);
  b_data = b->data;
  loop_ub_tmp = (int32_T)varargin_1 * (int32_T)varargin_2;
  for (i = 0; i < loop_ub_tmp; i++) {
    b_data[i].re = 0.0;
    b_data[i].im = 1.0;
  }
}

void g_repmat(const emlrtStack *sp, real_T a, real_T varargin_1,
              emxArray_real_T *b)
{
  emlrtStack st;
  real_T d;
  real_T *b_data;
  int32_T i;
  int32_T loop_ub_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  st.site = &ic_emlrtRSI;
  if ((varargin_1 != muDoubleScalarFloor(varargin_1)) ||
      muDoubleScalarIsInf(varargin_1) || (varargin_1 < -2.147483648E+9) ||
      (varargin_1 > 2.147483647E+9)) {
    emlrtErrorWithMessageIdR2018a(
        &st, &c_emlrtRTEI, "Coder:MATLAB:NonIntegerInput",
        "Coder:MATLAB:NonIntegerInput", 4, 12, MIN_int32_T, 12, MAX_int32_T);
  }
  if (varargin_1 <= 0.0) {
    d = 0.0;
  } else {
    d = varargin_1;
  }
  if (!(d <= 2.147483647E+9)) {
    emlrtErrorWithMessageIdR2018a(&st, &d_emlrtRTEI, "Coder:MATLAB:pmaxsize",
                                  "Coder:MATLAB:pmaxsize", 0);
  }
  loop_ub_tmp = (int32_T)varargin_1;
  i = b->size[0];
  b->size[0] = (int32_T)varargin_1;
  emxEnsureCapacity_real_T(sp, b, i, &pc_emlrtRTEI);
  b_data = b->data;
  for (i = 0; i < loop_ub_tmp; i++) {
    b_data[i] = a;
  }
}

void h_repmat(const emlrtStack *sp, real_T varargin_1, real_T varargin_2,
              emxArray_creal_T *b)
{
  emlrtStack st;
  creal_T *b_data;
  int32_T i;
  int32_T loop_ub_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  st.site = &ic_emlrtRSI;
  assertValidSizeArg(&st, varargin_1, varargin_2);
  if (!(varargin_2 >= 0.0)) {
    emlrtNonNegativeCheckR2012b(varargin_2, &e_emlrtDCI, (emlrtConstCTX)sp);
  }
  i = b->size[0] * b->size[1];
  b->size[0] = (int32_T)varargin_1;
  b->size[1] = (int32_T)varargin_2;
  emxEnsureCapacity_creal_T(sp, b, i, &pc_emlrtRTEI);
  b_data = b->data;
  loop_ub_tmp = (int32_T)varargin_1 * (int32_T)varargin_2;
  for (i = 0; i < loop_ub_tmp; i++) {
    b_data[i].re = 0.0;
    b_data[i].im = -1.0;
  }
}

void repmat(const emlrtStack *sp, real_T a, real_T varargin_2,
            emxArray_real_T *b)
{
  emlrtStack st;
  real_T d;
  real_T *b_data;
  int32_T i;
  int32_T loop_ub_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  st.site = &ic_emlrtRSI;
  if ((varargin_2 != muDoubleScalarFloor(varargin_2)) ||
      muDoubleScalarIsInf(varargin_2) || (varargin_2 < -2.147483648E+9) ||
      (varargin_2 > 2.147483647E+9)) {
    emlrtErrorWithMessageIdR2018a(
        &st, &c_emlrtRTEI, "Coder:MATLAB:NonIntegerInput",
        "Coder:MATLAB:NonIntegerInput", 4, 12, MIN_int32_T, 12, MAX_int32_T);
  }
  if (varargin_2 <= 0.0) {
    d = 0.0;
  } else {
    d = varargin_2;
  }
  if (!(d <= 2.147483647E+9)) {
    emlrtErrorWithMessageIdR2018a(&st, &d_emlrtRTEI, "Coder:MATLAB:pmaxsize",
                                  "Coder:MATLAB:pmaxsize", 0);
  }
  if (!(varargin_2 >= 0.0)) {
    emlrtNonNegativeCheckR2012b(varargin_2, &e_emlrtDCI, (emlrtConstCTX)sp);
  }
  i = b->size[0] * b->size[1];
  b->size[0] = 1;
  loop_ub_tmp = (int32_T)varargin_2;
  b->size[1] = (int32_T)varargin_2;
  emxEnsureCapacity_real_T(sp, b, i, &pc_emlrtRTEI);
  b_data = b->data;
  for (i = 0; i < loop_ub_tmp; i++) {
    b_data[i] = a;
  }
}

/* End of code generation (repmat.c) */
