• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Vec_I_DP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Vec_I_DP的典型用法代码示例。如果您正苦于以下问题:C++ Vec_I_DP类的具体用法?C++ Vec_I_DP怎么用?C++ Vec_I_DP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Vec_I_DP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pearsn

void NR::pearsn(Vec_I_DP &x, Vec_I_DP &y, DP &r, DP &prob, DP &z)
{
    const DP TINY=1.0e-20;
    int j;
    DP yt,xt,t,df;
    DP syy=0.0,sxy=0.0,sxx=0.0,ay=0.0,ax=0.0;

    int n=x.size();
    for (j=0; j<n; j++) {
        ax += x[j];
        ay += y[j];
    }
    ax /= n;
    ay /= n;
    for (j=0; j<n; j++) {
        xt=x[j]-ax;
        yt=y[j]-ay;
        sxx += xt*xt;
        syy += yt*yt;
        sxy += xt*yt;
    }
    r=sxy/(sqrt(sxx*syy)+TINY);
    z=0.5*log((1.0+r+TINY)/(1.0-r+TINY));
    df=n-2;
    t=r*sqrt(df/((1.0-r+TINY)*(1.0+r+TINY)));
    prob=betai(0.5*df,0.5,df/(df+t*t));
    // prob=erfcc(fabs(z*sqrt(n-1.0))/1.4142136);
}
开发者ID:hushell,项目名称:kod,代码行数:28,代码来源:pearsn.cpp


示例2: qroot

void NR::qroot(Vec_I_DP &p, DP &b, DP &c, const DP eps)
{
	const int ITMAX=20;
	const DP TINY=1.0e-14;
	int iter;
	DP sc,sb,s,rc,rb,r,dv,delc,delb;
	Vec_DP d(3);

	int n=p.size()-1;
	Vec_DP q(n+1),qq(n+1),rem(n+1);
	d[2]=1.0;
	for (iter=0;iter<ITMAX;iter++) {
		d[1]=b;
		d[0]=c;
		poldiv(p,d,q,rem);
		s=rem[0];
		r=rem[1];
		poldiv(q,d,qq,rem);
		sb = -c*(rc = -rem[1]);
		rb = -b*rc+(sc = -rem[0]);
		dv=1.0/(sb*rc-sc*rb);
		delb=(r*sc-s*rc)*dv;
		delc=(-r*sb+s*rb)*dv;
		b += (delb=(r*sc-s*rc)*dv);
		c += (delc=(-r*sb+s*rb)*dv);
		if ((fabs(delb) <= eps*fabs(b) || fabs(b) < TINY)
			&& (fabs(delc) <= eps*fabs(c) || fabs(c) < TINY)) {
			return;
		}
	}
	nrerror("Too many iterations in routine qroot");
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:32,代码来源:qroot.cpp


示例3: polint

void NR::polint(Vec_I_DP &xa, Vec_I_DP &ya, const DP x, DP &y, DP &dy)
{
	int i,m,ns=0;
	DP den,dif,dift,ho,hp,w;

	int n=xa.size();
	Vec_DP c(n),d(n);
	dif=fabs(x-xa[0]);
	for (i=0;i<n;i++) {
		if ((dift=fabs(x-xa[i])) < dif) {
			ns=i;
			dif=dift;
		}
		c[i]=ya[i];
		d[i]=ya[i];
	}
	y=ya[ns--];
	for (m=1;m<n;m++) {
		for (i=0;i<n-m;i++) {
			ho=xa[i]-x;
			hp=xa[i+m]-x;
			w=c[i+1]-d[i];
			if ((den=ho-hp) == 0.0) nrerror("Error in routine polint");
			den=w/den;
			d[i]=hp*den;
			c[i]=ho*den;
		}
		y += (dy=(2*(ns+1) < (n-m) ? c[ns+1] : d[ns--]));
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:30,代码来源:polint.cpp


示例4: asolve

void NR::asolve(Vec_I_DP &b, Vec_O_DP &x, const int itrnsp)
{
	int i;

	int n=b.size();
	for(i=0;i<n;i++) x[i]=((*sa_p)[i] != 0.0 ? b[i]/(*sa_p)[i] : b[i]);
}
开发者ID:HunterAllman,项目名称:kod,代码行数:7,代码来源:asolve.cpp


示例5: svdfit

void NR::svdfit(Vec_I_DP &x, Vec_I_DP &y, Vec_I_DP &sig, Vec_O_DP &a,
	Mat_O_DP &u, Mat_O_DP &v, Vec_O_DP &w, DP &chisq,
	void funcs(const DP, Vec_O_DP &))
{
	int i,j;
	const DP TOL=1.0e-13;
	DP wmax,tmp,thresh,sum;

	int ndata=x.size();
	int ma=a.size();
	Vec_DP b(ndata),afunc(ma);
	for (i=0;i<ndata;i++) {
		funcs(x[i],afunc);
		tmp=1.0/sig[i];
		for (j=0;j<ma;j++) u[i][j]=afunc[j]*tmp;
		b[i]=y[i]*tmp;
	}
	svdcmp(u,w,v);
	wmax=0.0;
	for (j=0;j<ma;j++)
		if (w[j] > wmax) wmax=w[j];
	thresh=TOL*wmax;
	for (j=0;j<ma;j++)
		if (w[j] < thresh) w[j]=0.0;
	svbksb(u,w,v,b,a);
	chisq=0.0;
	for (i=0;i<ndata;i++) {
		funcs(x[i],afunc);
		sum=0.0;
		for (j=0;j<ma;j++) sum += a[j]*afunc[j];
		chisq += (tmp=(y[i]-sum)/sig[i],tmp*tmp);
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:33,代码来源:svdfit.cpp


示例6: vander

void NR::vander(Vec_I_DP &x, Vec_O_DP &w, Vec_I_DP &q)
{
	int i,j,k;
	DP b,s,t,xx;

	int n=q.size();
	Vec_DP c(n);
	if (n == 1) w[0]=q[0];
	else {
		for (i=0;i<n;i++) c[i]=0.0;
		c[n-1] = -x[0];
		for (i=1;i<n;i++) {
			xx = -x[i];
			for (j=(n-1-i);j<(n-1);j++) c[j] += xx*c[j+1];
			c[n-1] += xx;
		}
		for (i=0;i<n;i++) {
			xx=x[i];
			t=b=1.0;
			s=q[n-1];
			for (k=n-1;k>0;k--) {
				b=c[k]+xx*b;
				s += q[k-1]*b;
				t=xx*t+b;
			}
			w[i]=s/t;
		}
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:29,代码来源:vander.cpp


示例7: predic

void NR::predic(Vec_I_DP &data, Vec_I_DP &d, Vec_O_DP &future)
{
	int k,j;
	DP sum,discrp;

	int ndata=data.size();
	int m=d.size();
	int nfut=future.size();
	Vec_DP reg(m);
	for (j=0;j<m;j++) reg[j]=data[ndata-1-j];
	for (j=0;j<nfut;j++) {
		discrp=0.0;
		sum=discrp;
		for (k=0;k<m;k++) sum += d[k]*reg[k];
		for (k=m-1;k>=1;k--) reg[k]=reg[k-1];
		future[j]=reg[0]=sum;
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:18,代码来源:predic.cpp


示例8: convlv

void NR::convlv(Vec_I_DP &data, Vec_I_DP &respns, const int isign,
	Vec_O_DP &ans)
{
	int i,no2;
	DP mag2,tmp;

	int n=data.size();
	int m=respns.size();
	Vec_DP temp(n);
	temp[0]=respns[0];
	for (i=1;i<(m+1)/2;i++) {
		temp[i]=respns[i];
		temp[n-i]=respns[m-i];
	}
	for (i=(m+1)/2;i<n-(m-1)/2;i++)
		temp[i]=0.0;
	for (i=0;i<n;i++)
		ans[i]=data[i];
	realft(ans,1);
	realft(temp,1);
	no2=n>>1;
	if (isign == 1) {
		for (i=2;i<n;i+=2) {
			tmp=ans[i];
			ans[i]=(ans[i]*temp[i]-ans[i+1]*temp[i+1])/no2;
			ans[i+1]=(ans[i+1]*temp[i]+tmp*temp[i+1])/no2;
		}
		ans[0]=ans[0]*temp[0]/no2;
		ans[1]=ans[1]*temp[1]/no2;
	} else if (isign == -1) {
		for (i=2;i<n;i+=2) {
			if ((mag2=SQR(temp[i])+SQR(temp[i+1])) == 0.0)
				nrerror("Deconvolving at response zero in convlv");
			tmp=ans[i];
			ans[i]=(ans[i]*temp[i]+ans[i+1]*temp[i+1])/mag2/no2;
			ans[i+1]=(ans[i+1]*temp[i]-tmp*temp[i+1])/mag2/no2;
		}
		if (temp[0] == 0.0 || temp[1] == 0.0)
			nrerror("Deconvolving at response zero in convlv");
		ans[0]=ans[0]/temp[0]/no2;
		ans[1]=ans[1]/temp[1]/no2;
	} else nrerror("No meaning for isign in convlv");
	realft(ans,-1);
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:44,代码来源:convlv.cpp


示例9: g

DP NR::fredin(const DP x, const DP a, const DP b, Vec_I_DP &t, Vec_I_DP &f,
	Vec_I_DP &w, DP g(const DP), DP ak(const DP, const DP))
{
	int i;
	DP sum=0.0;

	int n=t.size();
	for (i=0;i<n;i++) sum += ak(x,t[i])*w[i]*f[i];
	return g(x)+sum;
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:10,代码来源:fredin.cpp


示例10: ftest

void NR::ftest(Vec_I_DP &data1, Vec_I_DP &data2, DP &f, DP &prob)
{
	DP var1,var2,ave1,ave2,df1,df2;

	int n1=data1.size();
	int n2=data2.size();
	avevar(data1,ave1,var1);
	avevar(data2,ave2,var2);
	if (var1 > var2) {
		f=var1/var2;
		df1=n1-1;
		df2=n2-1;
	} else {
		f=var2/var1;
		df1=n2-1;
		df2=n1-1;
	}
	prob = 2.0*betai(0.5*df2,0.5*df1,df2/(df2+df1*f));
	if (prob > 1.0) prob=2.0-prob;
}
开发者ID:HunterAllman,项目名称:kod,代码行数:20,代码来源:ftest.cpp


示例11: simpr

void NR::simpr(Vec_I_DP &y, Vec_I_DP &dydx, Vec_I_DP &dfdx, Mat_I_DP &dfdy,
	const DP xs, const DP htot, const int nstep, Vec_O_DP &yout,
	void derivs(const DP, Vec_IO_DP &, Vec_O_DP &))
{
        const int NMAX=61000;
        Vec_INT ija(NMAX);
        Vec_DP sa(NMAX);
	double sa_a[NMAX];
	int ija_a[NMAX];
	int i,nn,RAZMER;
	DP d,h,x;
        const int ITOL=2,ITMAX=75;
        const DP TOL=1.0e-9;
        int ii,iter;
        DP err;

	int n=y.size();
	Vec_INT indx(n);
	Vec_DP del(n),ytemp(n),xinit(n);
	h=htot/nstep;
        NR::sprsin(dfdy,1.e-9,sa,ija);
		RAZMER = (ija[n]-1);
		for(i=0;i<RAZMER;i++) {ija_a[i]=ija[i]; sa_a[i] = -h*sa[i];}
		for (i=0;i<n;i++) ++sa_a[i];// a[i][j] = -h*dfdy[i][j];

//	ludcmp(a,indx,d);
	for (i=0;i<n;i++){ xinit[i] = 0.;
		yout[i]=h*(dydx[i]+h*dfdx[i]);}
	ija_p=new Vec_INT(ija_a,NMAX);
        sa_p=new Vec_DP(sa_a,NMAX);
	NR::linbcg(yout,xinit,ITOL,TOL,ITMAX,iter,err);
//	lubksb(a,indx,yout);
	for (i=0;i<n;i++)
		ytemp[i]=y[i]+(del[i]=yout[i]=xinit[i]);
	x=xs+h;
	derivs(x,ytemp,yout);
	for (nn=2;nn<=nstep;nn++) {
		for (i=0;i<n;i++)
			yout[i]=h*yout[i]-del[i];
	NR::linbcg(yout,xinit,ITOL,TOL,ITMAX,iter,err);
//		lubksb(a,indx,yout);
		for (i=0;i<n;i++) ytemp[i] += (del[i] += 2.0*(yout[i]=xinit[i]));
		x += h;
		derivs(x,ytemp,yout);
	}
	for (i=0;i<n;i++)
		yout[i]=h*yout[i]-del[i];
	NR::linbcg(yout,xinit,ITOL,TOL,ITMAX,iter,err);
//	lubksb(a,indx,yout);
	for (i=0;i<n;i++)
		yout[i] = xinit[i] + ytemp[i];
        delete sa_p;
        delete ija_p;
}
开发者ID:seliv55,项目名称:isodyn,代码行数:54,代码来源:simprsparse.cpp


示例12: hunt

void NR::hunt(Vec_I_DP &xx, const DP x, int &jlo)
{
	int jm,jhi,inc;
	bool ascnd;

	int n=xx.size();
	ascnd=(xx[n-1] >= xx[0]);
	if (jlo < 0 || jlo > n-1) {
		jlo=-1;
		jhi=n;
	} else {
		inc=1;
		if (x >= xx[jlo] == ascnd) {
			if (jlo == n-1) return;
			jhi=jlo+1;
			while (x >= xx[jhi] == ascnd) {
				jlo=jhi;
				inc += inc;
				jhi=jlo+inc;
				if (jhi > n-1) {
					jhi=n;
					break;
				}
			}
		} else {
			if (jlo == 0) {
				jlo=-1;
				return;
			}
			jhi=jlo--;
			while (x < xx[jlo] == ascnd) {
				jhi=jlo;
				inc <<= 1;
				if (inc >= jhi) {
					jlo=-1;
					break;
				}
				else jlo=jhi-inc;
			}
		}
	}
	while (jhi-jlo != 1) {
		jm=(jhi+jlo) >> 1;
		if (x >= xx[jm] == ascnd)
			jlo=jm;
		else
			jhi=jm;
	}
	if (x == xx[n-1]) jlo=n-2;
	if (x == xx[0]) jlo=0;
}
开发者ID:HunterAllman,项目名称:kod,代码行数:51,代码来源:hunt.cpp


示例13: sprsax

void NR::sprsax(Vec_I_DP &sa, Vec_I_INT &ija, Vec_I_DP &x, Vec_O_DP &b)
{
	int i,k;

	int n=x.size();
	if (ija[0] != n+1)
		nrerror("sprsax: mismatched vector and matrix");
	for (i=0;i<n;i++) {
		b[i]=sa[i]*x[i];
		for (k=ija[i];k<ija[i+1];k++) {
			b[i] += sa[k]*x[ija[k]];
		}
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:14,代码来源:sprsax.cpp


示例14: jacobn_s

void NR::jacobn_s(const DP x, Vec_I_DP &y, Vec_O_DP &dfdx, Mat_O_DP &dfdy)
{
	int i;

	int n=y.size();
	for (i=0;i<n;i++) dfdx[i]=0.0;
	dfdy[0][0] = -0.013-1000.0*y[2];
	dfdy[0][1] = 0.0;
	dfdy[0][2] = -1000.0*y[0];
	dfdy[1][0] = 0.0;
	dfdy[1][1] = -2500.0*y[2];
	dfdy[1][2] = -2500.0*y[1];
	dfdy[2][0] = -0.013-1000.0*y[2];
	dfdy[2][1] = -2500.0*y[2];
	dfdy[2][2] = -1000.0*y[0]-2500.0*y[1];
}
开发者ID:HunterAllman,项目名称:kod,代码行数:16,代码来源:jacobn.cpp


示例15: fgauss

void NR::fgauss(const DP x, Vec_I_DP &a, DP &y, Vec_O_DP &dyda)
{
	int i;
	DP fac,ex,arg;

	int na=a.size();
	y=0.0;
	for (i=0;i<na-1;i+=3) {
		arg=(x-a[i+1])/a[i+2];
		ex=exp(-arg*arg);
		fac=a[i]*ex*2.0*arg;
		y += a[i]*ex;
		dyda[i]=ex;
		dyda[i+1]=fac/a[i+2];
		dyda[i+2]=fac*arg/a[i+2];
	}
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:17,代码来源:fgauss.cpp


示例16: avevar

void NR::avevar(Vec_I_DP &data, DP &ave, DP &var)
{
	DP s,ep;
	int j;

	int n=data.size();
	ave=0.0;
	for (j=0;j<n;j++) ave += data[j];
	ave /= n;
	var=ep=0.0;
	for (j=0;j<n;j++) {
		s=data[j]-ave;
		ep += s;
		var += s*s;
	}
	var=(var-ep*ep/n)/(n-1);
}
开发者ID:HunterAllman,项目名称:kod,代码行数:17,代码来源:avevar.cpp


示例17: tridag

void NR::tridag(Vec_I_DP &a, Vec_I_DP &b, Vec_I_DP &c, Vec_I_DP &r, Vec_O_DP &u)
{
    int j;
    DP bet;

    int n=a.size();
    Vec_DP gam(n);
    if (b[0] == 0.0) nrerror("Error 1 in tridag");
    u[0]=r[0]/(bet=b[0]);
    for (j=1; j<n; j++) {
        gam[j]=c[j-1]/bet;
        bet=b[j]-a[j]*gam[j];
        if (bet == 0.0) nrerror("Error 2 in tridag");
        u[j]=(r[j]-a[j]*u[j-1])/bet;
    }
    for (j=(n-2); j>=0; j--)
        u[j] -= gam[j+1]*u[j+1];
}
开发者ID:hildingur,项目名称:filtering,代码行数:18,代码来源:tridag.cpp


示例18: snrm

DP NR::snrm(Vec_I_DP &sx, const int itol)
{
	int i,isamax;
	DP ans;

	int n=sx.size();
	if (itol <= 3) {
		ans = 0.0;
		for (i=0;i<n;i++) ans += sx[i]*sx[i];
		return sqrt(ans);
	} else {
		isamax=0;
		for (i=0;i<n;i++) {
			if (fabs(sx[i]) > fabs(sx[isamax])) isamax=i;
		}
		return fabs(sx[isamax]);
	}
}
开发者ID:HunterAllman,项目名称:kod,代码行数:18,代码来源:snrm.cpp


示例19: chstwo

void NR::chstwo(Vec_I_DP &bins1, Vec_I_DP &bins2, const int knstrn, DP &df,
	DP &chsq, DP &prob)
{
	int j;
	DP temp;

	int nbins=bins1.size();
	df=nbins-knstrn;
	chsq=0.0;
	for (j=0;j<nbins;j++)
		if (bins1[j] == 0.0 && bins2[j] == 0.0)
			--df;
		else {
			temp=bins1[j]-bins2[j];
			chsq += temp*temp/(bins1[j]+bins2[j]);
		}
	prob=gammq(0.5*df,0.5*chsq);
}
开发者ID:1040003585,项目名称:LearnedCandCPP,代码行数:18,代码来源:chstwo.cpp


示例20: shootf

void NR::shootf(Vec_I_DP &v, Vec_O_DP &f)
{
	const DP EPS=1.0e-14;
	int i,nbad,nok;
	DP h1,hmin=0.0;

	int nvar=v.size();
	Vec_DP f1(nvar),f2(nvar),y(nvar);
	Vec_DP v2(&v[n2],nvar-n2);
	kmax=0;
	h1=(x2-x1)/100.0;
	load1(x1,v,y);
	odeint(y,x1,xf,EPS,h1,hmin,nok,nbad,derivs,rkqs);
	score(xf,y,f1);
	load2(x2,v2,y);
	odeint(y,x2,xf,EPS,h1,hmin,nok,nbad,derivs,rkqs);
	score(xf,y,f2);
	for (i=0;i<nvar;i++) f[i]=f1[i]-f2[i];
}
开发者ID:HunterAllman,项目名称:kod,代码行数:19,代码来源:shootf.cpp



注:本文中的Vec_I_DP类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Vect类代码示例发布时间:2022-05-31
下一篇:
C++ Vec_IO_DP类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap