本文整理汇总了C++中vector_t::data方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_t::data方法的具体用法?C++ vector_t::data怎么用?C++ vector_t::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_t
的用法示例。
在下文中一共展示了vector_t::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_sah
void build_sah(vector_t<PrimRef>& prims, isa::PrimInfo& pinfo)
{
size_t N = pinfo.size();
/* fast allocator that supports thread local operation */
FastAllocator allocator;
for (size_t i=0; i<2; i++)
{
std::cout << "iteration " << i << ": building BVH over " << N << " primitives, " << std::flush;
double t0 = getSeconds();
allocator.reset();
Node* root;
isa::BVHBuilderBinnedSAH::build<Node*>(
root,
/* thread local allocator for fast allocations */
[&] () -> FastAllocator::ThreadLocal* {
return allocator.threadLocal();
},
/* lambda function that creates BVH nodes */
[&](const isa::BVHBuilderBinnedSAH::BuildRecord& current, isa::BVHBuilderBinnedSAH::BuildRecord* children, const size_t N, FastAllocator::ThreadLocal* alloc) -> int
{
assert(N <= 2);
InnerNode* node = new (alloc->malloc(sizeof(InnerNode))) InnerNode;
for (size_t i=0; i<N; i++) {
node->bounds[i] = children[i].pinfo.geomBounds;
children[i].parent = (size_t*) &node->children[i];
}
*current.parent = (size_t) node;
return 0;
},
/* lambda function that creates BVH leaves */
[&](const isa::BVHBuilderBinnedSAH::BuildRecord& current, FastAllocator::ThreadLocal* alloc) -> int
{
assert(current.prims.size() == 1);
Node* node = new (alloc->malloc(sizeof(LeafNode))) LeafNode(prims[current.prims.begin()].ID(),prims[current.prims.begin()].bounds());
*current.parent = (size_t) node;
return 0;
},
/* progress monitor function */
[&] (size_t dn) {
// throw an exception here to cancel the build operation
},
prims.data(),pinfo,2,1024,1,1,1,1.0f,1.0f);
double t1 = getSeconds();
std::cout << 1000.0f*(t1-t0) << "ms, " << 1E-6*double(N)/(t1-t0) << " Mprims/s, sah = " << root->sah() << " [DONE]" << std::endl;
}
}
示例2: vgrad
scalar_t vgrad(const vector_t& x, vector_t* gx) const override
{
m_idata = map_tensor(x.data(), m_idata.dims());
m_op.output(m_idata, m_wdata, m_bdata, m_odata);
if (gx)
{
gx->resize(x.size());
auto idata = map_tensor(gx->data(), m_idata.dims());
m_op.ginput(idata, m_wdata, m_bdata, m_odata);
}
return m_odata.array().square().sum() / 2;
}
示例3: geqrf
// QR Factorization of a MxN General Matrix A.
// a (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R. The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.
// tau (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.
// info (OUT - int)
// 0 : function completed normally
// < 0 : The ith argument, where i = abs(return value) had an illegal value.
int geqrf (matrix_t& a, vector_t& tau)
{
int _m = int(a.size1());
int _n = int(a.size2());
int _lda = int(a.size1());
int _info;
// make_sure tau's size is greater than or equal to min(m,n)
if (int(tau.size()) < (_n<_m ? _n : _m) )
return -104;
int ldwork = _n*_n;
vector_t dwork(ldwork);
rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);
return _info;
}
示例4: ToEigenVec
vector_eig EigenUtil::ToEigenVec(const vector_t &mat) {
return vector_eig::Map(mat.data(), mat.size());
}