本文整理汇总了C++中NumArg函数的典型用法代码示例。如果您正苦于以下问题:C++ NumArg函数的具体用法?C++ NumArg怎么用?C++ NumArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NumArg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: reverse_powpv_op
inline void reverse_powpv_op(
size_t d ,
size_t i_z ,
const addr_t* arg ,
const Base* parameter ,
size_t cap_order ,
const Base* taylor ,
size_t nc_partial ,
Base* partial )
{
// convert from final result to first result
i_z -= 2; // NumRes(PowpvOp) - 1;
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 );
CPPAD_ASSERT_UNKNOWN( d < cap_order );
CPPAD_ASSERT_UNKNOWN( d < nc_partial );
// z_2 = exp(z_1)
reverse_exp_op(
d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial
);
// 2DO: remove requirement that i_z * cap_order <= max addr_t value
CPPAD_ASSERT_KNOWN(
std::numeric_limits<addr_t>::max() >= i_z * cap_order,
"cppad_tape_addr_type maximum value has been exceeded\n"
"This is due to a kludge in the pow operation and should be fixed."
);
// z_1 = z_0 * y
addr_t adr[2];
adr[0] = addr_t( i_z * cap_order ); // offset of z_0[0] in taylor
adr[1] = arg[1]; // index of y in taylor and partial
// use taylor both for parameter and variable values
reverse_mulpv_op(
d, i_z+1, adr, taylor, cap_order, taylor, nc_partial, partial
);
// z_0 = log(x)
// x is a parameter
}
开发者ID:kaskr,项目名称:CppAD,代码行数:43,代码来源:pow_op.hpp
示例2: forward_atan_op_0
inline void forward_atan_op_0(
size_t i_z ,
size_t i_x ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(AtanOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 2 );
CPPAD_ASSERT_UNKNOWN( 0 < cap_order );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * cap_order;
Base* z = taylor + i_z * cap_order;
Base* b = z - cap_order; // called y in documentation
z[0] = atan( x[0] );
b[0] = Base(1.0) + x[0] * x[0];
}
开发者ID:kaskr,项目名称:CppAD,代码行数:19,代码来源:atan_op.hpp
示例3: forward_cos_op_0
inline void forward_cos_op_0(
size_t i_z ,
size_t i_x ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 );
CPPAD_ASSERT_UNKNOWN( 0 < cap_order );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * cap_order;
Base* c = taylor + i_z * cap_order; // called z in documentation
Base* s = c - cap_order; // called y in documentation
c[0] = cos( x[0] );
s[0] = sin( x[0] );
}
开发者ID:barak,项目名称:CppAD-1,代码行数:19,代码来源:cos_op.hpp
示例4: reverse_divpv_op
inline void reverse_divpv_op(
size_t d ,
size_t i_z ,
const size_t* arg ,
const Base* parameter ,
size_t nc_taylor ,
const Base* taylor ,
size_t nc_partial ,
Base* partial )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 );
CPPAD_ASSERT_UNKNOWN( arg[1] < i_z );
CPPAD_ASSERT_UNKNOWN( d < nc_taylor );
CPPAD_ASSERT_UNKNOWN( d < nc_partial );
// Arguments
const Base* y = taylor + arg[1] * nc_taylor;
const Base* z = taylor + i_z * nc_taylor;
// Partial derivatives corresponding to arguments and result
Base* py = partial + arg[1] * nc_partial;
Base* pz = partial + i_z * nc_partial;
// Using CondExp, it can make sense to divide by zero so do not
// make it an error.
size_t k;
// number of indices to access
size_t j = d + 1;
while(j)
{ --j;
// scale partial w.r.t z[j]
pz[j] /= y[0];
for(k = 1; k <= j; k++)
{ pz[j-k] -= pz[j] * y[k];
py[k] -= pz[j] * z[j-k];
}
py[0] -= pz[j] * z[j];
}
}
开发者ID:jnorthrup,项目名称:jmodelica,代码行数:43,代码来源:div_op.hpp
示例5: forward_sign_op_0
inline void forward_sign_op_0(
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 );
CPPAD_ASSERT_UNKNOWN( i_x < i_z );
CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor );
// Taylor coefficients corresponding to argument and result
Base x0 = *(taylor + i_x * nc_taylor);
Base* z = taylor + i_z * nc_taylor;
z[0] = sign(x0);
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:19,代码来源:sign_op.hpp
示例6: reverse_sign_op
inline void reverse_sign_op(
size_t d ,
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
const Base* taylor ,
size_t nc_partial ,
Base* partial )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 );
CPPAD_ASSERT_UNKNOWN( i_x < i_z );
CPPAD_ASSERT_UNKNOWN( d < nc_taylor );
CPPAD_ASSERT_UNKNOWN( d < nc_partial );
// nothing to do because partials of sign are zero
return;
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:19,代码来源:sign_op.hpp
示例7: reverse_sqrt_op
inline void reverse_sqrt_op(
size_t d ,
size_t i_z ,
size_t i_x ,
size_t cap_order ,
const Base* taylor ,
size_t nc_partial ,
Base* partial )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SqrtOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 1 );
CPPAD_ASSERT_UNKNOWN( d < cap_order );
CPPAD_ASSERT_UNKNOWN( d < nc_partial );
// Taylor coefficients and partials corresponding to argument
Base* px = partial + i_x * nc_partial;
// Taylor coefficients and partials corresponding to result
const Base* z = taylor + i_z * cap_order;
Base* pz = partial + i_z * nc_partial;
Base inv_z0 = Base(1) / z[0];
// number of indices to access
size_t j = d;
size_t k;
while(j)
{
// scale partial w.r.t. z[j]
pz[j] = azmul(pz[j], inv_z0);
pz[0] -= azmul(pz[j], z[j]);
px[j] += pz[j] / Base(2);
for(k = 1; k < j; k++)
pz[k] -= azmul(pz[j], z[j-k]);
--j;
}
px[0] += azmul(pz[0], inv_z0) / Base(2);
}
开发者ID:jonathancurrie,项目名称:OPTI,代码行数:42,代码来源:sqrt_op.hpp
示例8: forward_powvv_op
inline void forward_powvv_op(
size_t p ,
size_t q ,
size_t i_z ,
const addr_t* arg ,
const Base* parameter ,
size_t cap_order ,
Base* taylor )
{
// convert from final result to first result
i_z -= 2; // 2 = NumRes(PowvvOp) - 1;
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 );
CPPAD_ASSERT_UNKNOWN( q < cap_order );
CPPAD_ASSERT_UNKNOWN( p <= q );
CPPAD_ASSERT_UNKNOWN( std::numeric_limits<addr_t>::max() >= i_z );
// z_0 = log(x)
forward_log_op(p, q, i_z, arg[0], cap_order, taylor);
// z_1 = z_0 * y
addr_t adr[2];
adr[0] = addr_t( i_z );
adr[1] = arg[1];
forward_mulvv_op(p, q, i_z+1, adr, parameter, cap_order, taylor);
// z_2 = exp(z_1)
// final result for zero order case is exactly the same as for Base
if( p == 0 )
{ // Taylor coefficients corresponding to arguments and result
Base* x = taylor + arg[0] * cap_order;
Base* y = taylor + arg[1] * cap_order;
Base* z_2 = taylor + (i_z+2) * cap_order;
z_2[0] = pow(x[0], y[0]);
p++;
}
if( p <= q )
forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor);
}
开发者ID:kaskr,项目名称:CppAD,代码行数:42,代码来源:pow_op.hpp
示例9: reverse_abs_op
inline void reverse_abs_op(
size_t d ,
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
const Base* taylor ,
size_t nc_partial ,
Base* partial )
{ size_t j, k;
static Base zero(0);
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 );
CPPAD_ASSERT_UNKNOWN( i_x < i_z );
CPPAD_ASSERT_UNKNOWN( d < nc_taylor );
CPPAD_ASSERT_UNKNOWN( d < nc_partial );
// Taylor coefficients and partials corresponding to argument
const Base* x = taylor + i_x * nc_taylor;
Base* px = partial + i_x * nc_partial;
// Taylor coefficients and partials corresponding to result
Base* pz = partial + i_z * nc_partial;
// order that decides positive, negative or zero
k = 0;
while( (k < d) & (x[k] == zero) )
k++;
if( GreaterThanZero(x[k]) )
{ // partial of z w.r.t y is +1
for(j = k; j <= d; j++)
px[j] += pz[j];
}
else if( LessThanZero(x[k]) )
{ // partial of z w.r.t y is -1
for(j = k; j <= d; j++)
px[j] -= pz[j];
}
}
开发者ID:jnorthrup,项目名称:jmodelica,代码行数:42,代码来源:abs_op.hpp
示例10: forward_sinh_op
inline void forward_sinh_op(
size_t p ,
size_t q ,
size_t i_z ,
size_t i_x ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 );
CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z );
CPPAD_ASSERT_UNKNOWN( q < cap_order );
CPPAD_ASSERT_UNKNOWN( p <= q );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * cap_order;
Base* s = taylor + i_z * cap_order;
Base* c = s - cap_order;
// rest of this routine is identical for the following cases:
// forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op
// (except that there is a sign difference for hyperbolic case).
size_t k;
if( p == 0 )
{ s[0] = sinh( x[0] );
c[0] = cosh( x[0] );
p++;
}
for(size_t j = p; j <= q; j++)
{
s[j] = Base(0);
c[j] = Base(0);
for(k = 1; k <= j; k++)
{ s[j] += Base(k) * x[k] * c[j-k];
c[j] += Base(k) * x[k] * s[j-k];
}
s[j] /= Base(j);
c[j] /= Base(j);
}
}
开发者ID:TheoMichelot,项目名称:adcomp,代码行数:42,代码来源:sinh_op.hpp
示例11: forward_tanh_op_0
inline void forward_tanh_op_0(
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 );
CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z );
CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * nc_taylor;
Base* z = taylor + i_z * nc_taylor; // called z in documentation
Base* y = z - nc_taylor; // called y in documentation
z[0] = tanh( x[0] );
y[0] = z[0] * z[0];
}
开发者ID:AndreasBrack,项目名称:WahlkreisSeminar,代码行数:20,代码来源:tanh_op.hpp
示例12: forward_divvv_op_0
inline void forward_divvv_op_0(
size_t i_z ,
const size_t* arg ,
const Base* parameter ,
size_t nc_taylor ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 );
CPPAD_ASSERT_UNKNOWN( arg[0] < i_z );
CPPAD_ASSERT_UNKNOWN( arg[1] < i_z );
// Taylor coefficients corresponding to arguments and result
Base* x = taylor + arg[0] * nc_taylor;
Base* y = taylor + arg[1] * nc_taylor;
Base* z = taylor + i_z * nc_taylor;
z[0] = x[0] / y[0];
}
开发者ID:jnorthrup,项目名称:jmodelica,代码行数:20,代码来源:div_op.hpp
示例13: forward_zmulpv_op_0
inline void forward_zmulpv_op_0(
size_t i_z ,
const addr_t* arg ,
const Base* parameter ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 );
// Paraemter value
Base x = parameter[ arg[0] ];
// Taylor coefficients corresponding to arguments and result
Base* y = taylor + arg[1] * cap_order;
Base* z = taylor + i_z * cap_order;
z[0] = azmul(x, y[0]);
}
开发者ID:barak,项目名称:CppAD-1,代码行数:20,代码来源:zmul_op.hpp
示例14: reverse_sparse_jacobian_load_op
inline void reverse_sparse_jacobian_load_op(
OpCode op ,
size_t i_z ,
const addr_t* arg ,
size_t num_combined ,
const size_t* combined ,
Vector_set& var_sparsity ,
Vector_set& vecad_sparsity )
{
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 );
CPPAD_ASSERT_UNKNOWN( 0 < arg[0] );
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined );
size_t i_v = combined[ arg[0] - 1 ];
CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity);
return;
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:20,代码来源:load_op.hpp
示例15: forward_sparse_store_op
inline void forward_sparse_store_op(
OpCode op ,
const addr_t* arg ,
size_t num_combined ,
const size_t* combined ,
Vector_set& var_sparsity ,
Vector_set& vecad_sparsity )
{
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 );
CPPAD_ASSERT_UNKNOWN( 0 < arg[0] );
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined );
size_t i_v = combined[ arg[0] - 1 ];
CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() );
vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity);
return;
}
开发者ID:modsim,项目名称:CADET-semi-analytic,代码行数:20,代码来源:store_op.hpp
示例16: forward_sinh_op_0
inline void forward_sinh_op_0(
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 );
CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z );
CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * nc_taylor;
Base* s = taylor + i_z * nc_taylor; // called z in documentation
Base* c = s - nc_taylor; // called y in documentation
s[0] = sinh( x[0] );
c[0] = cosh( x[0] );
}
开发者ID:tkelman,项目名称:OS-oldmirror,代码行数:20,代码来源:sinh_op.hpp
示例17: forward_asin_op_0
inline void forward_asin_op_0(
size_t i_z ,
size_t i_x ,
size_t nc_taylor ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 );
CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 );
CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z );
CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor );
// Taylor coefficients corresponding to argument and result
Base* x = taylor + i_x * nc_taylor;
Base* z = taylor + i_z * nc_taylor;
Base* b = z - nc_taylor; // called y in documentation
z[0] = asin( x[0] );
b[0] = sqrt( Base(1) - x[0] * x[0] );
}
开发者ID:markpayneatwork,项目名称:adcomp,代码行数:20,代码来源:asin_op.hpp
示例18: forward_subvv_op_0
inline void forward_subvv_op_0(
size_t i_z ,
const addr_t* arg ,
const Base* parameter ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(SubvvOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 );
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z );
CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z );
// Taylor coefficients corresponding to arguments and result
Base* x = taylor + arg[0] * cap_order;
Base* y = taylor + arg[1] * cap_order;
Base* z = taylor + i_z * cap_order;
z[0] = x[0] - y[0];
}
开发者ID:TheoMichelot,项目名称:adcomp,代码行数:20,代码来源:sub_op.hpp
示例19: forward_divvp_op_0
inline void forward_divvp_op_0(
size_t i_z ,
const addr_t* arg ,
const Base* parameter ,
size_t cap_order ,
Base* taylor )
{
// check assumptions
CPPAD_ASSERT_UNKNOWN( NumArg(DivvpOp) == 2 );
CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 );
// Parameter value
Base y = parameter[ arg[1] ];
// Taylor coefficients corresponding to arguments and result
Base* x = taylor + arg[0] * cap_order;
Base* z = taylor + i_z * cap_order;
z[0] = x[0] / y;
}
开发者ID:ChinaQuants,项目名称:QuantLibAdjoint,代码行数:20,代码来源:div_op.hpp
示例20: forward_sparse_load_op
inline void forward_sparse_load_op(
OpCode op ,
size_t i_z ,
const addr_t* arg ,
size_t num_combined ,
const size_t* combined ,
Vector_set& var_sparsity ,
Vector_set& vecad_sparsity )
{
CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 );
CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 );
CPPAD_ASSERT_UNKNOWN( 0 < arg[0] );
CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined );
size_t i_v = combined[ arg[0] - 1 ];
CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() );
var_sparsity.assignment(i_z, i_v, vecad_sparsity);
return;
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:20,代码来源:load_op.hpp
注:本文中的NumArg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论