本文整理汇总了C++中SpBase::get_ref方法的典型用法代码示例。如果您正苦于以下问题:C++ SpBase::get_ref方法的具体用法?C++ SpBase::get_ref怎么用?C++ SpBase::get_ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpBase
的用法示例。
在下文中一共展示了SpBase::get_ref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: direct_dot_arma
inline
arma_warn_unused
typename
enable_if2
<(is_arma_sparse_type<T1>::value) && (is_arma_sparse_type<T2>::value) && (is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const SpBase<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "dot()");
typedef typename T1::elem_type eT;
if((&(x.get_ref()) == &(y.get_ref())) && (SpProxy<T1>::must_use_iterator == false))
{
// We can do it directly!
return op_dot::direct_dot_arma(pa.get_n_nonzero(), pa.get_values(), pa.get_values());
}
else
{
// Iterate over both objects and see when they are the same
eT result = eT(0);
typename SpProxy<T1>::const_iterator_type a_it = pa.begin();
typename SpProxy<T2>::const_iterator_type b_it = pb.begin();
while((a_it.pos() < pa.get_n_nonzero()) && (b_it.pos() < pb.get_n_nonzero()))
{
if(a_it == b_it)
{
result += (*a_it) * (*b_it);
++a_it;
++b_it;
}
else if((a_it.col() < b_it.col()) || ((a_it.col() == b_it.col()) && (a_it.row() < b_it.row())))
{
// a_it is "behind"
++a_it;
}
else
{
// b_it is "behind"
++b_it;
}
}
return result;
}
}
示例2:
inline
const SpGlue<T1, T2, spglue_join_rows>
join_horiz(const SpBase<typename T1::elem_type,T1>& A, const SpBase<typename T1::elem_type,T2>& B)
{
arma_extra_debug_sigprint();
return SpGlue<T1, T2, spglue_join_rows>(A.get_ref(), B.get_ref());
}
示例3: p
inline
const SpSubview<eT>&
SpSubview<eT>::operator/=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
SpProxy<T1> p(x.get_ref());
arma_debug_assert_same_size(n_rows, n_cols, p.get_n_rows(), p.get_n_cols(), "element-wise division");
if(p.is_alias(m) == false)
{
for(uword lcol = 0; lcol < n_cols; ++lcol)
for(uword lrow = 0; lrow < n_rows; ++lrow)
{
at(lrow,lcol) /= p.at(lrow,lcol);
}
}
else
{
const SpMat<eT> tmp(p.Q);
(*this).operator/=(tmp);
}
return *this;
}
示例4: pa
inline
arma_warn_unused
typename
enable_if2
<(is_arma_type<T1>::value) && (is_arma_sparse_type<T2>::value) && (is_same_type<typename T1::elem_type, typename T2::elem_type>::value),
typename T1::elem_type
>::result
dot
(
const Base<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y
)
{
arma_extra_debug_sigprint();
const Proxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "dot()");
typedef typename T1::elem_type eT;
eT result = eT(0);
typename SpProxy<T2>::const_iterator_type it = pb.begin();
// prefer_at_accessor won't save us operations
while(it.pos() < pb.get_n_nonzero())
{
result += (*it) * pa.at(it.row(), it.col());
++it;
}
return result;
}
示例5: P
arma_warn_unused
inline
Col<uword>
find(const SpBase<typename T1::elem_type,T1>& X, const uword k = 0)
{
arma_extra_debug_sigprint();
const SpProxy<T1> P(X.get_ref());
const uword n_rows = P.get_n_rows();
const uword n_nz = P.get_n_nonzero();
Mat<uword> tmp(n_nz,1);
uword* tmp_mem = tmp.memptr();
typename SpProxy<T1>::const_iterator_type it = P.begin();
for(uword i=0; i<n_nz; ++i)
{
const uword index = it.row() + it.col()*n_rows;
tmp_mem[i] = index;
++it;
}
Col<uword> out;
const uword count = (k == 0) ? uword(n_nz) : uword( (std::min)(n_nz, k) );
out.steal_mem_col(tmp, count);
return out;
}
示例6: P
inline
void
op_nonzeros::apply_noalias(Mat<typename T1::elem_type>& out, const SpBase<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const SpProxy<T1> P(X.get_ref());
const uword N = P.get_n_nonzero();
out.set_size(N,1);
if(N > 0)
{
if(is_SpMat<typename SpProxy<T1>::stored_type>::value)
{
const unwrap_spmat<typename SpProxy<T1>::stored_type> U(P.Q);
arrayops::copy(out.memptr(), U.M.values, N);
}
else
{
eT* out_mem = out.memptr();
typename SpProxy<T1>::const_iterator_type it = P.begin();
for(uword i=0; i<N; ++i) { out_mem[i] = (*it); ++it; }
}
}
}
示例7: n_unique
inline
uword
n_unique
(
const SpBase<typename T1::elem_type, T1>& x,
const SpBase<typename T2::elem_type, T2>& y,
const op_n_unique_type junk
)
{
arma_extra_debug_sigprint();
const SpProxy<T1> pa(x.get_ref());
const SpProxy<T2> pb(y.get_ref());
return n_unique(pa,pb,junk);
}
示例8: P
inline
arma_warn_unused
bool
is_finite(const SpBase<typename T1::elem_type,T1>& X)
{
arma_extra_debug_sigprint();
const SpProxy<T1> P(X.get_ref());
if(is_SpMat<typename SpProxy<T1>::stored_type>::value)
{
const unwrap_spmat<typename SpProxy<T1>::stored_type> tmp(P.Q);
return tmp.M.is_finite();
}
else
{
typename SpProxy<T1>::const_iterator_type it = P.begin();
typename SpProxy<T1>::const_iterator_type it_end = P.end();
while(it != it_end)
{
if(arma_isfinite(*it) == false) { return false; }
++it;
}
}
return true;
}
示例9:
inline
Mat<typename T1::elem_type>
spsolve
(
const SpBase<typename T1::elem_type, T1>& A,
const Base<typename T1::elem_type, T2>& B,
const char* solver = "superlu",
const spsolve_opts_base& settings = spsolve_opts_none(),
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typedef typename T1::elem_type eT;
Mat<eT> out;
const bool status = spsolve_helper(out, A.get_ref(), B.get_ref(), solver, settings);
if(status == false)
{
arma_bad("spsolve(): solution not found");
}
return out;
}
示例10: return
inline
const SpSubview<eT>&
SpSubview<eT>::operator*=(const SpBase<eT, T1>& x)
{
arma_extra_debug_sigprint();
return (*this).operator=( (*this) * x.get_ref() );
}
示例11:
arma_inline
const SpOp<T1, spop_repmat>
repmat(const SpBase<typename T1::elem_type,T1>& A, const uword r, const uword c)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_repmat>(A.get_ref(), r, c);
}
示例12:
inline
const SpOp<T1, spop_reshape>
reshape(const SpBase<typename T1::elem_type, T1>& X, const SizeMat& s)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_reshape>(X.get_ref(), s.n_rows, s.n_cols);
}
示例13:
arma_inline
const SpOp<T1, spop_sqrt>
sqrt(const SpBase<typename T1::elem_type,T1>& A)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_sqrt>(A.get_ref());
}
示例14:
arma_warn_unused
arma_inline
typename enable_if2< is_cx<typename T1::elem_type>::yes, const SpOp<T1, spop_symmat_cx> >::result
symmatl(const SpBase<typename T1::elem_type,T1>& X, const bool do_conj = true)
{
arma_extra_debug_sigprint();
return SpOp<T1, spop_symmat_cx>(X.get_ref(), 1, (do_conj ? 1 : 0));
}
示例15:
inline
SpRow<eT>::SpRow(const SpBase<eT,T1>& X)
{
arma_extra_debug_sigprint();
access::rw(SpMat<eT>::vec_state) = 2;
SpMat<eT>::operator=(X.get_ref());
}