/*
 * 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.
 *
 * digital_option_price_cg.c
 *
 * Code generation for function 'digital_option_price_cg'
 *
 */

/* Include files */
#include "digital_option_price_cg.h"
#include "assertCompatibleDims.h"
#include "digital_option_price_cg_data.h"
#include "digital_option_price_cg_emxutil.h"
#include "digital_option_price_cg_types.h"
#include "div.h"
#include "exp.h"
#include "log.h"
#include "moment_gen_function_cg.h"
#include "repmat.h"
#include "rt_nonfinite.h"
#include "sin.h"
#include "sum.h"
#include "unsafeSxfun.h"
#include "mwmathutil.h"

/* Variable Definitions */
static emlrtRSInfo emlrtRSI = {
    59,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo b_emlrtRSI = {
    60,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo c_emlrtRSI = {
    61,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo d_emlrtRSI = {
    69,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo e_emlrtRSI = {
    70,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo f_emlrtRSI = {
    82,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo g_emlrtRSI = {
    83,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo h_emlrtRSI = {
    95,                        /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo i_emlrtRSI = {
    106,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo j_emlrtRSI = {
    109,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo k_emlrtRSI = {
    110,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo l_emlrtRSI = {
    113,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo m_emlrtRSI = {
    118,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo n_emlrtRSI = {
    120,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo o_emlrtRSI = {
    123,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo p_emlrtRSI = {
    125,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo q_emlrtRSI = {
    128,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo r_emlrtRSI = {
    130,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo cc_emlrtRSI = {
    71,      /* lineNo */
    "power", /* fcnName */
    "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/ops/power.m" /* pathName
                                                                          */
};

static emlrtRSInfo dc_emlrtRSI = {
    34,               /* lineNo */
    "rdivide_helper", /* fcnName */
    "/Applications/MATLAB_R2024b.app/toolbox/eml/eml/+coder/+internal/"
    "rdivide_helper.m" /* pathName */
};

static emlrtRSInfo
    ec_emlrtRSI =
        {
            53,    /* lineNo */
            "div", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/eml/+coder/+internal/"
            "div.m" /* pathName */
};

static emlrtECInfo emlrtECI = {
    2,                         /* nDims */
    95,                        /* lineNo */
    20,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo b_emlrtECI = {
    2,                         /* nDims */
    95,                        /* lineNo */
    56,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo c_emlrtECI = {
    2,                         /* nDims */
    95,                        /* lineNo */
    16,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo d_emlrtECI = {
    2,                         /* nDims */
    95,                        /* lineNo */
    15,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo e_emlrtECI = {
    -1,                        /* nDims */
    95,                        /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    96,                        /* lineNo */
    6,                         /* colNo */
    "tmp3",                    /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo f_emlrtECI = {
    1,                         /* nDims */
    109,                       /* lineNo */
    6,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo g_emlrtECI = {
    2,                         /* nDims */
    109,                       /* lineNo */
    6,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo h_emlrtECI = {
    1,                         /* nDims */
    110,                       /* lineNo */
    40,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo i_emlrtECI = {
    2,                         /* nDims */
    110,                       /* lineNo */
    40,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo j_emlrtECI = {
    1,                         /* nDims */
    110,                       /* lineNo */
    89,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo k_emlrtECI = {
    2,                         /* nDims */
    110,                       /* lineNo */
    89,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo l_emlrtECI = {
    1,                         /* nDims */
    110,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo m_emlrtECI = {
    2,                         /* nDims */
    110,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo b_emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    112,                       /* lineNo */
    6,                         /* colNo */
    "fk",                      /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo n_emlrtECI = {
    -1,                        /* nDims */
    112,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo o_emlrtECI = {
    1,                         /* nDims */
    113,                       /* lineNo */
    47,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo p_emlrtECI = {
    2,                         /* nDims */
    113,                       /* lineNo */
    47,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo q_emlrtECI = {
    1,                         /* nDims */
    113,                       /* lineNo */
    10,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo r_emlrtECI = {
    1,                         /* nDims */
    115,                       /* lineNo */
    9,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo s_emlrtECI = {
    1,                         /* nDims */
    118,                       /* lineNo */
    41,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo t_emlrtECI = {
    2,                         /* nDims */
    118,                       /* lineNo */
    41,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo u_emlrtECI = {
    1,                         /* nDims */
    118,                       /* lineNo */
    90,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo v_emlrtECI = {
    2,                         /* nDims */
    118,                       /* lineNo */
    90,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo w_emlrtECI = {
    1,                         /* nDims */
    118,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo x_emlrtECI = {
    2,                         /* nDims */
    118,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo c_emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    119,                       /* lineNo */
    7,                         /* colNo */
    "fk2",                     /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo y_emlrtECI = {
    -1,                        /* nDims */
    119,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo ab_emlrtECI = {
    1,                         /* nDims */
    120,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo bb_emlrtECI = {
    2,                         /* nDims */
    120,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo cb_emlrtECI = {
    1,                         /* nDims */
    120,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo db_emlrtECI = {
    1,                         /* nDims */
    123,                       /* lineNo */
    41,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo eb_emlrtECI = {
    2,                         /* nDims */
    123,                       /* lineNo */
    41,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo fb_emlrtECI = {
    1,                         /* nDims */
    123,                       /* lineNo */
    90,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo gb_emlrtECI = {
    2,                         /* nDims */
    123,                       /* lineNo */
    90,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo hb_emlrtECI = {
    1,                         /* nDims */
    123,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo ib_emlrtECI = {
    2,                         /* nDims */
    123,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo jb_emlrtECI = {
    1,                         /* nDims */
    123,                       /* lineNo */
    140,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo kb_emlrtECI = {
    2,                         /* nDims */
    123,                       /* lineNo */
    140,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo d_emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    124,                       /* lineNo */
    7,                         /* colNo */
    "fk3",                     /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo lb_emlrtECI = {
    -1,                        /* nDims */
    124,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo mb_emlrtECI = {
    1,                         /* nDims */
    125,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo nb_emlrtECI = {
    2,                         /* nDims */
    125,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo ob_emlrtECI = {
    1,                         /* nDims */
    125,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo e_emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    128,                       /* lineNo */
    50,                        /* colNo */
    "beta1",                   /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo pb_emlrtECI = {
    1,                         /* nDims */
    128,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo qb_emlrtECI = {
    2,                         /* nDims */
    128,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo rb_emlrtECI = {
    1,                         /* nDims */
    128,                       /* lineNo */
    76,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo sb_emlrtECI = {
    2,                         /* nDims */
    128,                       /* lineNo */
    76,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo tb_emlrtECI = {
    1,                         /* nDims */
    128,                       /* lineNo */
    125,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo ub_emlrtECI = {
    2,                         /* nDims */
    128,                       /* lineNo */
    125,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtBCInfo f_emlrtBCI = {
    -1,                        /* iFirst */
    -1,                        /* iLast */
    129,                       /* lineNo */
    7,                         /* colNo */
    "fk4",                     /* aName */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m", /* pName
                                                                          */
    0 /* checkKind */
};

static emlrtECInfo vb_emlrtECI = {
    -1,                        /* nDims */
    129,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo wb_emlrtECI = {
    1,                         /* nDims */
    130,                       /* lineNo */
    32,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtECInfo xb_emlrtECI = {
    2,                         /* nDims */
    130,                       /* lineNo */
    32,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo g_emlrtRTEI = {
    13,     /* lineNo */
    9,      /* colNo */
    "sqrt", /* fName */
    "/Applications/MATLAB_R2024b.app/toolbox/eml/lib/matlab/elfun/sqrt.m" /* pName
                                                                           */
};

static emlrtRTEInfo i_emlrtRTEI = {
    78,                        /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo j_emlrtRTEI = {
    82,                        /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo k_emlrtRTEI = {
    83,                        /* lineNo */
    7,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo l_emlrtRTEI = {
    83,                        /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo m_emlrtRTEI = {
    94,                        /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo n_emlrtRTEI = {
    95,                        /* lineNo */
    16,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo o_emlrtRTEI = {
    95,                        /* lineNo */
    52,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo p_emlrtRTEI = {
    95,                        /* lineNo */
    89,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo q_emlrtRTEI = {
    95,                        /* lineNo */
    15,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo r_emlrtRTEI = {
    106,                       /* lineNo */
    57,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo s_emlrtRTEI = {
    106,                       /* lineNo */
    65,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo t_emlrtRTEI = {
    106,                       /* lineNo */
    86,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo u_emlrtRTEI = {
    110,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo v_emlrtRTEI = {
    112,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo w_emlrtRTEI = {
    113,                       /* lineNo */
    47,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo y_emlrtRTEI = {
    115,                       /* lineNo */
    9,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo ab_emlrtRTEI = {
    115,                       /* lineNo */
    25,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo bb_emlrtRTEI = {
    118,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo cb_emlrtRTEI = {
    119,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo db_emlrtRTEI = {
    120,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo eb_emlrtRTEI = {
    120,                       /* lineNo */
    62,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo fb_emlrtRTEI = {
    123,                       /* lineNo */
    189,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo gb_emlrtRTEI = {
    123,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo hb_emlrtRTEI = {
    124,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo ib_emlrtRTEI = {
    125,                       /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo jb_emlrtRTEI = {
    125,                       /* lineNo */
    62,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo kb_emlrtRTEI = {
    128,                       /* lineNo */
    44,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo lb_emlrtRTEI = {
    128,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo mb_emlrtRTEI = {
    129,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo nb_emlrtRTEI = {
    130,                       /* lineNo */
    32,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo ob_emlrtRTEI = {
    130,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo pb_emlrtRTEI = {
    110,                       /* lineNo */
    40,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo qb_emlrtRTEI = {
    110,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo rb_emlrtRTEI = {
    109,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo sb_emlrtRTEI = {
    1,                         /* lineNo */
    48,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo tb_emlrtRTEI = {
    95,                        /* lineNo */
    20,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo ub_emlrtRTEI = {
    95,                        /* lineNo */
    56,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo vb_emlrtRTEI = {
    110,                       /* lineNo */
    89,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo wb_emlrtRTEI = {
    112,                       /* lineNo */
    1,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo xb_emlrtRTEI = {
    123,                       /* lineNo */
    140,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo yb_emlrtRTEI = {
    130,                       /* lineNo */
    14,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo dd_emlrtRTEI = {
    128,                       /* lineNo */
    76,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo ed_emlrtRTEI = {
    128,                       /* lineNo */
    12,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo fd_emlrtRTEI = {
    128,                       /* lineNo */
    125,                       /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo gd_emlrtRTEI = {
    125,                       /* lineNo */
    11,                        /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo hd_emlrtRTEI = {
    118,                       /* lineNo */
    7,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo id_emlrtRTEI = {
    115,                       /* lineNo */
    7,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRTEInfo kd_emlrtRTEI = {
    109,                       /* lineNo */
    6,                         /* colNo */
    "digital_option_price_cg", /* fName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pName
                                                                         */
};

static emlrtRSInfo ad_emlrtRSI = {
    115,                       /* lineNo */
    "digital_option_price_cg", /* fcnName */
    "/Users/lazarus/Dropbox/Work/Research/Ned/VolatilityFinance/"
    "ReplicationCodeManual/Code/Temp/Toolbox/digital_option_price_cg.m" /* pathName
                                                                         */
};

static emlrtRSInfo bd_emlrtRSI = {
    31,            /* lineNo */
    "unsafeSxfun", /* fcnName */
    "/Applications/MATLAB_R2024b.app/toolbox/eml/eml/+coder/+internal/"
    "unsafeSxfun.m" /* pathName */
};

static emlrtRSInfo
    cd_emlrtRSI =
        {
            54,    /* lineNo */
            "div", /* fcnName */
            "/Applications/MATLAB_R2024b.app/toolbox/eml/eml/+coder/+internal/"
            "div.m" /* pathName */
};

/* Function Declarations */
static void b_minus(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2);

static void b_rdivide(const emlrtStack *sp, emxArray_real_T *in1,
                      const emxArray_real_T *in2, const emxArray_real_T *in3);

static void b_times(const emlrtStack *sp, emxArray_creal_T *in1,
                    const emxArray_creal_T *in2);

static void binary_expand_op(const emlrtStack *sp, emxArray_real_T *in1,
                             const emlrtRSInfo in2, const emxArray_real_T *in3,
                             const emxArray_real_T *in4);

static void binary_expand_op_1(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_creal_T *in2,
                               const emxArray_creal_T *in3);

static void binary_expand_op_10(const emlrtStack *sp, emxArray_real_T *in1,
                                const emxArray_real_T *in2, int32_T in3,
                                int32_T in4, const emxArray_real_T *in5);

static void binary_expand_op_5(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_creal_T *in2);

static void binary_expand_op_6(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_real_T *in2);

static void c_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2);

static void d_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2);

static void e_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2);

static void minus(const emlrtStack *sp, emxArray_real_T *in1,
                  const emxArray_real_T *in2);

static void plus(const emlrtStack *sp, emxArray_creal_T *in1,
                 const emxArray_creal_T *in2);

static void times(const emlrtStack *sp, emxArray_creal_T *in1,
                  const emxArray_real_T *in2);

/* Function Definitions */
static void b_minus(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2)
{
  emxArray_real_T *b_in1;
  const real_T *in2_data;
  real_T *b_in1_data;
  real_T *in1_data;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_1;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in1, 2, &n_emlrtRTEI);
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = 1;
  if (in2->size[1] == 1) {
    loop_ub = in1->size[1];
  } else {
    loop_ub = in2->size[1];
  }
  b_in1->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, b_in1, i, &n_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_1 = (in1->size[1] != 1);
  stride_1_1 = (in2->size[1] != 1);
  for (i = 0; i < loop_ub; i++) {
    b_in1_data[i] = in1_data[i * stride_0_1] - in2_data[i * stride_1_1];
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = 1;
  in1->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &n_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = b_in1_data[i];
  }
  emxFree_real_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void b_rdivide(const emlrtStack *sp, emxArray_real_T *in1,
                      const emxArray_real_T *in2, const emxArray_real_T *in3)
{
  const real_T *in2_data;
  const real_T *in3_data;
  real_T *in1_data;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_1_0;
  in3_data = in3->data;
  in2_data = in2->data;
  if (in3->size[0] == 1) {
    loop_ub = in2->size[0];
  } else {
    loop_ub = in3->size[0];
  }
  i = in1->size[0];
  in1->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &j_emlrtRTEI);
  in1_data = in1->data;
  stride_0_0 = (in2->size[0] != 1);
  stride_1_0 = (in3->size[0] != 1);
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = in2_data[i * stride_0_0] / in3_data[i * stride_1_0];
  }
}

static void b_times(const emlrtStack *sp, emxArray_creal_T *in1,
                    const emxArray_creal_T *in2)
{
  emxArray_creal_T *b_in1;
  const creal_T *in2_data;
  creal_T *b_in1_data;
  creal_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_creal_T(sp, &b_in1, 2, &ed_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = loop_ub;
  if (in2->size[1] == 1) {
    b_loop_ub = in1->size[1];
  } else {
    b_loop_ub = in2->size[1];
  }
  b_in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, b_in1, i, &ed_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_0_1 = (in1->size[1] != 1);
  stride_1_0 = (in2->size[0] != 1);
  stride_1_1 = (in2->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      real_T d;
      real_T d1;
      real_T d2;
      real_T d3;
      int32_T i2;
      int32_T i3;
      i2 = i1 * stride_0_0;
      i3 = i1 * stride_1_0;
      d = in1_data[i2 + in1->size[0] * aux_0_1].re;
      d1 = in2_data[i3 + in2->size[0] * aux_1_1].im;
      d2 = in1_data[i2 + in1->size[0] * aux_0_1].im;
      d3 = in2_data[i3 + in2->size[0] * aux_1_1].re;
      b_in1_data[i1 + b_in1->size[0] * i].re = d * d3 - d2 * d1;
      b_in1_data[i1 + b_in1->size[0] * i].im = d * d1 + d2 * d3;
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, in1, i, &ed_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in1_data[i1 + b_in1->size[0] * i];
    }
  }
  emxFree_creal_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void binary_expand_op(const emlrtStack *sp, emxArray_real_T *in1,
                             const emlrtRSInfo in2, const emxArray_real_T *in3,
                             const emxArray_real_T *in4)
{
  emlrtStack st;
  emxArray_real_T *b_in3;
  const real_T *in3_data;
  const real_T *in4_data;
  real_T *b_in3_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  st.prev = sp;
  st.tls = sp->tls;
  in4_data = in4->data;
  in3_data = in3->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in3, 2, &nb_emlrtRTEI);
  if (in4->size[0] == 1) {
    loop_ub = in3->size[0];
  } else {
    loop_ub = in4->size[0];
  }
  i = b_in3->size[0] * b_in3->size[1];
  b_in3->size[0] = loop_ub;
  if (in4->size[1] == 1) {
    b_loop_ub = in3->size[1];
  } else {
    b_loop_ub = in4->size[1];
  }
  b_in3->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, b_in3, i, &nb_emlrtRTEI);
  b_in3_data = b_in3->data;
  stride_0_0 = (in3->size[0] != 1);
  stride_0_1 = (in3->size[1] != 1);
  stride_1_0 = (in4->size[0] != 1);
  stride_1_1 = (in4->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      b_in3_data[i1 + b_in3->size[0] * i] =
          in3_data[i1 * stride_0_0 + in3->size[0] * aux_0_1] *
          in4_data[i1 * stride_1_0 + in4->size[0] * aux_1_1];
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  st.site = (emlrtRSInfo *)&in2;
  sum(&st, b_in3, in1);
  emxFree_real_T(sp, &b_in3);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void binary_expand_op_1(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_creal_T *in2,
                               const emxArray_creal_T *in3)
{
  const creal_T *in2_data;
  const creal_T *in3_data;
  real_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in3_data = in3->data;
  in2_data = in2->data;
  if (in3->size[0] == 1) {
    loop_ub = in2->size[0];
  } else {
    loop_ub = in3->size[0];
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &lb_emlrtRTEI);
  if (in3->size[1] == 1) {
    b_loop_ub = in2->size[1];
  } else {
    b_loop_ub = in3->size[1];
  }
  i = in1->size[0] * in1->size[1];
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &lb_emlrtRTEI);
  in1_data = in1->data;
  stride_0_0 = (in2->size[0] != 1);
  stride_0_1 = (in2->size[1] != 1);
  stride_1_0 = (in3->size[0] != 1);
  stride_1_1 = (in3->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      int32_T b_in2_re_tmp;
      int32_T in2_re_tmp;
      in2_re_tmp = i1 * stride_0_0;
      b_in2_re_tmp = i1 * stride_1_0;
      in1_data[i1 + in1->size[0] * i] =
          in2_data[in2_re_tmp + in2->size[0] * aux_0_1].re *
              in3_data[b_in2_re_tmp + in3->size[0] * aux_1_1].re -
          in2_data[in2_re_tmp + in2->size[0] * aux_0_1].im *
              in3_data[b_in2_re_tmp + in3->size[0] * aux_1_1].im;
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
}

static void binary_expand_op_10(const emlrtStack *sp, emxArray_real_T *in1,
                                const emxArray_real_T *in2, int32_T in3,
                                int32_T in4, const emxArray_real_T *in5)
{
  const real_T *in2_data;
  const real_T *in5_data;
  real_T *in1_data;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_1;
  int32_T stride_1_1;
  in5_data = in5->data;
  in2_data = in2->data;
  i = in1->size[0] * in1->size[1];
  in1->size[0] = 1;
  emxEnsureCapacity_real_T(sp, in1, i, &o_emlrtRTEI);
  i = in4 - in3;
  if (in5->size[1] == 1) {
    loop_ub = i;
  } else {
    loop_ub = in5->size[1];
  }
  stride_0_1 = in1->size[0] * in1->size[1];
  in1->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, stride_0_1, &o_emlrtRTEI);
  in1_data = in1->data;
  stride_0_1 = (i != 1);
  stride_1_1 = (in5->size[1] != 1);
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = in2_data[in3 + i * stride_0_1] * in5_data[i * stride_1_1];
  }
}

static void binary_expand_op_5(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_creal_T *in2)
{
  emxArray_real_T *b_in2;
  const creal_T *in2_data;
  real_T *b_in2_data;
  real_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in2, 2, &hd_emlrtRTEI);
  if (in1->size[0] == 1) {
    loop_ub = in2->size[0];
  } else {
    loop_ub = in1->size[0];
  }
  i = b_in2->size[0] * b_in2->size[1];
  b_in2->size[0] = loop_ub;
  if (in1->size[1] == 1) {
    b_loop_ub = in2->size[1];
  } else {
    b_loop_ub = in1->size[1];
  }
  b_in2->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, b_in2, i, &hd_emlrtRTEI);
  b_in2_data = b_in2->data;
  stride_0_0 = (in2->size[0] != 1);
  stride_0_1 = (in2->size[1] != 1);
  stride_1_0 = (in1->size[0] != 1);
  stride_1_1 = (in1->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      b_in2_data[i1 + b_in2->size[0] * i] =
          in2_data[i1 * stride_0_0 + in2->size[0] * aux_0_1].re *
          in1_data[i1 * stride_1_0 + in1->size[0] * aux_1_1];
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &hd_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in2_data[i1 + b_in2->size[0] * i];
    }
  }
  emxFree_real_T(sp, &b_in2);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void binary_expand_op_6(const emlrtStack *sp, emxArray_real_T *in1,
                               const emxArray_real_T *in2)
{
  emxArray_real_T *r;
  const real_T *in2_data;
  real_T *in1_data;
  real_T *r1;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_1_0;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &r, 1, &id_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = r->size[0];
  r->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, r, i, &id_emlrtRTEI);
  r1 = r->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_1_0 = (in2->size[0] != 1);
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 1.0 - in1_data[i * stride_0_0] * in2_data[i * stride_1_0];
  }
  i = in1->size[0];
  in1->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &id_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = r1[i];
  }
  emxFree_real_T(sp, &r);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void c_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2)
{
  emxArray_real_T *b_in1;
  const real_T *in2_data;
  real_T *b_in1_data;
  real_T *in1_data;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_1_0;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in1, 1, &gd_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0];
  b_in1->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, b_in1, i, &gd_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_1_0 = (in2->size[0] != 1);
  for (i = 0; i < loop_ub; i++) {
    b_in1_data[i] = in1_data[i * stride_0_0] * in2_data[i * stride_1_0];
  }
  i = in1->size[0];
  in1->size[0] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &gd_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = b_in1_data[i];
  }
  emxFree_real_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void d_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2)
{
  emxArray_real_T *b_in1;
  const real_T *in2_data;
  real_T *b_in1_data;
  real_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in1, 2, &kd_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = loop_ub;
  if (in2->size[1] == 1) {
    b_loop_ub = in1->size[1];
  } else {
    b_loop_ub = in2->size[1];
  }
  b_in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, b_in1, i, &kd_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_0_1 = (in1->size[1] != 1);
  stride_1_0 = (in2->size[0] != 1);
  stride_1_1 = (in2->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      b_in1_data[i1 + b_in1->size[0] * i] =
          in1_data[i1 * stride_0_0 + in1->size[0] * aux_0_1] *
          in2_data[i1 * stride_1_0 + in2->size[0] * aux_1_1];
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &kd_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in1_data[i1 + b_in1->size[0] * i];
    }
  }
  emxFree_real_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void e_times(const emlrtStack *sp, emxArray_real_T *in1,
                    const emxArray_real_T *in2)
{
  emxArray_real_T *b_in1;
  const real_T *in2_data;
  real_T *b_in1_data;
  real_T *in1_data;
  int32_T i;
  int32_T loop_ub;
  int32_T stride_0_1;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in1, 2, &q_emlrtRTEI);
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = 1;
  if (in2->size[1] == 1) {
    loop_ub = in1->size[1];
  } else {
    loop_ub = in2->size[1];
  }
  b_in1->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, b_in1, i, &q_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_1 = (in1->size[1] != 1);
  stride_1_1 = (in2->size[1] != 1);
  for (i = 0; i < loop_ub; i++) {
    b_in1_data[i] = in1_data[i * stride_0_1] * in2_data[i * stride_1_1];
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = 1;
  in1->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &q_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < loop_ub; i++) {
    in1_data[i] = b_in1_data[i];
  }
  emxFree_real_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void minus(const emlrtStack *sp, emxArray_real_T *in1,
                  const emxArray_real_T *in2)
{
  emxArray_real_T *b_in1;
  const real_T *in2_data;
  real_T *b_in1_data;
  real_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_real_T(sp, &b_in1, 2, &fd_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = loop_ub;
  if (in2->size[1] == 1) {
    b_loop_ub = in1->size[1];
  } else {
    b_loop_ub = in2->size[1];
  }
  b_in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, b_in1, i, &fd_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_0_1 = (in1->size[1] != 1);
  stride_1_0 = (in2->size[0] != 1);
  stride_1_1 = (in2->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      b_in1_data[i1 + b_in1->size[0] * i] =
          in1_data[i1 * stride_0_0 + in1->size[0] * aux_0_1] -
          in2_data[i1 * stride_1_0 + in2->size[0] * aux_1_1];
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_real_T(sp, in1, i, &fd_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in1_data[i1 + b_in1->size[0] * i];
    }
  }
  emxFree_real_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void plus(const emlrtStack *sp, emxArray_creal_T *in1,
                 const emxArray_creal_T *in2)
{
  emxArray_creal_T *b_in1;
  const creal_T *in2_data;
  creal_T *b_in1_data;
  creal_T *in1_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_creal_T(sp, &b_in1, 2, &xb_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = loop_ub;
  if (in2->size[1] == 1) {
    b_loop_ub = in1->size[1];
  } else {
    b_loop_ub = in2->size[1];
  }
  b_in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, b_in1, i, &xb_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_0_1 = (in1->size[1] != 1);
  stride_1_0 = (in2->size[0] != 1);
  stride_1_1 = (in2->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      int32_T i2;
      int32_T i3;
      i2 = i1 * stride_0_0;
      i3 = i1 * stride_1_0;
      b_in1_data[i1 + b_in1->size[0] * i].re =
          in1_data[i2 + in1->size[0] * aux_0_1].re +
          in2_data[i3 + in2->size[0] * aux_1_1].re;
      b_in1_data[i1 + b_in1->size[0] * i].im =
          in1_data[i2 + in1->size[0] * aux_0_1].im +
          in2_data[i3 + in2->size[0] * aux_1_1].im;
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, in1, i, &xb_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in1_data[i1 + b_in1->size[0] * i];
    }
  }
  emxFree_creal_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

static void times(const emlrtStack *sp, emxArray_creal_T *in1,
                  const emxArray_real_T *in2)
{
  emxArray_creal_T *b_in1;
  creal_T *b_in1_data;
  creal_T *in1_data;
  const real_T *in2_data;
  int32_T aux_0_1;
  int32_T aux_1_1;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T loop_ub;
  int32_T stride_0_0;
  int32_T stride_0_1;
  int32_T stride_1_0;
  int32_T stride_1_1;
  in2_data = in2->data;
  in1_data = in1->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  emxInit_creal_T(sp, &b_in1, 2, &dd_emlrtRTEI);
  if (in2->size[0] == 1) {
    loop_ub = in1->size[0];
  } else {
    loop_ub = in2->size[0];
  }
  i = b_in1->size[0] * b_in1->size[1];
  b_in1->size[0] = loop_ub;
  if (in2->size[1] == 1) {
    b_loop_ub = in1->size[1];
  } else {
    b_loop_ub = in2->size[1];
  }
  b_in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, b_in1, i, &dd_emlrtRTEI);
  b_in1_data = b_in1->data;
  stride_0_0 = (in1->size[0] != 1);
  stride_0_1 = (in1->size[1] != 1);
  stride_1_0 = (in2->size[0] != 1);
  stride_1_1 = (in2->size[1] != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      real_T d;
      int32_T i2;
      d = in2_data[i1 * stride_1_0 + in2->size[0] * aux_1_1];
      i2 = i1 * stride_0_0;
      b_in1_data[i1 + b_in1->size[0] * i].re =
          d * in1_data[i2 + in1->size[0] * aux_0_1].re;
      b_in1_data[i1 + b_in1->size[0] * i].im =
          d * in1_data[i2 + in1->size[0] * aux_0_1].im;
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += stride_0_1;
  }
  i = in1->size[0] * in1->size[1];
  in1->size[0] = loop_ub;
  in1->size[1] = b_loop_ub;
  emxEnsureCapacity_creal_T(sp, in1, i, &dd_emlrtRTEI);
  in1_data = in1->data;
  for (i = 0; i < b_loop_ub; i++) {
    for (i1 = 0; i1 < loop_ub; i1++) {
      in1_data[i1 + in1->size[0] * i] = b_in1_data[i1 + b_in1->size[0] * i];
    }
  }
  emxFree_creal_T(sp, &b_in1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

void digital_option_price_cg(const emlrtStack *sp, const emxArray_real_T *S0,
                             const emxArray_real_T *K, real_T T, real_T CP,
                             real_T sv1, real_T sv2, real_T sv3, real_T rf,
                             real_T zeta, real_T N, real_T L,
                             emxArray_real_T *VC, emxArray_real_T *CDF,
                             emxArray_real_T *VCdelta, emxArray_real_T *VCgamma,
                             emxArray_real_T *VCvega)
{
  emlrtStack b_st;
  emlrtStack c_st;
  emlrtStack st;
  emxArray_creal_T *a__1;
  emxArray_creal_T *a__2;
  emxArray_creal_T *a__3;
  emxArray_creal_T *b_beta1;
  emxArray_creal_T *beta1;
  emxArray_creal_T *cf;
  emxArray_creal_T *r6;
  emxArray_real_T *X;
  emxArray_real_T *b_fk;
  emxArray_real_T *fk;
  emxArray_real_T *kay;
  emxArray_real_T *r;
  emxArray_real_T *r2;
  emxArray_real_T *r3;
  emxArray_real_T *r4;
  emxArray_real_T *r5;
  emxArray_real_T *tmp3;
  emxArray_real_T *varargin_1;
  emxArray_real_T *vk;
  creal_T CF1;
  creal_T cf0;
  creal_T cf1;
  creal_T *a__1_data;
  creal_T *a__2_data;
  creal_T *b_beta1_data;
  creal_T *beta1_data;
  creal_T *r7;
  real_T b_K[2];
  const real_T *K_data;
  const real_T *S0_data;
  real_T a;
  real_T b;
  real_T c;
  real_T d;
  real_T d1_re;
  real_T re;
  real_T *VC_data;
  real_T *fk_data;
  real_T *kay_data;
  real_T *r1;
  real_T *tmp3_data;
  real_T *vk_data;
  int32_T b_loop_ub;
  int32_T i;
  int32_T i1;
  int32_T i2;
  int32_T loop_ub;
  int32_T loop_ub_tmp;
  (void)sv3;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  c_st.prev = &b_st;
  c_st.tls = b_st.tls;
  K_data = K->data;
  S0_data = S0->data;
  emlrtHeapReferenceStackEnterFcnR2012b((emlrtConstCTX)sp);
  /*  This function allows one to price digital options and resulting
   * risk-neutral CDFs */
  /*  for a given known underlying distribution (see the function:
   * moment_gen_function_cg.m) */
  /*  Updated to handle codegen */
  /*  */
  /*  The below is lightly adapted code from Nicola Fusari's Matlab Toolbox for
   */
  /*  Option Pricing (including comments). This code edits (with some */
  /*  notational hacks) his code to obtain the price of a digital option */
  /*  (should work for digital calls and puts, but I've tested it only for */
  /*  calls, so set CP=1) following Fang and Oosterlee (2008). The option pays
   */
  /*  K if S_T>K and 0 otherwise. It then transforms the resulting price to a */
  /*  risk-neutral CDF evaluated at the same strikes, and following Nicola's */
  /*  code, spits out Greeks for the digital option if desired. */
  /*  */
  /*  Nicola's code: */
  /*  */
  /* ==========================================================================
   */
  /*  */
  /*  The option price approximation is based on the paper by Fang & Oosterlee
   */
  /*  (2008), SIAM J. Sci. Comput. Vol 31, No. 2, pp. 826-848. */
  /*  */
  /*  I've tryied to keep the notation as close as possible to the one in the */
  /*  paper. */
  /*  */
  /* ==========================================================================
   */
  /*  OUTPUT:   OPTION PRICE */
  /*            RN CDF */
  /*            OPTION DELTA  */
  /*            OPTION GAMMA */
  /*            OPTION VEGA */
  /*  INPUT:    Distr ---> select the distribution of the underlying (see */
  /*                       function: moment_gen_function_cg.m)  */
  /*            S0    ---> underlying initial value */
  /*            K     ---> column vector of strikes */
  /*            x     ---> vector that contains the parameters for the selected
   */
  /*                       distribution (see function: moment_gen_function_cg.m)
   */
  /*            T     ---> maturity (in YEARS) */
  /*            CP    ---> Call/Put Flag  (call=1, put=-1) */
  /*            sv1   ---> value of the first variance component (if needed) */
  /*            sv2   ---> value of the first variance component (if needed) */
  /*            rf    ---> risk-free rate used to discound the option price */
  /*            d     ---> dividend yield */
  /*  REMARK: S0 and K must have the same length ---> COLUMN VECTORS */
  /* --------------------------------------------------------------------------
   */
  /*  Nicola Fusari (2011): */
  /*  You can distribute and use the code. Please cite the author if you use */
  /*  the code in in your research. */
  /* --------------------------------------------------------------------------
   */
  /*  Compute numerical derivatives of the MGF to computed MEAN and VARIANCE of
   */
  /*  the underlying distribution to decide WHERE to TRUNCATE the DENSITY */
  /*  approximation: */
  /*  0.01 */
  st.site = &emlrtRSI;
  cf1 = moment_gen_function_cg(&st, sv1, sv2, T, rf, zeta);
  b_log(&cf1);
  st.site = &b_emlrtRSI;
  cf0 = b_moment_gen_function_cg(&st, sv1, sv2, T, rf, zeta);
  b_log(&cf0);
  st.site = &c_emlrtRSI;
  CF1 = c_moment_gen_function_cg(&st, sv1, sv2, T, rf, zeta);
  b_log(&CF1);
  /*    http://mathworld.wolfram.com/FiniteDifference.html */
  b = CF1.re - cf1.re;
  if (CF1.im - cf1.im == 0.0) {
    d1_re = b / 0.01;
  } else if (b == 0.0) {
    d1_re = 0.0;
  } else {
    d1_re = b / 0.01;
  }
  b = (CF1.re + cf1.re) - 2.0 * cf0.re;
  c = (CF1.im + cf1.im) - 2.0 * cf0.im;
  if (c == 0.0) {
    re = b / 2.5E-5;
    b = 0.0;
  } else if (b == 0.0) {
    re = 0.0;
    b = c / 2.5E-5;
  } else {
    re = b / 2.5E-5;
    b = c / 2.5E-5;
  }
  b = muDoubleScalarHypot(re, b);
  st.site = &d_emlrtRSI;
  if (b < 0.0) {
    emlrtErrorWithMessageIdR2018a(
        &st, &g_emlrtRTEI, "Coder:toolbox:ElFunDomainError",
        "Coder:toolbox:ElFunDomainError", 3, 4, 4, "sqrt");
  }
  a = d1_re - L * muDoubleScalarSqrt(b);
  st.site = &e_emlrtRSI;
  if (b < 0.0) {
    emlrtErrorWithMessageIdR2018a(
        &st, &g_emlrtRTEI, "Coder:toolbox:ElFunDomainError",
        "Coder:toolbox:ElFunDomainError", 3, 4, 4, "sqrt");
  }
  b = d1_re + L * muDoubleScalarSqrt(b);
  if (CP == 1.0) {
    c = 0.0;
    d1_re = b;
  } else {
    c = a;
    d1_re = 0.0;
  }
  emxInit_real_T(sp, &kay, 2, &i_emlrtRTEI);
  if (muDoubleScalarIsNaN(N - 1.0)) {
    i = kay->size[0] * kay->size[1];
    kay->size[0] = 1;
    kay->size[1] = 1;
    emxEnsureCapacity_real_T(sp, kay, i, &i_emlrtRTEI);
    kay_data = kay->data;
    kay_data[0] = rtNaN;
  } else if (N - 1.0 < 0.0) {
    kay->size[1] = 0;
  } else {
    i = kay->size[0] * kay->size[1];
    kay->size[0] = 1;
    kay->size[1] = (int32_T)(N - 1.0) + 1;
    emxEnsureCapacity_real_T(sp, kay, i, &i_emlrtRTEI);
    kay_data = kay->data;
    loop_ub = (int32_T)(N - 1.0);
    for (i = 0; i <= loop_ub; i++) {
      kay_data[i] = i;
    }
  }
  st.site = &f_emlrtRSI;
  b_st.site = &dc_emlrtRSI;
  c_st.site = &ec_emlrtRSI;
  assertCompatibleDims(&c_st, S0, K);
  emxInit_real_T(sp, &X, 1, &j_emlrtRTEI);
  if (S0->size[0] == K->size[0]) {
    loop_ub = S0->size[0];
    i = X->size[0];
    X->size[0] = S0->size[0];
    emxEnsureCapacity_real_T(sp, X, i, &j_emlrtRTEI);
    kay_data = X->data;
    for (i = 0; i < loop_ub; i++) {
      kay_data[i] = S0_data[i] / K_data[i];
    }
  } else {
    b_rdivide(sp, X, S0, K);
  }
  st.site = &f_emlrtRSI;
  c_log(&st, X);
  st.site = &g_emlrtRSI;
  i = kay->size[0] * kay->size[1];
  kay->size[0] = 1;
  emxEnsureCapacity_real_T(&st, kay, i, &k_emlrtRTEI);
  kay_data = kay->data;
  loop_ub_tmp = kay->size[1] - 1;
  for (i = 0; i <= loop_ub_tmp; i++) {
    kay_data[i] *= 3.1415926535897931;
  }
  re = b - a;
  emxInit_real_T(&st, &tmp3, 2, &m_emlrtRTEI);
  b_st.site = &g_emlrtRSI;
  repmat(&b_st, re, N, tmp3);
  tmp3_data = tmp3->data;
  b_st.site = &dc_emlrtRSI;
  c_st.site = &ec_emlrtRSI;
  b_assertCompatibleDims(&c_st, kay, tmp3);
  if (kay->size[1] == tmp3->size[1]) {
    i = kay->size[0] * kay->size[1];
    kay->size[0] = 1;
    emxEnsureCapacity_real_T(&b_st, kay, i, &l_emlrtRTEI);
    kay_data = kay->data;
    for (i = 0; i <= loop_ub_tmp; i++) {
      kay_data[i] /= tmp3_data[i];
    }
  } else {
    c_st.site = &cd_emlrtRSI;
    rdivide(&c_st, kay, tmp3);
    kay_data = kay->data;
  }
  /* ---------------------- Chi_k ---------------------------------------------
   */
  /*  tmp1 = (cos(uu.*(d-a)).*exp(d)) - (cos(uu.*(c-a)).*exp(c)); */
  /* tmp1 = (cos(uu.*repmat(d-a,1,N)).*exp(repmat(d,1,N))) -
   * (cos(uu.*repmat(c-a,1,N)).*exp(repmat(c,1,N))); */
  /*  tmp2 = (uu.*sin(uu.*(d-a)).*exp(d)) - (uu.*sin(uu.*(c-a)).*exp(c)); */
  /* tmp2 = (uu.*sin(uu.*repmat(d-a,1,N)).*exp(repmat(d,1,N))) -
   * (uu.*sin(uu.*repmat(c-a,1,N)).*exp(repmat(c,1,N))); */
  /* CHI = (1./(1+uu.^2)) .* (tmp1 + tmp2); */
  /* ---------------------- Psi_k ---------------------------------------------
   */
  i = tmp3->size[0] * tmp3->size[1];
  tmp3->size[0] = 1;
  loop_ub = kay->size[1];
  tmp3->size[1] = kay->size[1];
  emxEnsureCapacity_real_T(sp, tmp3, i, &m_emlrtRTEI);
  tmp3_data = tmp3->data;
  for (i = 0; i < loop_ub; i++) {
    tmp3_data[i] = 0.0;
  }
  if (kay->size[1] < 2) {
    i = 0;
    i1 = 0;
  } else {
    i = 1;
    i1 = kay->size[1];
  }
  emxInit_real_T(sp, &r, 2, &tb_emlrtRTEI);
  st.site = &h_emlrtRSI;
  repmat(&st, d1_re - a, N - 1.0, r);
  r1 = r->data;
  loop_ub = i1 - i;
  if ((loop_ub != r->size[1]) && ((loop_ub != 1) && (r->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(loop_ub, r->size[1], &emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (kay->size[1] < 2) {
    i2 = 0;
    loop_ub_tmp = 0;
  } else {
    i2 = 1;
    loop_ub_tmp = kay->size[1];
  }
  emxInit_real_T(sp, &r2, 2, &ub_emlrtRTEI);
  st.site = &h_emlrtRSI;
  repmat(&st, c - a, N - 1.0, r2);
  VC_data = r2->data;
  b_loop_ub = loop_ub_tmp - i2;
  if ((b_loop_ub != r2->size[1]) && ((b_loop_ub != 1) && (r2->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_loop_ub, r2->size[1], &b_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  emxInit_real_T(sp, &r3, 2, &n_emlrtRTEI);
  if (loop_ub == r->size[1]) {
    i1 = r3->size[0] * r3->size[1];
    r3->size[0] = 1;
    r3->size[1] = loop_ub;
    emxEnsureCapacity_real_T(sp, r3, i1, &n_emlrtRTEI);
    fk_data = r3->data;
    for (i1 = 0; i1 < loop_ub; i1++) {
      fk_data[i1] = kay_data[i + i1] * r1[i1];
    }
  } else {
    binary_expand_op_10(sp, r3, kay, i, i1, r);
  }
  st.site = &h_emlrtRSI;
  b_sin(&st, r3);
  if (b_loop_ub == r2->size[1]) {
    i = r->size[0] * r->size[1];
    r->size[0] = 1;
    r->size[1] = b_loop_ub;
    emxEnsureCapacity_real_T(sp, r, i, &o_emlrtRTEI);
    r1 = r->data;
    for (i = 0; i < b_loop_ub; i++) {
      r1[i] = kay_data[i2 + i] * VC_data[i];
    }
  } else {
    binary_expand_op_10(sp, r, kay, i2, loop_ub_tmp, r2);
  }
  st.site = &h_emlrtRSI;
  b_sin(&st, r);
  r1 = r->data;
  if ((r3->size[1] != r->size[1]) &&
      ((r3->size[1] != 1) && (r->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r3->size[1], r->size[1], &c_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (kay->size[1] < 2) {
    i = 0;
    i1 = 0;
  } else {
    i = 1;
    i1 = kay->size[1];
  }
  if (r3->size[1] == r->size[1]) {
    loop_ub = r3->size[1] - 1;
    i2 = r3->size[0] * r3->size[1];
    r3->size[0] = 1;
    emxEnsureCapacity_real_T(sp, r3, i2, &n_emlrtRTEI);
    fk_data = r3->data;
    for (i2 = 0; i2 <= loop_ub; i2++) {
      fk_data[i2] -= r1[i2];
    }
  } else {
    st.site = &h_emlrtRSI;
    b_minus(&st, r3, r);
  }
  i2 = r->size[0] * r->size[1];
  r->size[0] = 1;
  loop_ub = i1 - i;
  r->size[1] = loop_ub;
  emxEnsureCapacity_real_T(sp, r, i2, &p_emlrtRTEI);
  r1 = r->data;
  for (i1 = 0; i1 < loop_ub; i1++) {
    r1[i1] = 1.0 / kay_data[i + i1];
  }
  if ((r3->size[1] != loop_ub) && ((r3->size[1] != 1) && (loop_ub != 1))) {
    emlrtDimSizeImpxCheckR2021b(r3->size[1], loop_ub, &d_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (kay->size[1] < 2) {
    i = 0;
    i1 = 0;
  } else {
    i = 1;
    i1 = kay->size[1];
  }
  if (r3->size[1] == r->size[1]) {
    loop_ub = r3->size[1] - 1;
    i2 = r3->size[0] * r3->size[1];
    r3->size[0] = 1;
    emxEnsureCapacity_real_T(sp, r3, i2, &q_emlrtRTEI);
    fk_data = r3->data;
    for (i2 = 0; i2 <= loop_ub; i2++) {
      fk_data[i2] *= r1[i2];
    }
  } else {
    st.site = &h_emlrtRSI;
    e_times(&st, r3, r);
    fk_data = r3->data;
  }
  i1 -= i;
  loop_ub = r3->size[1];
  if (i1 != r3->size[1]) {
    emlrtSubAssignSizeCheck1dR2017a(i1, r3->size[1], &e_emlrtECI,
                                    (emlrtConstCTX)sp);
  }
  for (i1 = 0; i1 < loop_ub; i1++) {
    tmp3_data[i + i1] = fk_data[i1];
  }
  emxFree_real_T(sp, &r3);
  if (kay->size[1] < 1) {
    emlrtDynamicBoundsCheckR2012b(1, 1, kay->size[1], &emlrtBCI,
                                  (emlrtConstCTX)sp);
  }
  tmp3_data[0] = d1_re - c;
  /* --------------------------------------------------------------------------
   */
  /* CHIPSIdiff = CHI - PSI; */
  /*  ----------- CHARACTERISTIC FUNCTION OF log(S_T/S_t)
   * ---------------------------- */
  emxInit_creal_T(sp, &beta1, 2, &kb_emlrtRTEI);
  i = beta1->size[0] * beta1->size[1];
  beta1->size[0] = 1;
  loop_ub = kay->size[1];
  beta1->size[1] = kay->size[1];
  emxEnsureCapacity_creal_T(sp, beta1, i, &r_emlrtRTEI);
  beta1_data = beta1->data;
  for (i = 0; i < loop_ub; i++) {
    beta1_data[i].re = kay_data[i] * 0.0;
    beta1_data[i].im = kay_data[i];
  }
  i = r->size[0] * r->size[1];
  r->size[0] = 1;
  r->size[1] = kay->size[1];
  emxEnsureCapacity_real_T(sp, r, i, &s_emlrtRTEI);
  r1 = r->data;
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 0.0;
  }
  i = r2->size[0] * r2->size[1];
  r2->size[0] = 1;
  r2->size[1] = kay->size[1];
  emxEnsureCapacity_real_T(sp, r2, i, &t_emlrtRTEI);
  VC_data = r2->data;
  for (i = 0; i < loop_ub; i++) {
    VC_data[i] = 0.0;
  }
  emxInit_creal_T(sp, &a__1, 2, &fb_emlrtRTEI);
  emxInit_creal_T(sp, &a__2, 2, &pb_emlrtRTEI);
  emxInit_creal_T(sp, &a__3, 2, &qb_emlrtRTEI);
  emxInit_creal_T(sp, &cf, 2, &sb_emlrtRTEI);
  emxInit_creal_T(sp, &b_beta1, 2, &sb_emlrtRTEI);
  st.site = &i_emlrtRSI;
  d_moment_gen_function_cg(&st, beta1, r, r2, sv1, sv2, T, rf, zeta, cf, a__1,
                           b_beta1, a__2, a__3);
  b_beta1_data = b_beta1->data;
  emxFree_real_T(sp, &r2);
  emxFree_real_T(sp, &r);
  /*  -------------------------------------------------------------------------
   */
  emxInit_real_T(sp, &vk, 2, &rb_emlrtRTEI);
  st.site = &j_emlrtRSI;
  b_repmat(&st, CP, K->size[0], N, vk);
  vk_data = vk->data;
  b_K[0] = 1.0;
  b_K[1] = tmp3->size[1];
  emxInit_real_T(sp, &fk, 2, &u_emlrtRTEI);
  st.site = &j_emlrtRSI;
  c_repmat(&st, K, b_K, fk);
  tmp3_data = fk->data;
  if ((vk->size[0] != fk->size[0]) &&
      ((vk->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[0], fk->size[0], &f_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[1] != fk->size[1]) &&
      ((vk->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[1], fk->size[1], &g_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[0] == fk->size[0]) && (vk->size[1] == fk->size[1])) {
    loop_ub_tmp = vk->size[0] * vk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      vk_data[i] *= tmp3_data[i];
    }
  } else {
    st.site = &j_emlrtRSI;
    d_times(&st, vk, fk);
    vk_data = vk->data;
  }
  b_K[0] = K->size[0];
  b_K[1] = 1.0;
  st.site = &j_emlrtRSI;
  d_repmat(&st, tmp3, b_K, fk);
  tmp3_data = fk->data;
  emxFree_real_T(sp, &tmp3);
  if ((vk->size[0] != fk->size[0]) &&
      ((vk->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[0], fk->size[0], &f_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[1] != fk->size[1]) &&
      ((vk->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[1], fk->size[1], &g_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[0] == fk->size[0]) && (vk->size[1] == fk->size[1])) {
    loop_ub_tmp = vk->size[0] * vk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      vk_data[i] *= tmp3_data[i];
    }
  } else {
    st.site = &j_emlrtRSI;
    d_times(&st, vk, fk);
    vk_data = vk->data;
  }
  st.site = &j_emlrtRSI;
  b_repmat(&st, 2.0 / re, K->size[0], N, fk);
  tmp3_data = fk->data;
  if ((vk->size[0] != fk->size[0]) &&
      ((vk->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[0], fk->size[0], &f_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[1] != fk->size[1]) &&
      ((vk->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(vk->size[1], fk->size[1], &g_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((vk->size[0] == fk->size[0]) && (vk->size[1] == fk->size[1])) {
    loop_ub_tmp = vk->size[0] * vk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      vk_data[i] *= tmp3_data[i];
    }
  } else {
    st.site = &j_emlrtRSI;
    d_times(&st, vk, fk);
    vk_data = vk->data;
  }
  st.site = &k_emlrtRSI;
  f_repmat(&st, K->size[0], N, a__2);
  a__2_data = a__2->data;
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &k_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  if ((a__2->size[0] != fk->size[0]) &&
      ((a__2->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], fk->size[0], &h_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != fk->size[1]) &&
      ((a__2->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], fk->size[1], &i_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = 1.0;
  b_K[1] = cf->size[1];
  emxInit_real_T(sp, &b_fk, 2, &w_emlrtRTEI);
  st.site = &k_emlrtRSI;
  c_repmat(&st, X, b_K, b_fk);
  fk_data = b_fk->data;
  emxInit_real_T(sp, &r4, 2, &vb_emlrtRTEI);
  st.site = &k_emlrtRSI;
  b_repmat(&st, a, K->size[0], N, r4);
  r1 = r4->data;
  if ((b_fk->size[0] != r4->size[0]) &&
      ((b_fk->size[0] != 1) && (r4->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[0], r4->size[0], &j_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((b_fk->size[1] != r4->size[1]) &&
      ((b_fk->size[1] != 1) && (r4->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[1], r4->size[1], &k_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[0] == fk->size[0]) && (a__2->size[1] == fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= tmp3_data[i];
      a__2_data[i].im *= tmp3_data[i];
    }
  } else {
    st.site = &k_emlrtRSI;
    times(&st, a__2, fk);
    a__2_data = a__2->data;
  }
  if ((b_fk->size[0] == r4->size[0]) && (b_fk->size[1] == r4->size[1])) {
    loop_ub_tmp = b_fk->size[0] * b_fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] -= r1[i];
    }
  } else {
    st.site = &k_emlrtRSI;
    minus(&st, b_fk, r4);
    fk_data = b_fk->data;
  }
  if ((a__2->size[0] != b_fk->size[0]) &&
      ((a__2->size[0] != 1) && (b_fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], b_fk->size[0], &h_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != b_fk->size[1]) &&
      ((a__2->size[1] != 1) && (b_fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], b_fk->size[1], &i_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &k_emlrtRSI;
  e_repmat(&st, cf, b_K, a__3);
  beta1_data = a__3->data;
  if ((a__2->size[0] == b_fk->size[0]) && (a__2->size[1] == b_fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= fk_data[i];
      a__2_data[i].im *= fk_data[i];
    }
  } else {
    times(sp, a__2, b_fk);
  }
  st.site = &k_emlrtRSI;
  b_exp(&st, a__2);
  a__2_data = a__2->data;
  if ((a__3->size[0] != a__2->size[0]) &&
      ((a__3->size[0] != 1) && (a__2->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], a__2->size[0], &l_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != a__2->size[1]) &&
      ((a__3->size[1] != 1) && (a__2->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], a__2->size[1], &m_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == a__2->size[0]) && (a__3->size[1] == a__2->size[1])) {
    i = fk->size[0] * fk->size[1];
    fk->size[0] = a__3->size[0];
    fk->size[1] = a__3->size[1];
    emxEnsureCapacity_real_T(sp, fk, i, &u_emlrtRTEI);
    tmp3_data = fk->data;
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      tmp3_data[i] = beta1_data[i].re * a__2_data[i].re -
                     beta1_data[i].im * a__2_data[i].im;
    }
  } else {
    st.site = &k_emlrtRSI;
    binary_expand_op_1(&st, fk, a__3, a__2);
    tmp3_data = fk->data;
  }
  if (fk->size[1] < 1) {
    emlrtDynamicBoundsCheckR2012b(1, 1, fk->size[1], &b_emlrtBCI,
                                  (emlrtConstCTX)sp);
  }
  emxInit_real_T(sp, &r5, 1, &wb_emlrtRTEI);
  loop_ub = fk->size[0];
  i = r5->size[0];
  r5->size[0] = fk->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &v_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 0.5 * tmp3_data[i];
  }
  emlrtSubAssignSizeCheckR2012b(&fk->size[0], 1, &r5->size[0], 1, &n_emlrtECI,
                                (emlrtCTX)sp);
  for (i = 0; i < loop_ub; i++) {
    tmp3_data[i] = r1[i];
  }
  if ((fk->size[0] != vk->size[0]) &&
      ((fk->size[0] != 1) && (vk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[0], vk->size[0], &o_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((fk->size[1] != vk->size[1]) &&
      ((fk->size[1] != 1) && (vk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[1], vk->size[1], &p_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  d = muDoubleScalarExp(-rf * T);
  st.site = &l_emlrtRSI;
  g_repmat(&st, d, K->size[0], r5);
  r1 = r5->data;
  emxInit_real_T(sp, &varargin_1, 1, &yb_emlrtRTEI);
  if ((fk->size[0] == vk->size[0]) && (fk->size[1] == vk->size[1])) {
    i = b_fk->size[0] * b_fk->size[1];
    b_fk->size[0] = fk->size[0];
    b_fk->size[1] = fk->size[1];
    emxEnsureCapacity_real_T(sp, b_fk, i, &w_emlrtRTEI);
    fk_data = b_fk->data;
    loop_ub_tmp = fk->size[0] * fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] = tmp3_data[i] * vk_data[i];
    }
    st.site = &l_emlrtRSI;
    sum(&st, b_fk, varargin_1);
    tmp3_data = varargin_1->data;
  } else {
    st.site = &l_emlrtRSI;
    binary_expand_op(&st, varargin_1, l_emlrtRSI, fk, vk);
    tmp3_data = varargin_1->data;
  }
  loop_ub = r5->size[0];
  if ((r5->size[0] != varargin_1->size[0]) &&
      ((r5->size[0] != 1) && (varargin_1->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r5->size[0], varargin_1->size[0], &q_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (r5->size[0] == varargin_1->size[0]) {
    i = VC->size[0];
    VC->size[0] = r5->size[0];
    emxEnsureCapacity_real_T(sp, VC, i, &x_emlrtRTEI);
    VC_data = VC->data;
    for (i = 0; i < loop_ub; i++) {
      b = r1[i] * tmp3_data[i];
      VC_data[i] = muDoubleScalarMax(b, 0.0);
    }
  } else {
    st.site = &bd_emlrtRSI;
    binary_expand_op_7(&st, VC, r5, varargin_1);
    VC_data = VC->data;
  }
  b = muDoubleScalarExp(rf * T);
  loop_ub = VC->size[0];
  i = CDF->size[0];
  CDF->size[0] = VC->size[0];
  emxEnsureCapacity_real_T(sp, CDF, i, &y_emlrtRTEI);
  kay_data = CDF->data;
  for (i = 0; i < loop_ub; i++) {
    kay_data[i] = VC_data[i] * b;
  }
  b_loop_ub = K->size[0];
  i = r5->size[0];
  r5->size[0] = K->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &ab_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < b_loop_ub; i++) {
    r1[i] = 1.0 / K_data[i];
  }
  if ((VC->size[0] != K->size[0]) &&
      ((VC->size[0] != 1) && (K->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(VC->size[0], K->size[0], &r_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (CDF->size[0] == r5->size[0]) {
    for (i = 0; i < loop_ub; i++) {
      kay_data[i] = 1.0 - kay_data[i] * r1[i];
    }
  } else {
    st.site = &ad_emlrtRSI;
    binary_expand_op_6(&st, CDF, r5);
  }
  /* -------------------------- Delta -----------------------------------------
   */
  st.site = &m_emlrtRSI;
  f_repmat(&st, K->size[0], N, a__2);
  a__2_data = a__2->data;
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &m_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  if ((a__2->size[0] != fk->size[0]) &&
      ((a__2->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], fk->size[0], &s_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != fk->size[1]) &&
      ((a__2->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], fk->size[1], &t_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = 1.0;
  b_K[1] = cf->size[1];
  st.site = &m_emlrtRSI;
  c_repmat(&st, X, b_K, b_fk);
  fk_data = b_fk->data;
  st.site = &m_emlrtRSI;
  b_repmat(&st, a, K->size[0], N, r4);
  r1 = r4->data;
  if ((b_fk->size[0] != r4->size[0]) &&
      ((b_fk->size[0] != 1) && (r4->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[0], r4->size[0], &u_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((b_fk->size[1] != r4->size[1]) &&
      ((b_fk->size[1] != 1) && (r4->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[1], r4->size[1], &v_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[0] == fk->size[0]) && (a__2->size[1] == fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= tmp3_data[i];
      a__2_data[i].im *= tmp3_data[i];
    }
  } else {
    st.site = &m_emlrtRSI;
    times(&st, a__2, fk);
    a__2_data = a__2->data;
  }
  if ((b_fk->size[0] == r4->size[0]) && (b_fk->size[1] == r4->size[1])) {
    loop_ub_tmp = b_fk->size[0] * b_fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] -= r1[i];
    }
  } else {
    st.site = &m_emlrtRSI;
    minus(&st, b_fk, r4);
    fk_data = b_fk->data;
  }
  if ((a__2->size[0] != b_fk->size[0]) &&
      ((a__2->size[0] != 1) && (b_fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], b_fk->size[0], &s_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != b_fk->size[1]) &&
      ((a__2->size[1] != 1) && (b_fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], b_fk->size[1], &t_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &m_emlrtRSI;
  e_repmat(&st, cf, b_K, a__3);
  beta1_data = a__3->data;
  if ((a__2->size[0] == b_fk->size[0]) && (a__2->size[1] == b_fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= fk_data[i];
      a__2_data[i].im *= fk_data[i];
    }
  } else {
    times(sp, a__2, b_fk);
  }
  st.site = &m_emlrtRSI;
  b_exp(&st, a__2);
  a__2_data = a__2->data;
  if ((a__3->size[0] != a__2->size[0]) &&
      ((a__3->size[0] != 1) && (a__2->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], a__2->size[0], &w_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != a__2->size[1]) &&
      ((a__3->size[1] != 1) && (a__2->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], a__2->size[1], &x_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == a__2->size[0]) && (a__3->size[1] == a__2->size[1])) {
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      re = beta1_data[i].re;
      b = a__2_data[i].im;
      c = beta1_data[i].im;
      d1_re = a__2_data[i].re;
      beta1_data[i].re = re * d1_re - c * b;
      beta1_data[i].im = re * b + c * d1_re;
    }
  } else {
    st.site = &m_emlrtRSI;
    b_times(&st, a__3, a__2);
    beta1_data = a__3->data;
  }
  st.site = &m_emlrtRSI;
  f_repmat(&st, K->size[0], N, a__2);
  a__2_data = a__2->data;
  if ((a__3->size[0] != a__2->size[0]) &&
      ((a__3->size[0] != 1) && (a__2->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], a__2->size[0], &w_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != a__2->size[1]) &&
      ((a__3->size[1] != 1) && (a__2->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], a__2->size[1], &x_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == a__2->size[0]) && (a__3->size[1] == a__2->size[1])) {
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      re = beta1_data[i].re;
      b = a__2_data[i].im;
      c = beta1_data[i].im;
      d1_re = a__2_data[i].re;
      beta1_data[i].re = re * d1_re - c * b;
      beta1_data[i].im = re * b + c * d1_re;
    }
  } else {
    st.site = &m_emlrtRSI;
    b_times(&st, a__3, a__2);
    beta1_data = a__3->data;
  }
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &m_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  if ((a__3->size[0] != fk->size[0]) &&
      ((a__3->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], fk->size[0], &w_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != fk->size[1]) &&
      ((a__3->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], fk->size[1], &x_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == fk->size[0]) && (a__3->size[1] == fk->size[1])) {
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    i = fk->size[0] * fk->size[1];
    fk->size[0] = a__3->size[0];
    fk->size[1] = a__3->size[1];
    emxEnsureCapacity_real_T(sp, fk, i, &bb_emlrtRTEI);
    tmp3_data = fk->data;
    for (i = 0; i < loop_ub_tmp; i++) {
      tmp3_data[i] *= beta1_data[i].re;
    }
  } else {
    st.site = &m_emlrtRSI;
    binary_expand_op_5(&st, fk, a__3);
    tmp3_data = fk->data;
  }
  /* for delta */
  if (fk->size[1] < 1) {
    emlrtDynamicBoundsCheckR2012b(1, 1, fk->size[1], &c_emlrtBCI,
                                  (emlrtConstCTX)sp);
  }
  loop_ub = fk->size[0];
  i = r5->size[0];
  r5->size[0] = fk->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &cb_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 0.5 * tmp3_data[i];
  }
  emlrtSubAssignSizeCheckR2012b(&fk->size[0], 1, &r5->size[0], 1, &y_emlrtECI,
                                (emlrtCTX)sp);
  for (i = 0; i < loop_ub; i++) {
    tmp3_data[i] = r1[i];
  }
  if ((fk->size[0] != vk->size[0]) &&
      ((fk->size[0] != 1) && (vk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[0], vk->size[0], &ab_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((fk->size[1] != vk->size[1]) &&
      ((fk->size[1] != 1) && (vk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[1], vk->size[1], &bb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  st.site = &n_emlrtRSI;
  g_repmat(&st, d, K->size[0], VCdelta);
  kay_data = VCdelta->data;
  if ((fk->size[0] == vk->size[0]) && (fk->size[1] == vk->size[1])) {
    i = b_fk->size[0] * b_fk->size[1];
    b_fk->size[0] = fk->size[0];
    b_fk->size[1] = fk->size[1];
    emxEnsureCapacity_real_T(sp, b_fk, i, &db_emlrtRTEI);
    fk_data = b_fk->data;
    loop_ub_tmp = fk->size[0] * fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] = tmp3_data[i] * vk_data[i];
    }
    st.site = &n_emlrtRSI;
    sum(&st, b_fk, r5);
    r1 = r5->data;
  } else {
    st.site = &n_emlrtRSI;
    binary_expand_op(&st, r5, n_emlrtRSI, fk, vk);
    r1 = r5->data;
  }
  loop_ub = VCdelta->size[0];
  if ((VCdelta->size[0] != r5->size[0]) &&
      ((VCdelta->size[0] != 1) && (r5->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(VCdelta->size[0], r5->size[0], &cb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (VCdelta->size[0] == r5->size[0]) {
    for (i = 0; i < loop_ub; i++) {
      kay_data[i] *= r1[i];
    }
  } else {
    st.site = &n_emlrtRSI;
    c_times(&st, VCdelta, r5);
    kay_data = VCdelta->data;
  }
  loop_ub = S0->size[0];
  i = r5->size[0];
  r5->size[0] = S0->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &eb_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 1.0 / S0_data[i];
  }
  b_loop_ub = VCdelta->size[0];
  if ((VCdelta->size[0] != S0->size[0]) &&
      ((VCdelta->size[0] != 1) && (S0->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(VCdelta->size[0], S0->size[0], &cb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (VCdelta->size[0] == r5->size[0]) {
    for (i = 0; i < b_loop_ub; i++) {
      kay_data[i] *= r1[i];
    }
  } else {
    st.site = &n_emlrtRSI;
    c_times(&st, VCdelta, r5);
  }
  /* -------------------------- Gamma -----------------------------------------
   */
  st.site = &o_emlrtRSI;
  f_repmat(&st, K->size[0], N, a__2);
  a__2_data = a__2->data;
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &o_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  if ((a__2->size[0] != fk->size[0]) &&
      ((a__2->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], fk->size[0], &db_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != fk->size[1]) &&
      ((a__2->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], fk->size[1], &eb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = 1.0;
  b_K[1] = cf->size[1];
  st.site = &o_emlrtRSI;
  c_repmat(&st, X, b_K, b_fk);
  fk_data = b_fk->data;
  st.site = &o_emlrtRSI;
  b_repmat(&st, a, K->size[0], N, r4);
  r1 = r4->data;
  if ((b_fk->size[0] != r4->size[0]) &&
      ((b_fk->size[0] != 1) && (r4->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[0], r4->size[0], &fb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((b_fk->size[1] != r4->size[1]) &&
      ((b_fk->size[1] != 1) && (r4->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[1], r4->size[1], &gb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[0] == fk->size[0]) && (a__2->size[1] == fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= tmp3_data[i];
      a__2_data[i].im *= tmp3_data[i];
    }
  } else {
    st.site = &o_emlrtRSI;
    times(&st, a__2, fk);
    a__2_data = a__2->data;
  }
  if ((b_fk->size[0] == r4->size[0]) && (b_fk->size[1] == r4->size[1])) {
    loop_ub_tmp = b_fk->size[0] * b_fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] -= r1[i];
    }
  } else {
    st.site = &o_emlrtRSI;
    minus(&st, b_fk, r4);
    fk_data = b_fk->data;
  }
  if ((a__2->size[0] != b_fk->size[0]) &&
      ((a__2->size[0] != 1) && (b_fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], b_fk->size[0], &db_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != b_fk->size[1]) &&
      ((a__2->size[1] != 1) && (b_fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], b_fk->size[1], &eb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &o_emlrtRSI;
  e_repmat(&st, cf, b_K, a__3);
  beta1_data = a__3->data;
  if ((a__2->size[0] == b_fk->size[0]) && (a__2->size[1] == b_fk->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      a__2_data[i].re *= fk_data[i];
      a__2_data[i].im *= fk_data[i];
    }
  } else {
    times(sp, a__2, b_fk);
  }
  st.site = &o_emlrtRSI;
  b_exp(&st, a__2);
  a__2_data = a__2->data;
  if ((a__3->size[0] != a__2->size[0]) &&
      ((a__3->size[0] != 1) && (a__2->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], a__2->size[0], &hb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != a__2->size[1]) &&
      ((a__3->size[1] != 1) && (a__2->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], a__2->size[1], &ib_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  emxInit_creal_T(sp, &r6, 2, &xb_emlrtRTEI);
  st.site = &o_emlrtRSI;
  h_repmat(&st, K->size[0], N, r6);
  r7 = r6->data;
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &o_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  if ((r6->size[0] != fk->size[0]) &&
      ((r6->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[0], fk->size[0], &jb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[1] != fk->size[1]) &&
      ((r6->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[1], fk->size[1], &kb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[0] == fk->size[0]) && (r6->size[1] == fk->size[1])) {
    loop_ub_tmp = r6->size[0] * r6->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      r7[i].re *= tmp3_data[i];
      r7[i].im *= tmp3_data[i];
    }
  } else {
    st.site = &o_emlrtRSI;
    times(&st, r6, fk);
    r7 = r6->data;
  }
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &o_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  i = a__1->size[0] * a__1->size[1];
  a__1->size[0] = fk->size[0];
  a__1->size[1] = fk->size[1];
  emxEnsureCapacity_creal_T(sp, a__1, i, &fb_emlrtRTEI);
  a__1_data = a__1->data;
  loop_ub_tmp = fk->size[0] * fk->size[1];
  for (i = 0; i < loop_ub_tmp; i++) {
    a__1_data[i].re = tmp3_data[i] * 0.0;
    a__1_data[i].im = tmp3_data[i];
  }
  for (i = 0; i < loop_ub_tmp; i++) {
    cf1 = a__1_data[i];
    cf0.re = cf1.re * cf1.re - cf1.im * cf1.im;
    b = cf1.re * cf1.im;
    cf0.im = b + b;
    a__1_data[i] = cf0;
  }
  if ((r6->size[0] != fk->size[0]) &&
      ((r6->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[0], fk->size[0], &jb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[1] != fk->size[1]) &&
      ((r6->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[1], fk->size[1], &kb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == a__2->size[0]) && (a__3->size[1] == a__2->size[1])) {
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      re = beta1_data[i].re;
      b = a__2_data[i].im;
      c = beta1_data[i].im;
      d1_re = a__2_data[i].re;
      beta1_data[i].re = re * d1_re - c * b;
      beta1_data[i].im = re * b + c * d1_re;
    }
  } else {
    st.site = &o_emlrtRSI;
    b_times(&st, a__3, a__2);
    beta1_data = a__3->data;
  }
  if ((r6->size[0] == a__1->size[0]) && (r6->size[1] == a__1->size[1])) {
    loop_ub_tmp = r6->size[0] * r6->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      r7[i].re += a__1_data[i].re;
      r7[i].im += a__1_data[i].im;
    }
  } else {
    st.site = &o_emlrtRSI;
    plus(&st, r6, a__1);
    r7 = r6->data;
  }
  emxFree_creal_T(sp, &a__1);
  if ((a__3->size[0] != r6->size[0]) &&
      ((a__3->size[0] != 1) && (r6->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[0], r6->size[0], &hb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[1] != r6->size[1]) &&
      ((a__3->size[1] != 1) && (r6->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__3->size[1], r6->size[1], &ib_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__3->size[0] == r6->size[0]) && (a__3->size[1] == r6->size[1])) {
    i = fk->size[0] * fk->size[1];
    fk->size[0] = a__3->size[0];
    fk->size[1] = a__3->size[1];
    emxEnsureCapacity_real_T(sp, fk, i, &gb_emlrtRTEI);
    tmp3_data = fk->data;
    loop_ub_tmp = a__3->size[0] * a__3->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      tmp3_data[i] = beta1_data[i].re * r7[i].re - beta1_data[i].im * r7[i].im;
    }
  } else {
    st.site = &o_emlrtRSI;
    binary_expand_op_1(&st, fk, a__3, r6);
    tmp3_data = fk->data;
  }
  /* for gamma */
  if (fk->size[1] < 1) {
    emlrtDynamicBoundsCheckR2012b(1, 1, fk->size[1], &d_emlrtBCI,
                                  (emlrtConstCTX)sp);
  }
  b_loop_ub = fk->size[0];
  i = r5->size[0];
  r5->size[0] = fk->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &hb_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < b_loop_ub; i++) {
    r1[i] = 0.5 * tmp3_data[i];
  }
  emlrtSubAssignSizeCheckR2012b(&fk->size[0], 1, &r5->size[0], 1, &lb_emlrtECI,
                                (emlrtCTX)sp);
  for (i = 0; i < b_loop_ub; i++) {
    tmp3_data[i] = r1[i];
  }
  if ((fk->size[0] != vk->size[0]) &&
      ((fk->size[0] != 1) && (vk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[0], vk->size[0], &mb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((fk->size[1] != vk->size[1]) &&
      ((fk->size[1] != 1) && (vk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[1], vk->size[1], &nb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  st.site = &p_emlrtRSI;
  g_repmat(&st, d, K->size[0], VCgamma);
  kay_data = VCgamma->data;
  if ((fk->size[0] == vk->size[0]) && (fk->size[1] == vk->size[1])) {
    i = b_fk->size[0] * b_fk->size[1];
    b_fk->size[0] = fk->size[0];
    b_fk->size[1] = fk->size[1];
    emxEnsureCapacity_real_T(sp, b_fk, i, &ib_emlrtRTEI);
    fk_data = b_fk->data;
    loop_ub_tmp = fk->size[0] * fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] = tmp3_data[i] * vk_data[i];
    }
    st.site = &p_emlrtRSI;
    sum(&st, b_fk, r5);
    r1 = r5->data;
  } else {
    st.site = &p_emlrtRSI;
    binary_expand_op(&st, r5, p_emlrtRSI, fk, vk);
    r1 = r5->data;
  }
  b_loop_ub = VCgamma->size[0];
  if ((VCgamma->size[0] != r5->size[0]) &&
      ((VCgamma->size[0] != 1) && (r5->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(VCgamma->size[0], r5->size[0], &ob_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (VCgamma->size[0] == r5->size[0]) {
    for (i = 0; i < b_loop_ub; i++) {
      kay_data[i] *= r1[i];
    }
  } else {
    st.site = &p_emlrtRSI;
    c_times(&st, VCgamma, r5);
    kay_data = VCgamma->data;
  }
  st.site = &p_emlrtRSI;
  b_st.site = &cc_emlrtRSI;
  i = r5->size[0];
  r5->size[0] = S0->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &jb_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < loop_ub; i++) {
    b = S0_data[i];
    r1[i] = 1.0 / (b * b);
  }
  loop_ub = VCgamma->size[0];
  if ((VCgamma->size[0] != S0->size[0]) &&
      ((VCgamma->size[0] != 1) && (S0->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(VCgamma->size[0], S0->size[0], &ob_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if (VCgamma->size[0] == r5->size[0]) {
    for (i = 0; i < loop_ub; i++) {
      kay_data[i] *= r1[i];
    }
  } else {
    st.site = &p_emlrtRSI;
    c_times(&st, VCgamma, r5);
  }
  /* -------------------------- Vega ------------------------------------------
   */
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &q_emlrtRSI;
  e_repmat(&st, cf, b_K, a__2);
  a__2_data = a__2->data;
  if (b_beta1->size[0] < 1) {
    emlrtDynamicBoundsCheckR2012b(b_beta1->size[0], 1, b_beta1->size[0],
                                  &e_emlrtBCI, (emlrtConstCTX)sp);
  }
  i = beta1->size[0] * beta1->size[1];
  beta1->size[0] = 1;
  loop_ub = b_beta1->size[1];
  beta1->size[1] = b_beta1->size[1];
  emxEnsureCapacity_creal_T(sp, beta1, i, &kb_emlrtRTEI);
  beta1_data = beta1->data;
  for (i = 0; i < loop_ub; i++) {
    beta1_data[i] = b_beta1_data[(b_beta1->size[0] + b_beta1->size[0] * i) - 1];
  }
  emxFree_creal_T(sp, &b_beta1);
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &q_emlrtRSI;
  e_repmat(&st, beta1, b_K, a__3);
  beta1_data = a__3->data;
  emxFree_creal_T(sp, &beta1);
  if ((a__2->size[0] != a__3->size[0]) &&
      ((a__2->size[0] != 1) && (a__3->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], a__3->size[0], &pb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != a__3->size[1]) &&
      ((a__2->size[1] != 1) && (a__3->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], a__3->size[1], &qb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  st.site = &q_emlrtRSI;
  f_repmat(&st, K->size[0], N, r6);
  r7 = r6->data;
  b_K[0] = X->size[0];
  b_K[1] = 1.0;
  st.site = &q_emlrtRSI;
  d_repmat(&st, kay, b_K, fk);
  tmp3_data = fk->data;
  emxFree_real_T(sp, &kay);
  if ((r6->size[0] != fk->size[0]) &&
      ((r6->size[0] != 1) && (fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[0], fk->size[0], &rb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[1] != fk->size[1]) &&
      ((r6->size[1] != 1) && (fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[1], fk->size[1], &sb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  b_K[0] = 1.0;
  b_K[1] = cf->size[1];
  emxFree_creal_T(sp, &cf);
  st.site = &q_emlrtRSI;
  c_repmat(&st, X, b_K, b_fk);
  fk_data = b_fk->data;
  emxFree_real_T(sp, &X);
  st.site = &q_emlrtRSI;
  b_repmat(&st, a, K->size[0], N, r4);
  r1 = r4->data;
  if ((b_fk->size[0] != r4->size[0]) &&
      ((b_fk->size[0] != 1) && (r4->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[0], r4->size[0], &tb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((b_fk->size[1] != r4->size[1]) &&
      ((b_fk->size[1] != 1) && (r4->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(b_fk->size[1], r4->size[1], &ub_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[0] == fk->size[0]) && (r6->size[1] == fk->size[1])) {
    loop_ub_tmp = r6->size[0] * r6->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      r7[i].re *= tmp3_data[i];
      r7[i].im *= tmp3_data[i];
    }
  } else {
    st.site = &q_emlrtRSI;
    times(&st, r6, fk);
    r7 = r6->data;
  }
  if ((b_fk->size[0] == r4->size[0]) && (b_fk->size[1] == r4->size[1])) {
    loop_ub_tmp = b_fk->size[0] * b_fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] -= r1[i];
    }
  } else {
    st.site = &q_emlrtRSI;
    minus(&st, b_fk, r4);
    fk_data = b_fk->data;
  }
  emxFree_real_T(sp, &r4);
  if ((r6->size[0] != b_fk->size[0]) &&
      ((r6->size[0] != 1) && (b_fk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[0], b_fk->size[0], &rb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((r6->size[1] != b_fk->size[1]) &&
      ((r6->size[1] != 1) && (b_fk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(r6->size[1], b_fk->size[1], &sb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[0] == a__3->size[0]) && (a__2->size[1] == a__3->size[1])) {
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      re = a__2_data[i].re;
      b = beta1_data[i].im;
      c = a__2_data[i].im;
      d1_re = beta1_data[i].re;
      a__2_data[i].re = re * d1_re - c * b;
      a__2_data[i].im = re * b + c * d1_re;
    }
  } else {
    st.site = &q_emlrtRSI;
    b_times(&st, a__2, a__3);
    a__2_data = a__2->data;
  }
  emxFree_creal_T(sp, &a__3);
  if ((r6->size[0] == b_fk->size[0]) && (r6->size[1] == b_fk->size[1])) {
    loop_ub_tmp = r6->size[0] * r6->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      r7[i].re *= fk_data[i];
      r7[i].im *= fk_data[i];
    }
  } else {
    times(sp, r6, b_fk);
  }
  st.site = &q_emlrtRSI;
  b_exp(&st, r6);
  r7 = r6->data;
  if ((a__2->size[0] != r6->size[0]) &&
      ((a__2->size[0] != 1) && (r6->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[0], r6->size[0], &pb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[1] != r6->size[1]) &&
      ((a__2->size[1] != 1) && (r6->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(a__2->size[1], r6->size[1], &qb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((a__2->size[0] == r6->size[0]) && (a__2->size[1] == r6->size[1])) {
    i = fk->size[0] * fk->size[1];
    fk->size[0] = a__2->size[0];
    fk->size[1] = a__2->size[1];
    emxEnsureCapacity_real_T(sp, fk, i, &lb_emlrtRTEI);
    tmp3_data = fk->data;
    loop_ub_tmp = a__2->size[0] * a__2->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      tmp3_data[i] = a__2_data[i].re * r7[i].re - a__2_data[i].im * r7[i].im;
    }
  } else {
    st.site = &q_emlrtRSI;
    binary_expand_op_1(&st, fk, a__2, r6);
    tmp3_data = fk->data;
  }
  emxFree_creal_T(sp, &r6);
  emxFree_creal_T(sp, &a__2);
  if (fk->size[1] < 1) {
    emlrtDynamicBoundsCheckR2012b(1, 1, fk->size[1], &f_emlrtBCI,
                                  (emlrtConstCTX)sp);
  }
  loop_ub = fk->size[0];
  i = r5->size[0];
  r5->size[0] = fk->size[0];
  emxEnsureCapacity_real_T(sp, r5, i, &mb_emlrtRTEI);
  r1 = r5->data;
  for (i = 0; i < loop_ub; i++) {
    r1[i] = 0.5 * tmp3_data[i];
  }
  emlrtSubAssignSizeCheckR2012b(&fk->size[0], 1, &r5->size[0], 1, &vb_emlrtECI,
                                (emlrtCTX)sp);
  for (i = 0; i < loop_ub; i++) {
    tmp3_data[i] = r1[i];
  }
  emxFree_real_T(sp, &r5);
  if ((fk->size[0] != vk->size[0]) &&
      ((fk->size[0] != 1) && (vk->size[0] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[0], vk->size[0], &wb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((fk->size[1] != vk->size[1]) &&
      ((fk->size[1] != 1) && (vk->size[1] != 1))) {
    emlrtDimSizeImpxCheckR2021b(fk->size[1], vk->size[1], &xb_emlrtECI,
                                (emlrtConstCTX)sp);
  }
  if ((fk->size[0] == vk->size[0]) && (fk->size[1] == vk->size[1])) {
    i = b_fk->size[0] * b_fk->size[1];
    b_fk->size[0] = fk->size[0];
    b_fk->size[1] = fk->size[1];
    emxEnsureCapacity_real_T(sp, b_fk, i, &nb_emlrtRTEI);
    fk_data = b_fk->data;
    loop_ub_tmp = fk->size[0] * fk->size[1];
    for (i = 0; i < loop_ub_tmp; i++) {
      fk_data[i] = tmp3_data[i] * vk_data[i];
    }
    st.site = &r_emlrtRSI;
    sum(&st, b_fk, varargin_1);
    tmp3_data = varargin_1->data;
  } else {
    st.site = &r_emlrtRSI;
    binary_expand_op(&st, varargin_1, r_emlrtRSI, fk, vk);
    tmp3_data = varargin_1->data;
  }
  emxFree_real_T(sp, &b_fk);
  emxFree_real_T(sp, &fk);
  emxFree_real_T(sp, &vk);
  loop_ub_tmp = varargin_1->size[0];
  for (i = 0; i < loop_ub_tmp; i++) {
    tmp3_data[i] *= d;
  }
  st.site = &r_emlrtRSI;
  if (sv1 < 0.0) {
    emlrtErrorWithMessageIdR2018a(
        &st, &g_emlrtRTEI, "Coder:toolbox:ElFunDomainError",
        "Coder:toolbox:ElFunDomainError", 3, 4, 4, "sqrt");
  }
  d = muDoubleScalarSqrt(sv1);
  i = VCvega->size[0];
  VCvega->size[0] = varargin_1->size[0];
  emxEnsureCapacity_real_T(sp, VCvega, i, &ob_emlrtRTEI);
  kay_data = VCvega->data;
  for (i = 0; i < loop_ub_tmp; i++) {
    b = tmp3_data[i];
    kay_data[i] = muDoubleScalarMax(b, 0.0) * 2.0 * d;
  }
  emxFree_real_T(sp, &varargin_1);
  emlrtHeapReferenceStackLeaveFcnR2012b((emlrtConstCTX)sp);
}

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