本文整理汇总了C++中carg函数的典型用法代码示例。如果您正苦于以下问题:C++ carg函数的具体用法?C++ carg怎么用?C++ carg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了carg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Bsmumu_untag
double Bsmumu_untag(double C0b[], double C1b[], double C2b[], double complex CQ0b[], double complex CQ1b[], double Cpb[], double complex CQpb[], struct parameters* param, double mu_b)
/* computes the inclusive untagged branching ratio of Bs -> mu+ mu- */
{
double alphas_mub=alphas_running(mu_b,param->mass_top_pole,param->mass_b_pole,param);
double C10=C0b[10]+alphas_mub/4./pi*C1b[10]+alphas_mub*alphas_mub/16./pi/pi*C2b[10];
double complex CQ1=CQ0b[1]+alphas_mub/4./pi*CQ1b[1];
double complex CQ2=CQ0b[2]+alphas_mub/4./pi*CQ1b[2];
double C10p=Cpb[10];
double complex CQp1=CQpb[1];
double complex CQp2=CQpb[2];
double complex S=sqrt(1.-4.*param->mass_mu*param->mass_mu/param->m_Bs/param->m_Bs)*param->m_Bs*param->m_Bs/2./param->mass_mu/(param->mass_b_pole+param->mass_s)*(CQ1-CQp1);
double complex P=(C10-C10p)+param->m_Bs*param->m_Bs/2./param->mass_mu/(param->mass_b_pole+param->mass_s)*(CQ2-CQp2);
double phiS=carg(S);
double phiP=carg(P);
double ys=0.088;
double A_Dgamma=(pow(cabs(P),2.)*cos(2.*phiP)-pow(cabs(S),2.)*cos(2.*phiS))/(pow(cabs(P),2.)+pow(cabs(S),2.));
return (1.+A_Dgamma*ys)/(1.-ys*ys)*Bsmumu(C0b,C1b,C2b,CQ0b,CQ1b,Cpb,CQpb,param,mu_b);
}
开发者ID:HEPcodes,项目名称:SuperIso,代码行数:27,代码来源:bsmumu.c
示例2: meanTimeOffset
// compute mean time offset.
// the instantaneous time offset is given by deltaPhi/(2*pi*f)
// this needs the initial dephasing at low frequencies to be small (i.e. 2*pi*deltaT < 0.1)
REAL8 meanTimeOffset(COMPLEX16FrequencySeries* hPlusTildeFD, COMPLEX16FrequencySeries* hCrossTildeFD, COMPLEX16* hPlusTildeTD, COMPLEX16* hCrossTildeTD, REAL8 Fplus, REAL8 Fcross, INT4 iStart, INT4 jStart, INT4 nSkip, INT4 nMax, REAL8 fMin, REAL8 deltaF)
{
INT4 i, j;
REAL8 out = 0.;
REAL8 dPhi = 0.;
REAL8 dPhiOld = 0.;
REAL8 omega;
COMPLEX16 htTD, htFD;
for(i = iStart, j = jStart; j < nMax; i += nSkip, j++)
{
omega = LAL_TWOPI*(fMin + j*deltaF);
htTD = Fplus*hPlusTildeTD[i] + Fcross*hCrossTildeTD[i];
htFD = Fplus*hPlusTildeFD->data->data[j] + Fcross*hCrossTildeFD->data->data[j];
dPhi = carg(htTD) - carg(htFD);
while(dPhi - dPhiOld > LAL_PI)
{
dPhi -= LAL_TWOPI;
}
while(dPhi - dPhiOld < -LAL_PI)
{
dPhi += LAL_TWOPI;
}
dPhiOld = dPhi;
out += dPhi/omega;
}
return out/(nMax-jStart);
}
开发者ID:SwethaPBhagwat,项目名称:lalsuite,代码行数:30,代码来源:TestTaylorTFourier.c
示例3: findroots
static void findroots(complex double a, complex double b, complex double c,
complex double e[])
{
int i;
complex double p = (b - a * a / 3.) / 3.;
complex double q = (2. * a * a * a / 27. - a * b / 3. + c) / 2.;
complex double D = creal(p * p * p + q * q); /* MODEL SPECIFIC!!! */
double eps;
assert(abs(cimag(p)) < 1e-10);
assert(abs(creal(q)) < 1e-10);
assert(abs(cimag(p * p * p + q * q)) < 1e-10);
complex double upr = -q + csqrt(D);
double mod_upr = pow(cabs(upr), 1. / 3.);
double arg_upr = carg(upr);
complex double umr = -q - csqrt(D);
double mod_umr = pow(cabs(umr), 1. / 3.);
double arg_umr = carg(umr);
complex double rp = .5 * (-1. + I * sqrt(3.));
complex double rm = .5 * (-1. - I * sqrt(3.));
complex double up = mod_upr * cexp(I * arg_upr / 3.);
for (eps = 1e-30; eps < 1e-6; eps *= 10.) {
complex double um[3];
double sort[3];
for (i = 0; i < 3; i++) {
um[i] = mod_umr * cexp(I*(2. * M_PI * i + arg_umr) / 3.);
sort[i] = cabs((um[i] * up + p) / p);
}
qsort(sort, 3, sizeof(*sort), cmp);
for (i = 0; i < 3; i++) {
double test = cabs((um[i] * up + p) / p);
if (test == sort[0] && test < eps) {
e[0] = up + um[i] - a / 3.;
e[1] = rp * up + rm * um[i] - a / 3.;
e[2] = rm * up + rp * um[i] - a / 3.;
return;
}
}
}
fprintf(stderr, "This should never happen!\n");
fprintf(stderr, "up=%lg%+lg*I p=%lg%+lg*I q=%lg%+lg*I D=%lg\n",
creal(up), cimag(up), creal(p), cimag(p),
creal(q), cimag(q), creal(D));
}
开发者ID:sabeiro,项目名称:Allink,代码行数:49,代码来源:imf2.c
示例4: collision_projectile
int collision_projectile(Projectile *p) {
if(p->type == FairyProj) {
float angle = carg(global.plr.pos - p->pos) + p->angle;
int projr = sqrt(pow(p->tex->w/4*cos(angle),2)*5/10.0 + pow(p->tex->h/2*sin(angle)*5/10.0,2));
if(cabs(global.plr.pos - p->pos) < projr + 1)
return 1;
} else if(p->type >= PlrProj) {
Enemy *e = global.enemies;
while(e != NULL) {
if(e->hp != ENEMY_IMMUNE && cabs(e->pos - p->pos) < 15) {
global.points += 100;
e->hp -= p->type - PlrProj;
return 2;
}
e = e->next;
}
if(global.boss && cabs(global.boss->pos - p->pos) < 15
&& global.boss->current->type != AT_Move && global.boss->current->type != AT_SurvivalSpell && global.boss->current->starttime < global.frames) {
global.boss->dmg += p->type - PlrProj;
return 2;
}
}
return 0;
}
开发者ID:miton,项目名称:taisei,代码行数:26,代码来源:projectile.c
示例5: draw_laser_beam
static void draw_laser_beam(complex src, complex dst, double size, double step, double t, Texture *tex, Uniform *u_length) {
complex dir = dst - src;
complex center = (src + dst) * 0.5;
r_mat_push();
r_mat_translate(creal(center), cimag(center), 0);
r_mat_rotate_deg(180/M_PI*carg(dir), 0, 0, 1);
r_mat_scale(cabs(dir), size, 1);
r_mat_mode(MM_TEXTURE);
r_mat_identity();
r_mat_translate(-cimag(src) / step + t, 0, 0);
r_mat_scale(cabs(dir) / step, 1, 1);
r_mat_mode(MM_MODELVIEW);
r_uniform_sampler("tex", tex);
r_uniform_float(u_length, cabs(dir) / step);
r_draw_quad();
r_mat_mode(MM_TEXTURE);
r_mat_identity();
r_mat_mode(MM_MODELVIEW);
r_mat_pop();
}
开发者ID:laochailan,项目名称:taisei,代码行数:26,代码来源:marisa_a.c
示例6: Complex_cargf
//## Complex Complex.cargf();
static KMETHOD Complex_cargf(KonohaContext *kctx, KonohaStack *sfp)
{
kComplex *kc = (kComplex *) sfp[0].asObject;
float _Complex zf = (float _Complex)kc->z;
float ret = carg(zf);
KReturnFloatValue(ret);
}
开发者ID:imasahiro,项目名称:konoha3,代码行数:8,代码来源:Complex_glue.c
示例7: Complex_cargl
//## Complex Complex.cargl();
static KMETHOD Complex_cargl(KonohaContext *kctx, KonohaStack *sfp)
{
kComplex *kc = (kComplex *) sfp[0].asObject;
long double _Complex zl = (long double _Complex)kc->z;
long double ret = carg(zl);
KReturnFloatValue(ret);
}
开发者ID:imasahiro,项目名称:konoha3,代码行数:8,代码来源:Complex_glue.c
示例8: cpow
double complex cpow (double complex X, double complex Y)
{
double complex Res;
double i;
double r = hypot (__real__ X, __imag__ X);
if (r == 0.0)
{
__real__ Res = __imag__ Res = 0.0;
}
else
{
double rho;
double theta;
i = carg (X);
theta = i * __real__ Y;
if (__imag__ Y == 0.0)
/* This gives slightly more accurate results in these cases. */
rho = pow (r, __real__ Y);
else
{
r = log (r);
/* rearrangement of cexp(X * clog(Y)) */
theta += r * __imag__ Y;
rho = exp (r * __real__ Y - i * __imag__ Y);
}
__real__ Res = rho * cos (theta);
__imag__ Res = rho * sin (theta);
}
return Res;
}
开发者ID:MiUishadow,项目名称:binutils,代码行数:32,代码来源:cpow.c
示例9: log_sweep
void log_sweep(
filter_fun filter, void *state,
double f_min, double f_max, int steps, double exp
)
{
printf(
"%20s%20s%20s%20s%20s\n",
"f", "re", "im", "abs", "phase"
);
double phase = 0;
for (int i=0; i<steps; i++) {
double f = f_min + pow((double)i/(steps-1), exp) * (f_max - f_min);
complex double z = measure(filter, state, f);
phase = unwrap(&phase, carg(z));
printf("%20g%20g%20g%20g%20g\n", f,
creal(z), cimag(z), cabs(z), phase * 360 / M_TWOPI
);
}
// data-set separator
//
printf("\n\n");
}
开发者ID:pl4nkton,项目名称:drquad32,代码行数:27,代码来源:filtertest.c
示例10: cfo_cp_estimate
static float cfo_cp_estimate(srslte_sync_t *q, const cf_t *input)
{
uint32_t cp_offset = 0;
cp_offset = srslte_cp_synch(&q->cp_synch, input, q->max_offset, q->cfo_cp_nsymbols, SRSLTE_CP_LEN_NORM(1,q->fft_size));
cf_t cp_corr_max = srslte_cp_synch_corr_output(&q->cp_synch, cp_offset);
float cfo = -carg(cp_corr_max) / M_PI / 2;
return cfo;
}
开发者ID:andrepuschmann,项目名称:srsLTE,代码行数:8,代码来源:sync.c
示例11: clog
double complex clog(double complex z)
{
double r, phi;
r = cabs(z);
phi = carg(z);
return CMPLX(log(r), phi);
}
开发者ID:4ian,项目名称:emscripten,代码行数:8,代码来源:clog.c
示例12: clog10
double complex
clog10 (double complex z)
{
double complex v;
COMPLEX_ASSIGN (v, log10 (cabs (z)), carg (z));
return v;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:8,代码来源:c99_functions.c
示例13: measure
/* do measurements: load density, ploop, etc. and phases onto lattice */
void measure() {
register int i,j,k, c, is_even;
register site *s;
int dx,dy,dz; /* separation for correlated observables */
int dir; /* direction of separation */
msg_tag *tag;
register complex cc,dd; /*scratch*/
complex ztr, zcof, znum, zdet, TC, zd, density, zphase;
complex p[4]; /* probabilities of n quarks at a site */
complex np[4]; /* probabilities at neighbor site */
complex pp[4][4]; /* joint probabilities of n here and m there */
complex zplp, plp_even, plp_odd;
Real locphase, phase;
/* First make T (= timelike P-loop) from s->ploop_t
T stored in s->tempmat1
*/
ploop_less_slice(nt-1,EVEN);
ploop_less_slice(nt-1,ODD);
phase = 0.;
density = plp_even = plp_odd = cmplx(0.0, 0.0);
for(j=0;j<4;j++){
p[j]=cmplx(0.0,0.0);
for(k=0;k<4;k++)pp[j][k]=cmplx(0.0,0.0);
}
FORALLSITES(i,s) {
if(s->t != nt-1) continue;
if( ((s->x+s->y+s->z)&0x1)==0 ) is_even=1; else is_even=0;
mult_su3_nn(&(s->link[TUP]), &(s->ploop_t), &(s->tempmat1));
zplp = trace_su3(&(s->tempmat1));
if( is_even){CSUM(plp_even, zplp)}
else {CSUM(plp_odd, zplp)}
ztr = trace_su3(&(s->tempmat1));
CONJG(ztr, zcof);
if(is_even){
for(c=0; c<3; ++c) s->tempmat1.e[c][c].real += C;
zdet = det_su3(&(s->tempmat1));
znum = numer(C, ztr, zcof);
CDIV(znum, zdet, zd);
CSUM(density, zd);
/* store n_quark probabilities at this site in lattice variable
qprob[], accumulate sum over lattice in p[] */
cc= cmplx(C*C*C,0.0); CDIV(cc,zdet,s->qprob[0]); CSUM(p[0],s->qprob[0]);
CMULREAL(ztr,C*C,cc); CDIV(cc,zdet,s->qprob[1]); CSUM(p[1],s->qprob[1]);
CMULREAL(zcof,C,cc); CDIV(cc,zdet,s->qprob[2]); CSUM(p[2],s->qprob[2]);
cc = cmplx(1.0,0.0); CDIV(cc,zdet,s->qprob[3]); CSUM(p[3],s->qprob[3]);
locphase = carg(&zdet);
phase += locphase;
}
}
开发者ID:erinaldi,项目名称:milc_qcd,代码行数:59,代码来源:density_half.c
示例14: test3
void test3(__complex__ double x, __complex__ double y, int i)
{
if (carg(x) != atan2(__imag__ x, __real__ x))
link_error ();
if (ccos(x) != ccos(-x))
link_error();
if (ccos(ctan(x)) != ccos(ctan(-x)))
link_error();
if (ctan(x-y) != -ctan(y-x))
link_error();
if (ccos(x/y) != ccos(-x/y))
link_error();
if (ccos(x/y) != ccos(x/-y))
link_error();
if (ccos(x/ctan(y)) != ccos(-x/ctan(-y)))
link_error();
if (ccos(x*y) != ccos(-x*y))
link_error();
if (ccos(x*y) != ccos(x*-y))
link_error();
if (ccos(ctan(x)*y) != ccos(ctan(-x)*-y))
link_error();
if (ccos(ctan(x/y)) != ccos(-ctan(x/-y)))
link_error();
if (ccos(i ? x : y) != ccos(i ? -x : y))
link_error();
if (ccos(i ? x : y) != ccos(i ? x : -y))
link_error();
if (ccos(i ? x : ctan(y/x)) != ccos(i ? -x : -ctan(-y/x)))
link_error();
if (~x != -~-x)
link_error();
if (ccos(~x) != ccos(-~-x))
link_error();
if (ctan(~(x-y)) != -ctan(~(y-x)))
link_error();
if (ctan(~(x/y)) != -ctan(~(x/-y)))
link_error();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:56,代码来源:builtins-20.c
示例15: main
int main(void)
{
double complex z;
z = 0.5 + I * (sqrt(3)/2);
fprintf(stdout, "Z : \n");
fprintf(stdout, " Partie reelle : %f\n", creal(z));
fprintf(stdout, " Partie imaginaire : %f\n", cimag(z));
fprintf(stdout, " Module : %f\n", cabs(z));
fprintf(stdout, " Argument : %f\n", carg(z));
z = conj(z);
fprintf(stdout, "\nConjugue de Z : \n");
fprintf(stdout, " Partie reelle : %f\n", creal(z));
fprintf(stdout, " Partie imaginaire : %f\n", cimag(z));
fprintf(stdout, " Module : %f\n", cabs(z));
fprintf(stdout, " Argument : %f\n", carg(z));
return EXIT_SUCCESS;
}
开发者ID:cpb-,项目名称:Developpement-systeme-sous-Linux,代码行数:20,代码来源:exemple-complexe.c
示例16: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
const char *format_data = "data RAW COMPLEX128 1\n";
double c[8];
#ifdef GD_NO_C99_API
double data_data[100][2];
#else
double complex data_data[100];
#endif
int i, n, error, r = 0;
DIRFILE *D;
rmdirfile();
mkdir(filedir, 0777);
for (i = 0; i < 100; ++i) {
#ifdef GD_NO_C99_API
const double v = i * 3.14159265358979323846 / 5.;
data_data[i][0] = cos(v);
data_data[i][1] = sin(v);
#else
data_data[i] = cexp(_Complex_I * i * 3.14159265358979323846 / 5.);
#endif
}
i = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
write(i, format_data, strlen(format_data));
close(i);
i = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666);
write(i, data_data, 200 * sizeof(double));
close(i);
D = gd_open(filedir, GD_RDONLY | GD_VERBOSE);
n = gd_getdata(D, "data.a", 5, 0, 8, 0, GD_FLOAT64, &c);
error = gd_error(D);
gd_close(D);
unlink(data);
unlink(format);
rmdir(filedir);
CHECKI(error,0);
CHECKI(n,8);
for (i = 0; i < 8; ++i)
CHECKFi(i,c[i],carg(data_data[5 + i]));
return r;
}
开发者ID:syntheticpp,项目名称:dirfile,代码行数:53,代码来源:repr_a.c
示例17: endvalues_edge
static void
endvalues_edge(double * va, double * vb, double * dir,
const cdouble * w, slong ia, slong ib, slong d)
{
slong k;
double a, b;
cdouble ba = w[ib] - w[ia];
*dir = carg(ba);
a = b = (d - 1) * (*dir);
for (k = 0; k < d; k++)
{
if (k == ia || k == ib)
continue;
a += carg((w[ia] - w[k]) / ba);
b += carg((w[ib] - w[k]) / ba);
}
*va = a;
*vb = b;
}
开发者ID:pascalmolin,项目名称:hcperiods,代码行数:21,代码来源:spanning_tree.c
示例18: do_test
static int
do_test (void)
{
check_return_ilogb ();
check_return_lrint ();
check_return_lround ();
check_return_llrint ();
check_return_llround ();
printf ("%Zd\n", sizeof(carg (lx)));
return errors != 0;
}
开发者ID:Xilinx,项目名称:eglibc,代码行数:13,代码来源:test-tgmath-ret.c
示例19: pitchadjust
// Perform pitch adjustment on the given block of complex numbers..
void pitchadjust(complex double* in, complex double* out)
{
// keep track of last rounds phases for each bin.
// These persist accross calls to this function.
static double inphases[N] = {0};
static double outphases[N] = {0};
bzero(out, sizeof(complex double) * N);
int i;
for (i = 0; i < N; i++) {
double phase = carg(in[i]);
double mag = cabs(in[i]);
double dphase = phase - inphases[i];
inphases[i] = phase;
// Perform the adjustment
// It's possible multiple different input bins could fall into the
// same output bin, in which case we just use the last of those input
// bins.
int bin = i * PITCH_FACTOR;
int nbin = (i+1) * PITCH_FACTOR;
if (nbin != bin && bin >= 0 && bin < N) {
double shifted = dphase * PITCH_FACTOR;
outphases[bin] += shifted;
out[bin] = cmplxmp(mag, outphases[bin]);
}
}
printf("IN:\n");
for (i = 0; i < N; i++) {
printf(" ti?[%d] = cmplxmp(%f, tophase(%f));\n", i, cabs(in[i]), carg(in[i]));
}
printf("OUT:\n");
for (i = 0; i < N; i++) {
printf(" to?[%d] = cmplxmp(%f, tophase(%f));\n", i, cabs(out[i]), carg(out[i]));
}
}
开发者ID:jeonggunlee,项目名称:6.375-labs,代码行数:39,代码来源:pitch.c
示例20: srslte_pss_cfo_compute
/* Returns the CFO estimation given a PSS received sequence
*
* Source: An Efficient CFO Estimation Algorithm for the Downlink of 3GPP-LTE
* Feng Wang and Yu Zhu
*/
float srslte_pss_cfo_compute(srslte_pss_t* q, const cf_t *pss_recv) {
cf_t y0, y1;
const cf_t *pss_ptr = pss_recv;
if (q->filter_pss_enable) {
srslte_pss_filter(q, pss_recv, q->tmp_fft);
pss_ptr = (const cf_t*) q->tmp_fft;
}
y0 = srslte_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], pss_ptr, q->fft_size/2);
y1 = srslte_vec_dot_prod_ccc(&q->pss_signal_time[q->N_id_2][q->fft_size/2], &pss_ptr[q->fft_size/2], q->fft_size/2);
return carg(conjf(y0) * y1)/M_PI;
}
开发者ID:srsLTE,项目名称:srsLTE,代码行数:19,代码来源:pss.c
注:本文中的carg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论