本文整理汇总了C++中emxEnsureCapacity函数的典型用法代码示例。如果您正苦于以下问题:C++ emxEnsureCapacity函数的具体用法?C++ emxEnsureCapacity怎么用?C++ emxEnsureCapacity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emxEnsureCapacity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: b_sum
/* Function Definitions */
void b_sum(const emxArray_real_T *x, emxArray_real_T *y)
{
uint32_T sz[2];
int32_T iy;
int32_T ixstart;
int32_T j;
real_T s;
for (iy = 0; iy < 2; iy++) {
sz[iy] = (uint32_T)x->size[iy];
}
iy = y->size[0];
y->size[0] = (int32_T)sz[0];
emxEnsureCapacity((emxArray__common *)y, iy, (int32_T)sizeof(real_T));
if (x->size[0] == 0) {
iy = y->size[0];
y->size[0] = (int32_T)sz[0];
emxEnsureCapacity((emxArray__common *)y, iy, (int32_T)sizeof(real_T));
ixstart = (int32_T)sz[0];
for (iy = 0; iy < ixstart; iy++) {
y->data[iy] = 0.0;
}
} else {
iy = -1;
ixstart = -1;
for (j = 1; j <= x->size[0]; j++) {
ixstart++;
s = x->data[ixstart] + x->data[ixstart + x->size[0]];
iy++;
y->data[iy] = s;
}
}
}
示例2: Assign_otherMakers_1
void Assign_otherMakers_1(emxArray_struct1_T *otherMakers, double
visual_k, double frequency, double time, const emxArray_real_T *Position, int
otherMakersN)
{
struct1_T b_otherMakers;
struct1_T c_otherMakers;
int i1;
int loop_ub;
emxInitStruct_struct1_T(&b_otherMakers);
emxInitStruct_struct1_T(&c_otherMakers);
// % 给 otherMakers 赋值函数 1
otherMakers->data[(int)visual_k - 1].frequency = frequency;
otherMakers->data[(int)visual_k - 1].time = time;
i1 = otherMakers->data[(int)visual_k - 1].Position->size[0] *
otherMakers->data[(int)visual_k - 1].Position->size[1];
otherMakers->data[(int)visual_k - 1].Position->size[0] = 3;
emxEnsureCapacity((emxArray__common *)otherMakers->data[(int)visual_k - 1].
Position, i1, (int)sizeof(double));
i1 = otherMakers->data[(int)visual_k - 1].Position->size[0] *
otherMakers->data[(int)visual_k - 1].Position->size[1];
otherMakers->data[(int)visual_k - 1].Position->size[1] = Position->size[1];
emxEnsureCapacity((emxArray__common *)otherMakers->data[(int)visual_k - 1].
Position, i1, (int)sizeof(double));
emxCopyStruct_struct1_T(&b_otherMakers, &otherMakers->data[(int)visual_k - 1]);
emxCopyStruct_struct1_T(&c_otherMakers, &otherMakers->data[(int)visual_k - 1]);
loop_ub = Position->size[0] * Position->size[1];
emxFreeStruct_struct1_T(&c_otherMakers);
emxFreeStruct_struct1_T(&b_otherMakers);
for (i1 = 0; i1 < loop_ub; i1++) {
otherMakers->data[(int)visual_k - 1].Position->data[i1] = Position->data[i1];
}
otherMakers->data[(int)visual_k - 1].otherMakersN = otherMakersN;
}
示例3: Cone
/* Function Definitions */
void Cone(const emlrtStack *sp, real_T k, const emxArray_real_T *x, const
emxArray_real_T *gridX, const emxArray_real_T *t, emxArray_real_T
*vals)
{
int32_T t_idx_0;
int32_T i49;
int32_T l;
int32_T i50;
int32_T i51;
int32_T i52;
int32_T i53;
int32_T i54;
emlrtStack st;
st.prev = sp;
st.tls = sp->tls;
/* calculate the matrix Cone for a specific space point x_k, for all times */
/* t_i in A */
/* points x_k=1:numel(spacePoints) */
t_idx_0 = t->size[1];
i49 = vals->size[0] * vals->size[1];
vals->size[0] = t_idx_0;
emxEnsureCapacity(sp, (emxArray__common *)vals, i49, (int32_T)sizeof(real_T),
&v_emlrtRTEI);
t_idx_0 = x->size[1];
i49 = vals->size[0] * vals->size[1];
vals->size[1] = t_idx_0;
emxEnsureCapacity(sp, (emxArray__common *)vals, i49, (int32_T)sizeof(real_T),
&v_emlrtRTEI);
t_idx_0 = t->size[1] * x->size[1];
for (i49 = 0; i49 < t_idx_0; i49++) {
vals->data[i49] = 0.0;
}
t_idx_0 = 1;
while (t_idx_0 - 1 <= t->size[1] - 1) {
l = 0;
while (l <= x->size[1] - 1) {
i49 = vals->size[0];
i50 = vals->size[1];
i51 = 1 + l;
i52 = x->size[1];
i53 = (int32_T)emlrtIntegerCheckFastR2012b(k, &nb_emlrtDCI, sp);
i54 = t->size[1];
st.site = &le_emlrtRSI;
vals->data[(emlrtDynamicBoundsCheckFastR2012b(t_idx_0, 1, i49,
&je_emlrtBCI, sp) + vals->size[0] * (emlrtDynamicBoundsCheckFastR2012b
(i51, 1, i50, &ke_emlrtBCI, sp) - 1)) - 1] = b_Ccoeff(&st, 1.0 + (real_T)
l, x->data[emlrtDynamicBoundsCheckFastR2012b(i53, 1, i52, &le_emlrtBCI,
sp) - 1], t->data[emlrtDynamicBoundsCheckFastR2012b(t_idx_0, 1, i54,
&me_emlrtBCI, sp) - 1], gridX);
l++;
emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp);
}
t_idx_0++;
emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp);
}
}
示例4: b_sum
/* Function Definitions */
void b_sum(const emlrtStack *sp, const emxArray_real_T *x, emxArray_real_T *y)
{
uint32_T sz[2];
int32_T iy;
int32_T ixstart;
boolean_T overflow;
int32_T j;
int32_T ix;
real_T s;
int32_T k;
emlrtStack st;
emlrtStack b_st;
st.prev = sp;
st.tls = sp->tls;
b_st.prev = &st;
b_st.tls = st.tls;
for (iy = 0; iy < 2; iy++) {
sz[iy] = (uint32_T)x->size[iy];
}
iy = y->size[0];
y->size[0] = (int32_T)sz[0];
emxEnsureCapacity(sp, (emxArray__common *)y, iy, (int32_T)sizeof(real_T),
&q_emlrtRTEI);
if (x->size[0] == 0) {
iy = y->size[0];
y->size[0] = (int32_T)sz[0];
emxEnsureCapacity(sp, (emxArray__common *)y, iy, (int32_T)sizeof(real_T),
&sb_emlrtRTEI);
ixstart = (int32_T)sz[0];
for (iy = 0; iy < ixstart; iy++) {
y->data[iy] = 0.0;
}
} else {
iy = -1;
ixstart = -1;
st.site = &be_emlrtRSI;
overflow = (x->size[0] > 2147483646);
if (overflow) {
b_st.site = &db_emlrtRSI;
check_forloop_overflow_error(&b_st);
}
for (j = 1; j <= x->size[0]; j++) {
ixstart++;
ix = ixstart;
s = x->data[ixstart];
for (k = 0; k < 2; k++) {
ix += x->size[0];
s += x->data[ix];
}
iy++;
y->data[iy] = s;
}
}
}
示例5: diag
void diag(const emlrtStack *sp, const emxArray_real_T *v, emxArray_real_T *d)
{
int32_T m;
int32_T n;
int32_T stride;
boolean_T b1;
emlrtStack st;
emlrtStack b_st;
st.prev = sp;
st.tls = sp->tls;
b_st.prev = &st;
b_st.tls = st.tls;
if ((v->size[0] == 1) && (v->size[1] == 1)) {
m = d->size[0];
d->size[0] = 1;
emxEnsureCapacity(sp, (emxArray__common *)d, m, (int32_T)sizeof(real_T),
&g_emlrtRTEI);
d->data[0] = v->data[0];
} else {
if (!((v->size[0] == 1) || (v->size[1] == 1))) {
} else {
emlrtErrorWithMessageIdR2012b(sp, &j_emlrtRTEI,
"Coder:toolbox:diag_varsizedMatrixVector", 0);
}
m = v->size[0];
n = v->size[1];
if (0 < v->size[1]) {
n = muIntScalarMin_sint32(m, n);
stride = v->size[0] + 1;
} else {
n = 0;
stride = 0;
}
m = d->size[0];
d->size[0] = n;
emxEnsureCapacity(sp, (emxArray__common *)d, m, (int32_T)sizeof(real_T),
&g_emlrtRTEI);
st.site = &j_emlrtRSI;
if (1 > n) {
b1 = false;
} else {
b1 = (n > 2147483646);
}
if (b1) {
b_st.site = &k_emlrtRSI;
check_forloop_overflow_error(&b_st);
}
for (m = 0; m + 1 <= n; m++) {
d->data[m] = v->data[m * stride];
}
}
}
示例6: deci2bin
/*
* 十进制数x转化为二进制数,二进制数至少表示为t位
* Arguments : double x
* double t
* emxArray_real_T *y
* Return Type : void
*/
void deci2bin(double x, double t, emxArray_real_T *y)
{
int i2;
int loop_ub;
unsigned int i;
int i3;
int i4;
emxArray_real_T *b_y;
i2 = y->size[0] * y->size[1];
y->size[0] = 1;
y->size[1] = (int)t;
emxEnsureCapacity((emxArray__common *)y, i2, (int)sizeof(double));
loop_ub = (int)t;
for (i2 = 0; i2 < loop_ub; i2++) {
y->data[i2] = 0.0;
}
i = 1U;
while ((x >= 0.0) && (i <= t)) {
y->data[(int)i - 1] = rt_remd_snf(x, 2.0);
x = (x - y->data[(int)i - 1]) / 2.0;
i++;
}
if (1.0 > t) {
i2 = 1;
i3 = 1;
i4 = 0;
} else {
i2 = (int)t;
i3 = -1;
i4 = 1;
}
emxInit_real_T(&b_y, 2);
loop_ub = b_y->size[0] * b_y->size[1];
b_y->size[0] = 1;
b_y->size[1] = div_s32_floor(i4 - i2, i3) + 1;
emxEnsureCapacity((emxArray__common *)b_y, loop_ub, (int)sizeof(double));
loop_ub = div_s32_floor(i4 - i2, i3);
for (i4 = 0; i4 <= loop_ub; i4++) {
b_y->data[b_y->size[0] * i4] = y->data[(i2 + i3 * i4) - 1];
}
i2 = y->size[0] * y->size[1];
y->size[0] = 1;
y->size[1] = b_y->size[1];
emxEnsureCapacity((emxArray__common *)y, i2, (int)sizeof(double));
loop_ub = b_y->size[1];
for (i2 = 0; i2 < loop_ub; i2++) {
y->data[y->size[0] * i2] = b_y->data[b_y->size[0] * i2];
}
emxFree_real_T(&b_y);
}
示例7: b_repmat
//
// Arguments : const int varargin_1[2]
// emxArray_uint8_T *b
// Return Type : void
//
void b_repmat(const int varargin_1[2], emxArray_uint8_T *b)
{
int i38;
int loop_ub;
i38 = b->size[0] * b->size[1];
b->size[0] = varargin_1[0];
emxEnsureCapacity((emxArray__common *)b, i38, (int)sizeof(unsigned char));
i38 = b->size[0] * b->size[1];
b->size[1] = varargin_1[1];
emxEnsureCapacity((emxArray__common *)b, i38, (int)sizeof(unsigned char));
loop_ub = varargin_1[0] * varargin_1[1];
for (i38 = 0; i38 < loop_ub; i38++) {
b->data[i38] = 0;
}
}
示例8: repmat
//
// Arguments : const int varargin_1[2]
// emxArray_real_T *b
// Return Type : void
//
void repmat(const int varargin_1[2], emxArray_real_T *b)
{
int i11;
int loop_ub;
i11 = b->size[0] * b->size[1];
b->size[0] = varargin_1[0];
emxEnsureCapacity((emxArray__common *)b, i11, (int)sizeof(double));
i11 = b->size[0] * b->size[1];
b->size[1] = varargin_1[1];
emxEnsureCapacity((emxArray__common *)b, i11, (int)sizeof(double));
loop_ub = varargin_1[0] * varargin_1[1];
for (i11 = 0; i11 < loop_ub; i11++) {
b->data[i11] = rtMinusInf;
}
}
示例9: b_polyfit
void b_polyfit(const emxArray_real_T *x, const emxArray_real_T *y, double p[3])
{
emxArray_real_T *V;
int n;
unsigned int unnamed_idx_0;
int i22;
int k;
emxArray_real_T *b_y;
double rr;
double p1[3];
emxInit_real_T(&V, 2);
n = x->size[0] - 1;
unnamed_idx_0 = (unsigned int)x->size[0];
i22 = V->size[0] * V->size[1];
V->size[0] = (int)unnamed_idx_0;
V->size[1] = 3;
emxEnsureCapacity((emxArray__common *)V, i22, (int)sizeof(double));
if ((int)unnamed_idx_0 == 0) {
} else {
for (k = 0; k <= n; k++) {
V->data[k + (V->size[0] << 1)] = 1.0;
}
for (k = 0; k <= n; k++) {
V->data[k + V->size[0]] = x->data[k];
}
for (k = 0; k <= n; k++) {
V->data[k] = x->data[k] * V->data[k + V->size[0]];
}
}
b_emxInit_real_T(&b_y, 1);
i22 = b_y->size[0];
b_y->size[0] = y->size[0];
emxEnsureCapacity((emxArray__common *)b_y, i22, (int)sizeof(double));
k = y->size[0];
for (i22 = 0; i22 < k; i22++) {
b_y->data[i22] = y->data[i22];
}
b_eml_qrsolve(V, b_y, p1, &rr);
emxFree_real_T(&b_y);
emxFree_real_T(&V);
for (i22 = 0; i22 < 3; i22++) {
p[i22] = p1[i22];
}
}
示例10: b_mrdivide
/*
* Arguments : emxArray_real_T *A
* const emxArray_real_T *B
* Return Type : void
*/
void b_mrdivide(emxArray_real_T *A, const emxArray_real_T *B)
{
emxArray_real_T *b_B;
emxArray_real_T *b_A;
int i8;
int loop_ub;
double d2;
emxInit_real_T1(&b_B, 1);
emxInit_real_T1(&b_A, 1);
if ((A->size[1] == 0) || (B->size[1] == 0)) {
i8 = A->size[0] * A->size[1];
A->size[0] = 1;
A->size[1] = 1;
emxEnsureCapacity((emxArray__common *)A, i8, (int)sizeof(double));
A->data[0] = 0.0;
} else if (1 == B->size[1]) {
if (A->size[1] == 0) {
} else {
A->data[0] *= 1.0 / B->data[0];
}
} else {
i8 = b_B->size[0];
b_B->size[0] = B->size[1];
emxEnsureCapacity((emxArray__common *)b_B, i8, (int)sizeof(double));
loop_ub = B->size[1];
for (i8 = 0; i8 < loop_ub; i8++) {
b_B->data[i8] = B->data[B->size[0] * i8];
}
i8 = b_A->size[0];
b_A->size[0] = A->size[1];
emxEnsureCapacity((emxArray__common *)b_A, i8, (int)sizeof(double));
loop_ub = A->size[1];
for (i8 = 0; i8 < loop_ub; i8++) {
b_A->data[i8] = A->data[A->size[0] * i8];
}
d2 = qrsolve(b_B, b_A);
i8 = A->size[0] * A->size[1];
A->size[0] = 1;
A->size[1] = 1;
emxEnsureCapacity((emxArray__common *)A, i8, (int)sizeof(double));
A->data[0] = d2;
}
emxFree_real_T(&b_A);
emxFree_real_T(&b_B);
}
示例11: d_sort
/*
* Arguments : emxArray_real_T *x
* Return Type : void
*/
void d_sort(emxArray_real_T *x)
{
emxArray_real_T *vwork;
int i9;
int k;
int i10;
emxArray_int32_T *b_vwork;
emxInit_real_T2(&vwork, 1);
i9 = x->size[1];
k = x->size[1];
i10 = vwork->size[0];
vwork->size[0] = k;
emxEnsureCapacity((emxArray__common *)vwork, i10, (int)sizeof(double));
for (k = 0; k + 1 <= i9; k++) {
vwork->data[k] = x->data[k];
}
emxInit_int32_T(&b_vwork, 1);
sortIdx(vwork, b_vwork);
k = 0;
emxFree_int32_T(&b_vwork);
while (k + 1 <= i9) {
x->data[k] = vwork->data[k];
k++;
}
emxFree_real_T(&vwork);
}
示例12: eye
void eye(real_T n, emxArray_real_T *I)
{
int32_T q;
int32_T loop_ub;
real_T d0;
q = I->size[0] * I->size[1];
I->size[0] = (int32_T)n;
I->size[1] = (int32_T)n;
emxEnsureCapacity((emxArray__common *)I, q, (int32_T)sizeof(real_T));
loop_ub = (int32_T)n * (int32_T)n - 1;
for (q = 0; q <= loop_ub; q++) {
I->data[q] = 0.0;
}
d0 = rt_roundd_snf(n);
if (d0 < 2.147483648E+9) {
if (d0 >= -2.147483648E+9) {
q = (int32_T)d0;
} else {
q = MIN_int32_T;
}
} else if (d0 >= 2.147483648E+9) {
q = MAX_int32_T;
} else {
q = 0;
}
if (q > 0) {
for (loop_ub = 0; loop_ub + 1 <= q; loop_ub++) {
I->data[loop_ub + I->size[0] * loop_ub] = 1.0;
}
}
}
示例13: sort
/*
* Arguments : double x_data[]
* int x_size[1]
* Return Type : void
*/
void sort(double x_data[], int x_size[1])
{
int dim;
int i6;
double vwork_data[252];
int vwork_size_idx_0;
int vstride;
int k;
int j;
emxArray_real_T *vwork;
emxArray_int32_T *b_vwork;
dim = nonSingletonDim(x_size);
if (dim <= 1) {
i6 = x_size[0];
} else {
i6 = 1;
}
vwork_size_idx_0 = (unsigned char)i6;
vstride = 1;
k = 1;
while (k <= dim - 1) {
vstride *= x_size[0];
k = 2;
}
j = 0;
emxInit_real_T2(&vwork, 1);
emxInit_int32_T(&b_vwork, 1);
while (j + 1 <= vstride) {
for (k = 0; k + 1 <= i6; k++) {
vwork_data[k] = x_data[j + k * vstride];
}
dim = vwork->size[0];
vwork->size[0] = vwork_size_idx_0;
emxEnsureCapacity((emxArray__common *)vwork, dim, (int)sizeof(double));
for (dim = 0; dim < vwork_size_idx_0; dim++) {
vwork->data[dim] = vwork_data[dim];
}
sortIdx(vwork, b_vwork);
vwork_size_idx_0 = vwork->size[0];
k = vwork->size[0];
for (dim = 0; dim < k; dim++) {
vwork_data[dim] = vwork->data[dim];
}
for (k = 0; k + 1 <= i6; k++) {
x_data[j + k * vstride] = vwork->data[k];
}
j++;
}
emxFree_int32_T(&b_vwork);
emxFree_real_T(&vwork);
}
示例14: c_sum
void c_sum(const emxArray_real_T *x, emxArray_real_T *y)
{
uint32_T sz[2];
int32_T ixstart;
int32_T k;
int32_T ix;
int32_T iy;
int32_T i;
real_T s;
for (ixstart = 0; ixstart < 2; ixstart++) {
sz[ixstart] = (uint32_T)x->size[ixstart];
}
ixstart = y->size[0] * y->size[1];
y->size[0] = 1;
y->size[1] = (int32_T)sz[1];
emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T));
if ((x->size[0] == 0) || (x->size[1] == 0)) {
ixstart = y->size[0] * y->size[1];
y->size[0] = 1;
emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T));
ixstart = y->size[0] * y->size[1];
y->size[1] = (int32_T)sz[1];
emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T));
k = (int32_T)sz[1];
for (ixstart = 0; ixstart < k; ixstart++) {
y->data[ixstart] = 0.0;
}
} else {
ix = -1;
iy = -1;
for (i = 1; i <= x->size[1]; i++) {
ixstart = ix + 1;
ix++;
s = x->data[ixstart];
for (k = 2; k <= x->size[0]; k++) {
ix++;
s += x->data[ix];
}
iy++;
y->data[iy] = s;
}
}
}
示例15: b_diag
/* Function Definitions */
void b_diag(const emlrtStack *sp, const emxArray_real_T *v, emxArray_real_T *d)
{
int32_T j;
int32_T unnamed_idx_1;
int32_T i3;
boolean_T overflow;
emlrtStack st;
emlrtStack b_st;
st.prev = sp;
st.tls = sp->tls;
b_st.prev = &st;
b_st.tls = st.tls;
j = v->size[0];
unnamed_idx_1 = v->size[0];
i3 = d->size[0] * d->size[1];
d->size[0] = j;
emxEnsureCapacity(sp, (emxArray__common *)d, i3, (int32_T)sizeof(real_T),
&g_emlrtRTEI);
i3 = d->size[0] * d->size[1];
d->size[1] = unnamed_idx_1;
emxEnsureCapacity(sp, (emxArray__common *)d, i3, (int32_T)sizeof(real_T),
&g_emlrtRTEI);
j *= unnamed_idx_1;
for (i3 = 0; i3 < j; i3++) {
d->data[i3] = 0.0;
}
st.site = &l_emlrtRSI;
if (1 > v->size[0]) {
overflow = false;
} else {
overflow = (v->size[0] > 2147483646);
}
if (overflow) {
b_st.site = &k_emlrtRSI;
check_forloop_overflow_error(&b_st);
}
for (j = 0; j + 1 <= v->size[0]; j++) {
d->data[j + d->size[0] * j] = v->data[j];
}
}