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


C++ array::copy方法代码示例

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


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

示例1: pick

/**
* randomization - controls % of total number of pixels in the image
* that will be effected by random noise
* repeat - # of times the process is carried out on the previous steps output
*/
array pick(const array &in, int randomization, int repeat)
{
    int w = in.dims(0);
    int h = in.dims(1);
    float f = randomization / 100.0f;
    int dim = (int)(f*w*h);
    array ret_val = in.copy();
    for (int i = 0; i<repeat; ++i) {
        array idxs = (w*h)  * randu(dim);
        array rnd = getRandomNeighbor(ret_val, 1, 1);
        array temp_src = moddims(rnd, w*h, 3);
        array temp_dst = moddims(ret_val, w*h, 3);
        temp_dst(idxs, span) = temp_src(idxs, span);
        ret_val = moddims(temp_dst, in.dims());
    }
    return ret_val;
}
开发者ID:shehzan10,项目名称:arrayfire,代码行数:22,代码来源:filters.cpp

示例2: hurl

/**
* randomization - controls % of total number of pixels in the image
* that will be effected by random noise
* repeat - # of times the process is carried out on the previous steps output
*/
array hurl(const array &in, int randomization, int repeat)
{
    int w = in.dims(0);
    int h = in.dims(1);
    float f = randomization / 100.0f;
    int dim = (int)(f*w*h);
    array ret_val = in.copy();
    array temp = moddims(ret_val, w*h, 3);
    for (int i = 0; i<repeat; ++i) {
        array idxs = (w*h)  * randu(dim);
        array rndR = 255.0f * randu(dim);
        array rndG = 255.0f * randu(dim);
        array rndB = 255.0f * randu(dim);
        temp(idxs, 0) = rndR;
        temp(idxs, 1) = rndG;
        temp(idxs, 2) = rndB;
    }
    ret_val = moddims(temp, in.dims());
    return ret_val;
}
开发者ID:shehzan10,项目名称:arrayfire,代码行数:25,代码来源:filters.cpp

示例3: dims

    b.host(&hb[0]);
    c.host(&hc[0]);

    for (int i = 0; i < num; i++) {
        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
    }
}


TEST(Replace, 4D)
{
    dim4 dims(2, 3, 4, 2);
    array cond = af::randu(dims) > 0.5;
    array a = af::randu(dims);
    array b = a.copy();
    replace(b, !cond, a - a * 0.9);
    array c = a - a * cond * 0.9;

    int num = (int)dims.elements();
    std::vector<float> hb(num);
    std::vector<float> hc(num);

    b.host(&hb[0]);
    c.host(&hc[0]);

    for (int i = 0; i < num; i++) {
        ASSERT_EQ(hc[i], hb[i]) << "at " << i;
    }
}
开发者ID:FilipeMaia,项目名称:arrayfire,代码行数:29,代码来源:replace.cpp


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