当前位置: 首页>>代码示例>>C++>>正文


C++ Array2D::value方法代码示例

本文整理汇总了C++中Array2D::value方法的典型用法代码示例。如果您正苦于以下问题:C++ Array2D::value方法的具体用法?C++ Array2D::value怎么用?C++ Array2D::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Array2D的用法示例。


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

示例1: operator

    T operator()(const Array2D<T>& src, const XYScale& tr, const typename XYScale::point& p) {
	int nx = p.ix();
	int ny = p.iy();
	double v = src.value(nx, ny);
	double a=0;

	if (nx==0||nx==src.nj-1) return (T)v;
	if (ny==0||ny==src.ni-1) return (T)v;

	if (nx<src.nj-1) {
	    double x0 = tr.ax.value(nx);
	    double x1 = tr.ax.value(nx+1);
	    a = (p.x()-x0)/(x1-x0);
	    v = (1-a)*v+a*src.value(nx+1,ny);
	}
	if (ny>=src.ni-1) return (T)v;
	double v2 = src.value(nx,ny+1);
	double y0 = tr.ay.value(ny);
	double y1 = tr.ay.value(ny+1);
	double b = (p.y()-y0)/(y1-y0);
	if (nx<src.nj-1) {
	    v2 = (1-a)*v2+a*src.value(nx+1,ny+1);
	}
	return (T)(v*(1-b)+b*v2);
    }
开发者ID:stonebig,项目名称:guiqwt-1,代码行数:25,代码来源:scaler.cpp

示例2: matrix_multiply

Array2D matrix_multiply(const Array2D &M1,const Array2D &M2) {
	if (M1.height()!=M2.width()) return Array2D();
	Array2D ret(M1.width(),M2.height());
	for (int j=0; j<ret.height(); j++)
	for (int i=0; i<ret.width(); i++) {
		double val=0;
		for (int k=0; k<M1.height(); k++) {
			val+=M1.value(i,k)*M2.value(k,j);
		}
		ret.setValue(val,i,j);
	}
	return ret;
}
开发者ID:magland,项目名称:saladsort,代码行数:13,代码来源:array2d.cpp

示例3: ssfeatures

int ssfeatures(FILE* infile, FILE* outfile, const QMap<QString, QVariant>& params)
{
    int nfeatures = params["nfeatures"].toInt();
    int niterations = params["niterations"].toInt();

    //get the input file header
    MDAIO_HEADER HH_infile;
    if (!mda_read_header(&HH_infile, infile))
        return 0;
    int32_t M = HH_infile.dims[0];
    int32_t T = HH_infile.dims[1];
    int32_t N = HH_infile.dims[2];
    if (M <= 0)
        return 0;
    if (T <= 0)
        return 0;
    if (N <= 0)
        return 0;

    Array2D X;
    X.allocate(M * T, N);
    float* inbuf = (float*)malloc(sizeof(float) * M * T);
    for (int i = 0; i < N; i++) {
        mda_read_float32(inbuf, &HH_infile, M * T, infile);
        for (int j = 0; j < M * T; j++) {
            X.setValue(inbuf[j], j, i);
        }
    }
    free(inbuf);

    PCASolver SS;
    SS.setVectors(X);
    SS.setNumIterations(niterations);
    SS.setComponentCount(nfeatures);
    SS.solve();
    Array2D features = SS.coefficients();

    //write the output header
    MDAIO_HEADER HH_outfile;
    mda_copy_header(&HH_outfile, &HH_infile);
    HH_outfile.num_dims = 2;
    HH_outfile.dims[0] = nfeatures;
    HH_outfile.dims[1] = N;
    HH_outfile.dims[2] = 1;
    HH_outfile.data_type = MDAIO_TYPE_FLOAT32;
    mda_write_header(&HH_outfile, outfile);

    float* outbuf = (float*)malloc(sizeof(float) * nfeatures);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < nfeatures; j++) {
            outbuf[j] = features.value(j, i);
        }
        mda_write_float32(outbuf, &HH_outfile, nfeatures, outfile);
    }
    free(outbuf);

    return 1;
}
开发者ID:magland,项目名称:mountainlab,代码行数:58,代码来源:ssfeatures.cpp

示例4: vert_line

static bool vert_line(double _x0, double _y0, double _x1, double _y1, int NX,
		      vector<int>& imin, vector<int>& imax,
		      bool draw, npy_uint32 col, Array2D<npy_uint32>& D)
{
    int x0 = lrint(_x0);
    int y0 = lrint(_y0);
    int x1 = lrint(_x1);
    int y1 = lrint(_y1);
    int dx = abs(x1-x0);
    int dy = abs(y1-y0);
    int sx, sy;
    int NY=imin.size()-1;
    int err, e2;
    bool visible=false;
    NX = NX-1;
    if (x0 < x1)
	sx = 1;
    else
	sx = -1;
    if (y0 < y1)
	sy = 1;
    else
	sy = -1;
    err = dx-dy;

    do {
	if (y0>=0 && y0<=NY) {
	    int _min = min(imin[y0],x0);
	    int _max = max(imax[y0],x0);
	    if (draw) {
		if (x0>=0 && x0<=NX) {
		    D.value(x0,y0) = col;
		}
	    }
	    imin[y0] = max( 0,_min);
	    imax[y0] = min(NX,_max);
	    if (_min<=NX && _max>=0) {
		visible=true;
	    }
	}
	if ((x0 == x1) && (y0 == y1))
	    break;
	e2 = 2*err;
	if (e2 > -dy) {
	    err = err - dy;
	    x0 = x0 + sx;
	}
	if (e2 <  dx) {
	    err = err + dx;
	    y0 = y0 + sy;
	}
    } while(true);
    return visible;
}
开发者ID:PierreRaybaut,项目名称:plotpy,代码行数:54,代码来源:pcolor.cpp

示例5:

void Array2D::add(const Array2D &X) {
	for (int y=0; y<height(); y++)
	for (int x=0; x<width(); x++) {
		setValue(value(x,y)+X.value(x,y),x,y);
	}
}
开发者ID:magland,项目名称:saladsort,代码行数:6,代码来源:array2d.cpp


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