本文整理汇总了C++中DOMAIN_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ DOMAIN_ERROR函数的具体用法?C++ DOMAIN_ERROR怎么用?C++ DOMAIN_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DOMAIN_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gsl_sf_ellint_RC_e
int
gsl_sf_ellint_RC_e(double x, double y, gsl_mode_t mode, gsl_sf_result * result)
{
const double lolim = 5.0 * GSL_DBL_MIN;
const double uplim = 0.2 * GSL_DBL_MAX;
const gsl_prec_t goal = GSL_MODE_PREC(mode);
const double errtol = ( goal == GSL_PREC_DOUBLE ? 0.001 : 0.03 );
const double prec = gsl_prec_eps[goal];
if(x < 0.0 || y < 0.0 || x + y < lolim) {
DOMAIN_ERROR(result);
}
else if(GSL_MAX(x, y) < uplim) {
const double c1 = 1.0 / 7.0;
const double c2 = 9.0 / 22.0;
double xn = x;
double yn = y;
double mu, sn, lamda, s;
while(1) {
mu = (xn + yn + yn) / 3.0;
sn = (yn + mu) / mu - 2.0;
if (fabs(sn) < errtol) break;
lamda = 2.0 * sqrt(xn) * sqrt(yn) + yn;
xn = (xn + lamda) * 0.25;
yn = (yn + lamda) * 0.25;
}
s = sn * sn * (0.3 + sn * (c1 + sn * (0.375 + sn * c2)));
result->val = (1.0 + s) / sqrt(mu);
result->err = prec * fabs(result->val);
return GSL_SUCCESS;
}
else {
DOMAIN_ERROR(result);
}
}
示例2: gsl_sf_ellint_RD_e
int
gsl_sf_ellint_RD_e(double x, double y, double z, gsl_mode_t mode, gsl_sf_result * result)
{
const gsl_prec_t goal = GSL_MODE_PREC(mode);
const double errtol = ( goal == GSL_PREC_DOUBLE ? 0.001 : 0.03 );
const double prec = gsl_prec_eps[goal];
const double lolim = 2.0/pow(GSL_DBL_MAX, 2.0/3.0);
const double uplim = pow(0.1*errtol/GSL_DBL_MIN, 2.0/3.0);
if(GSL_MIN(x,y) < 0.0 || GSL_MIN(x+y,z) < lolim) {
DOMAIN_ERROR(result);
}
else if(locMAX3(x,y,z) < uplim) {
const double c1 = 3.0 / 14.0;
const double c2 = 1.0 / 6.0;
const double c3 = 9.0 / 22.0;
const double c4 = 3.0 / 26.0;
double xn = x;
double yn = y;
double zn = z;
double sigma = 0.0;
double power4 = 1.0;
double ea, eb, ec, ed, ef, s1, s2;
double mu, xndev, yndev, zndev;
while(1) {
double xnroot, ynroot, znroot, lamda;
double epslon;
mu = (xn + yn + 3.0 * zn) * 0.2;
xndev = (mu - xn) / mu;
yndev = (mu - yn) / mu;
zndev = (mu - zn) / mu;
epslon = locMAX3(fabs(xndev), fabs(yndev), fabs(zndev));
if (epslon < errtol) break;
xnroot = sqrt(xn);
ynroot = sqrt(yn);
znroot = sqrt(zn);
lamda = xnroot * (ynroot + znroot) + ynroot * znroot;
sigma += power4 / (znroot * (zn + lamda));
power4 *= 0.25;
xn = (xn + lamda) * 0.25;
yn = (yn + lamda) * 0.25;
zn = (zn + lamda) * 0.25;
}
ea = xndev * yndev;
eb = zndev * zndev;
ec = ea - eb;
ed = ea - 6.0 * eb;
ef = ed + ec + ec;
s1 = ed * (- c1 + 0.25 * c3 * ed - 1.5 * c4 * zndev * ef);
s2 = zndev * (c2 * ef + zndev * (- c3 * ec + zndev * c4 * ea));
result->val = 3.0 * sigma + power4 * (1.0 + s1 + s2) / (mu * sqrt(mu));
result->err = prec * fabs(result->val);
return GSL_SUCCESS;
}
else {
DOMAIN_ERROR(result);
}
}
示例3: get_trait
static int get_trait(SEXP variable, struct design *s, struct design *r, struct variable *v)
{
SEXP dim, cn, dn, nm;
int j, n, p;
double *xt, *x;
size_t dims[VAR_RANK_MAX];
size_t rank;
dim = GET_DIM(variable);
n = INTEGER(dim)[0];
p = INTEGER(dim)[1];
xt = NUMERIC_POINTER(variable);
x = (void *)R_alloc(n * p, sizeof(*x));
if (p == 0)
DOMAIN_ERROR("variable dimensions must be nonzero");
if (n > 0)
matrix_dtrans(n, p, xt, n, x, p);
if (p == 1) {
rank = 0;
} else {
rank = 1;
dims[0] = (size_t)p;
}
if (inherits(variable, "send")) {
if (n != design_count(s))
DOMAIN_ERROR("variable dimension must match sender count");
v->design = VARIABLE_DESIGN_SEND;
v->var.send = design_add_trait(s, NULL, x, dims, rank);
} else {
if (n != design_count(r))
DOMAIN_ERROR("variable dimension must match receiver count");
v->design = VARIABLE_DESIGN_RECV;
v->var.recv = design_add_trait(r, NULL, x, dims, rank);
}
v->type = VARIABLE_TYPE_TRAIT;
dn = GET_DIMNAMES(variable);
cn = GET_COLNAMES(dn);
v->names = (void *)R_alloc(p, sizeof(*v->names));
for (j = 0; j < p; j++) {
nm = STRING_ELT(cn, j);
v->names[j] = CHAR(nm);
}
return 0;
}
示例4: gsl_sf_ellint_RF_e
int
gsl_sf_ellint_RF_e(double x, double y, double z, gsl_mode_t mode, gsl_sf_result * result)
{
const double lolim = 5.0 * GSL_DBL_MIN;
const double uplim = 0.2 * GSL_DBL_MAX;
const gsl_prec_t goal = GSL_MODE_PREC(mode);
const double errtol = ( goal == GSL_PREC_DOUBLE ? 0.001 : 0.03 );
const double prec = gsl_prec_eps[goal];
if(x < 0.0 || y < 0.0 || z < 0.0) {
DOMAIN_ERROR(result);
}
else if(x+y < lolim || x+z < lolim || y+z < lolim) {
DOMAIN_ERROR(result);
}
else if(locMAX3(x,y,z) < uplim) {
const double c1 = 1.0 / 24.0;
const double c2 = 3.0 / 44.0;
const double c3 = 1.0 / 14.0;
double xn = x;
double yn = y;
double zn = z;
double mu, xndev, yndev, zndev, e2, e3, s;
while(1) {
double epslon, lamda;
double xnroot, ynroot, znroot;
mu = (xn + yn + zn) / 3.0;
xndev = 2.0 - (mu + xn) / mu;
yndev = 2.0 - (mu + yn) / mu;
zndev = 2.0 - (mu + zn) / mu;
epslon = locMAX3(fabs(xndev), fabs(yndev), fabs(zndev));
if (epslon < errtol) break;
xnroot = sqrt(xn);
ynroot = sqrt(yn);
znroot = sqrt(zn);
lamda = xnroot * (ynroot + znroot) + ynroot * znroot;
xn = (xn + lamda) * 0.25;
yn = (yn + lamda) * 0.25;
zn = (zn + lamda) * 0.25;
}
e2 = xndev * yndev - zndev * zndev;
e3 = xndev * yndev * zndev;
s = 1.0 + (c1 * e2 - 0.1 - c2 * e3) * e2 + c3 * e3;
result->val = s / sqrt(mu);
result->err = prec * fabs(result->val);
return GSL_SUCCESS;
}
else {
DOMAIN_ERROR(result);
}
}
示例5: gsl_sf_zeta_int_e
int gsl_sf_zeta_int_e(const int n, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(n < 0) {
if(!GSL_IS_ODD(n)) {
result->val = 0.0; /* exactly zero at even negative integers */
result->err = 0.0;
return GSL_SUCCESS;
}
else if(n > -ZETA_NEG_TABLE_NMAX) {
result->val = zeta_neg_int_table[-(n+1)/2];
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
return gsl_sf_zeta_e((double)n, result);
}
}
else if(n == 1){
DOMAIN_ERROR(result);
}
else if(n <= ZETA_POS_TABLE_NMAX){
result->val = 1.0 + zetam1_pos_int_table[n];
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
result->val = 1.0;
result->err = GSL_DBL_EPSILON;
return GSL_SUCCESS;
}
}
示例6: gsl_sf_bessel_K0_e
int gsl_sf_bessel_K0_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(x <= 2.0) {
const double lx = log(x);
int stat_I0;
gsl_sf_result I0;
gsl_sf_result c;
cheb_eval_e(&bk0_cs, 0.5*x*x-1.0, &c);
stat_I0 = gsl_sf_bessel_I0_e(x, &I0);
result->val = (-lx+M_LN2)*I0.val - 0.25 + c.val;
result->err = (fabs(lx) + M_LN2) * I0.err + c.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return stat_I0;
}
else {
gsl_sf_result K0_scaled;
int stat_K0 = gsl_sf_bessel_K0_scaled_e(x, &K0_scaled);
int stat_e = gsl_sf_exp_mult_err_e(-x, GSL_DBL_EPSILON*fabs(x),
K0_scaled.val, K0_scaled.err,
result);
return GSL_ERROR_SELECT_2(stat_e, stat_K0);
}
}
示例7: gsl_sf_psi_int_e
int gsl_sf_psi_int_e(const int n, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(n <= 0) {
DOMAIN_ERROR(result);
}
else if(n <= PSI_TABLE_NMAX) {
result->val = psi_table[n];
result->err = GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
/* Abramowitz+Stegun 6.3.18 */
const double c2 = -1.0/12.0;
const double c3 = 1.0/120.0;
const double c4 = -1.0/252.0;
const double c5 = 1.0/240.0;
const double ni2 = (1.0/n)*(1.0/n);
const double ser = ni2 * (c2 + ni2 * (c3 + ni2 * (c4 + ni2*c5)));
result->val = log(n) - 0.5/n + ser;
result->err = GSL_DBL_EPSILON * (fabs(log(n)) + fabs(0.5/n) + fabs(ser));
result->err += GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
}
示例8: gsl_sf_psi_1_int_e
int gsl_sf_psi_1_int_e(const int n, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(n <= 0) {
DOMAIN_ERROR(result);
}
else if(n <= PSI_1_TABLE_NMAX) {
result->val = psi_1_table[n];
result->err = GSL_DBL_EPSILON * result->val;
return GSL_SUCCESS;
}
else {
/* Abramowitz+Stegun 6.4.12
* double-precision for n > 100
*/
const double c0 = -1.0/30.0;
const double c1 = 1.0/42.0;
const double c2 = -1.0/30.0;
const double ni2 = (1.0/n)*(1.0/n);
const double ser = ni2*ni2 * (c0 + ni2*(c1 + c2*ni2));
result->val = (1.0 + 0.5/n + 1.0/(6.0*n*n) + ser) / n;
result->err = GSL_DBL_EPSILON * result->val;
return GSL_SUCCESS;
}
}
示例9: gsl_sf_hyperg_2F0_e
int
gsl_sf_hyperg_2F0_e(const double a, const double b, const double x, gsl_sf_result * result)
{
if(x < 0.0) {
/* Use "definition" 2F0(a,b,x) = (-1/x)^a U(a,1+a-b,-1/x).
*/
gsl_sf_result U;
double pre = pow(-1.0/x, a);
int stat_U = gsl_sf_hyperg_U_e(a, 1.0+a-b, -1.0/x, &U);
result->val = pre * U.val;
result->err = GSL_DBL_EPSILON * fabs(result->val) + pre * U.err;
return stat_U;
}
else if(x == 0.0) {
result->val = 1.0;
result->err = 0.0;
return GSL_SUCCESS;
}
else {
/* Use asymptotic series. ??
*/
/* return hyperg_2F0_series(a, b, x, -1, result, &prec); */
DOMAIN_ERROR(result);
}
}
示例10: gsl_sf_legendre_H3d_0_e
int
gsl_sf_legendre_H3d_0_e(const double lambda, const double eta, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(eta < 0.0) {
DOMAIN_ERROR(result);
}
else if(eta == 0.0 || lambda == 0.0) {
result->val = 1.0;
result->err = 0.0;
return GSL_SUCCESS;
}
else {
const double lam_eta = lambda * eta;
gsl_sf_result s;
gsl_sf_sin_err_e(lam_eta, 2.0*GSL_DBL_EPSILON * fabs(lam_eta), &s);
if(eta > -0.5*GSL_LOG_DBL_EPSILON) {
double f = 2.0 / lambda * exp(-eta);
result->val = f * s.val;
result->err = fabs(f * s.val) * (fabs(eta) + 1.0) * GSL_DBL_EPSILON;
result->err += fabs(f) * s.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
}
else {
double f = 1.0/(lambda*sinh(eta));
result->val = f * s.val;
result->err = fabs(f * s.val) * (fabs(eta) + 1.0) * GSL_DBL_EPSILON;
result->err += fabs(f) * s.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
}
return GSL_SUCCESS;
}
}
示例11: gsl_sf_hydrogenicR_e
int
gsl_sf_hydrogenicR_e(const int n, const int l,
const double Z, const double r,
gsl_sf_result * result)
{
if(n < 1 || l > n-1 || Z <= 0.0 || r < 0.0) {
DOMAIN_ERROR(result);
}
else {
double A = 2.0*Z/n;
gsl_sf_result norm;
int stat_norm = R_norm(n, l, Z, &norm);
double rho = A*r;
double ea = exp(-0.5*rho);
double pp = gsl_sf_pow_int(rho, l);
gsl_sf_result lag;
int stat_lag = gsl_sf_laguerre_n_e(n-l-1, 2*l+1, rho, &lag);
double W_val = norm.val * ea * pp;
double W_err = norm.err * ea * pp;
W_err += norm.val * ((0.5*rho + 1.0) * GSL_DBL_EPSILON) * ea * pp;
W_err += norm.val * ea * ((l+1.0) * GSL_DBL_EPSILON) * pp;
result->val = W_val * lag.val;
result->err = W_val * lag.err + W_err * fabs(lag.val);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
if ((l == 0 || (r > 0 && l > 0)) && lag.val != 0.0
&& stat_lag == GSL_SUCCESS && stat_norm == GSL_SUCCESS) {
CHECK_UNDERFLOW(result);
};
return GSL_ERROR_SELECT_2(stat_lag, stat_norm);
}
}
示例12: gsl_sf_bessel_K1_e
int gsl_sf_bessel_K1_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(x < 2.0*GSL_DBL_MIN) {
OVERFLOW_ERROR(result);
}
else if(x <= 2.0) {
const double lx = log(x);
int stat_I1;
gsl_sf_result I1;
gsl_sf_result c;
cheb_eval_e(&bk1_cs, 0.5*x*x-1.0, &c);
stat_I1 = gsl_sf_bessel_I1_e(x, &I1);
result->val = (lx-M_LN2)*I1.val + (0.75 + c.val)/x;
result->err = c.err/x + fabs(lx)*I1.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return stat_I1;
}
else {
gsl_sf_result K1_scaled;
int stat_K1 = gsl_sf_bessel_K1_scaled_e(x, &K1_scaled);
int stat_e = gsl_sf_exp_mult_err_e(-x, 0.0,
K1_scaled.val, K1_scaled.err,
result);
result->err = fabs(result->val) * (GSL_DBL_EPSILON*fabs(x) + K1_scaled.err/K1_scaled.val);
return GSL_ERROR_SELECT_2(stat_e, stat_K1);
}
}
示例13: gsl_sf_ellint_Ecomp_e
/* [Carlson, Numer. Math. 33 (1979) 1, (4.6)] */
int
gsl_sf_ellint_Ecomp_e(double k, gsl_mode_t mode, gsl_sf_result * result)
{
if(k*k >= 1.0) {
DOMAIN_ERROR(result);
}
else if(k*k >= 1.0 - GSL_SQRT_DBL_EPSILON) {
/* [Abramowitz+Stegun, 17.3.36] */
const double y = 1.0 - k*k;
const double a[] = { 0.44325141463, 0.06260601220, 0.04757383546 };
const double b[] = { 0.24998368310, 0.09200180037, 0.04069697526 };
const double ta = 1.0 + y*(a[0] + y*(a[1] + a[2]*y));
const double tb = -y*log(y) * (b[0] + y*(b[1] + b[2]*y));
result->val = ta + tb;
result->err = 2.0 * GSL_DBL_EPSILON * result->val;
return GSL_SUCCESS;
}
else {
gsl_sf_result rf;
gsl_sf_result rd;
const double y = 1.0 - k*k;
const int rfstatus = gsl_sf_ellint_RF_e(0.0, y, 1.0, mode, &rf);
const int rdstatus = gsl_sf_ellint_RD_e(0.0, y, 1.0, mode, &rd);
result->val = rf.val - k*k/3.0 * rd.val;
result->err = rf.err + k*k/3.0 * rd.err;
return GSL_ERROR_SELECT_2(rfstatus, rdstatus);
}
}
示例14: gsl_sf_psi_n_e
int gsl_sf_psi_n_e(const int n, const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(n == 0)
{
return gsl_sf_psi_e(x, result);
}
else if(n == 1)
{
return gsl_sf_psi_1_e(x, result);
}
else if(n < 0 || x <= 0.0) {
DOMAIN_ERROR(result);
}
else {
gsl_sf_result ln_nf;
gsl_sf_result hzeta;
int stat_hz = gsl_sf_hzeta_e(n+1.0, x, &hzeta);
int stat_nf = gsl_sf_lnfact_e((unsigned int) n, &ln_nf);
int stat_e = gsl_sf_exp_mult_err_e(ln_nf.val, ln_nf.err,
hzeta.val, hzeta.err,
result);
if(GSL_IS_EVEN(n)) result->val = -result->val;
return GSL_ERROR_SELECT_3(stat_e, stat_nf, stat_hz);
}
}
示例15: gsl_sf_lnsinh_e
int
gsl_sf_lnsinh_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(fabs(x) < 1.0) {
double eps;
sinh_series(x, &eps);
result->val = log(eps);
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else if(x < -0.5*GSL_LOG_DBL_EPSILON) {
result->val = x + log(0.5*(1.0 - exp(-2.0*x)));
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
result->val = -M_LN2 + x;
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
}