本文整理汇总了C++中SpProxy类的典型用法代码示例。如果您正苦于以下问题:C++ SpProxy类的具体用法?C++ SpProxy怎么用?C++ SpProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arma_extra_debug_sigprint
inline
void
op_sp_plus::apply_inside_schur(SpMat<eT>& out, const T2& x, const SpToDOp<T3, op_sp_plus>& y)
{
arma_extra_debug_sigprint();
const SpProxy<T2> proxy2(x);
const SpProxy<T3> proxy3(y.m);
arma_debug_assert_same_size(proxy2.get_n_rows(), proxy2.get_n_cols(), proxy3.get_n_rows(), proxy3.get_n_cols(), "element-wise multiplication");
out.zeros(proxy2.get_n_rows(), proxy2.get_n_cols());
typename SpProxy<T2>::const_iterator_type it = proxy2.begin();
typename SpProxy<T2>::const_iterator_type it_end = proxy2.end();
const eT k = y.aux;
for(; it != it_end; ++it)
{
const uword it_row = it.row();
const uword it_col = it.col();
out.at(it_row, it_col) = (*it) * (proxy3.at(it_row, it_col) + k);
}
}
示例2: arma_extra_debug_sigprint
arma_hot
inline
void
spglue_plus::apply(SpMat<typename T1::elem_type>& out, const SpGlue<T1,T2,spglue_plus>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const SpProxy<T1> pa(X.A);
const SpProxy<T2> pb(X.B);
const bool is_alias = pa.is_alias(out) || pb.is_alias(out);
if(is_alias == false)
{
spglue_plus::apply_noalias(out, pa, pb);
}
else
{
SpMat<eT> tmp;
spglue_plus::apply_noalias(tmp, pa, pb);
out.steal_mem(tmp);
}
}
示例3: arma_extra_debug_sigprint
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;
}
示例4: arma_extra_debug_sigprint
inline
void
spop_mean::apply(SpMat<typename T1::elem_type>& out, const SpOp<T1, spop_mean>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a;
arma_debug_check( (dim > 1), "mean(): parameter 'dim' must be 0 or 1" );
const SpProxy<T1> p(in.m);
if(p.is_alias(out) == false)
{
spop_mean::apply_noalias_fast(out, p, dim);
}
else
{
SpMat<eT> tmp;
spop_mean::apply_noalias_fast(tmp, p, dim);
out.steal_mem(tmp);
}
}
示例5: arma_extra_debug_sigprint
inline
void
spop_var::apply(SpMat<typename T1::pod_type>& out, const mtSpOp<typename T1::pod_type, T1, spop_var>& in)
{
arma_extra_debug_sigprint();
//typedef typename T1::elem_type in_eT;
typedef typename T1::pod_type out_eT;
const uword norm_type = in.aux_uword_a;
const uword dim = in.aux_uword_b;
arma_debug_check( (norm_type > 1), "var(): parameter 'norm_type' must be 0 or 1" );
arma_debug_check( (dim > 1), "var(): parameter 'dim' must be 0 or 1" );
const SpProxy<T1> p(in.m);
if(p.is_alias(out) == false)
{
spop_var::apply_noalias(out, p, norm_type, dim);
}
else
{
SpMat<out_eT> tmp;
spop_var::apply_noalias(tmp, p, norm_type, dim);
out.steal_mem(tmp);
}
}
示例6: find
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;
}
示例7: arma_extra_debug_sigprint
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; }
}
}
}
示例8: is_finite
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: arma_extra_debug_sigprint
inline
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),
Mat<typename T1::elem_type>
>::result
operator-
(
const T1& x,
const T2& y
)
{
arma_extra_debug_sigprint();
Mat<typename T1::elem_type> result(x);
const SpProxy<T2> pb(y.get_ref());
arma_debug_assert_same_size( result.n_rows, result.n_cols, pb.get_n_rows(), pb.get_n_cols(), "subtraction" );
typename SpProxy<T2>::const_iterator_type it = pb.begin();
typename SpProxy<T2>::const_iterator_type it_end = pb.end();
while(it != it_end)
{
result.at(it.row(), it.col()) -= (*it);
++it;
}
return result;
}
示例10: arma_extra_debug_sigprint
arma_hot
inline
uword
n_unique
(
const SpProxy<T1>& pa,
const SpProxy<T2>& pb,
const op_n_unique_type junk
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
typename SpProxy<T1>::const_iterator_type x_it = pa.begin();
typename SpProxy<T1>::const_iterator_type x_it_end = pa.end();
typename SpProxy<T2>::const_iterator_type y_it = pb.begin();
typename SpProxy<T2>::const_iterator_type y_it_end = pb.end();
uword total_n_nonzero = 0;
while( (x_it != x_it_end) || (y_it != y_it_end) )
{
if(x_it == y_it)
{
if(op_n_unique_type::eval((*x_it), (*y_it)) != typename T1::elem_type(0))
{
++total_n_nonzero;
}
++x_it;
++y_it;
}
else
{
if((x_it.col() < y_it.col()) || ((x_it.col() == y_it.col()) && (x_it.row() < y_it.row()))) // if y is closer to the end
{
if(op_n_unique_type::eval((*x_it), typename T1::elem_type(0)) != typename T1::elem_type(0))
{
++total_n_nonzero;
}
++x_it;
}
else // x is closer to the end
{
if(op_n_unique_type::eval(typename T1::elem_type(0), (*y_it)) != typename T1::elem_type(0))
{
++total_n_nonzero;
}
++y_it;
}
}
}
return total_n_nonzero;
}
示例11: size
arma_warn_unused
inline
uword
size(const SpBase<typename T1::elem_type,T1>& X, const uword dim)
{
arma_extra_debug_sigprint();
const SpProxy<T1> P(X.get_ref());
return SizeMat( P.get_n_rows(), P.get_n_cols() )( dim );
}
示例12: arma_extra_debug_sigprint
inline
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),
Mat<typename T1::elem_type>
>::result
operator/
(
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(), "element-wise division");
Mat<typename T1::elem_type> result(pa.get_n_rows(), pa.get_n_cols());
result.fill(Datum<typename T1::elem_type>::inf);
// Now divide each element
typename SpProxy<T2>::const_iterator_type it = pb.begin();
while(it.pos() < pb.get_n_nonzero())
{
if(Proxy<T1>::prefer_at_accessor == false)
{
const uword index = (it.col() * result.n_rows) + it.row();
result[index] = pa[index] / (*it);
}
else
{
result.at(it.row(), it.col()) = pa.at(it.row(), it.col()) / (*it);
}
++it;
}
return result;
}
示例13: arma_extra_debug_sigprint
inline
void
spop_scalar_times::apply(SpMat<typename T1::elem_type>& out, const SpOp<T1,spop_scalar_times>& in)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
if(in.aux != eT(0))
{
out.init_xform(in.m, priv::functor_scalar_times<eT>(in.aux));
}
else
{
const SpProxy<T1> P(in.m);
out.zeros( P.get_n_rows(), P.get_n_cols() );
}
}
示例14: find_nonfinite
arma_warn_unused
inline
Col<uword>
find_nonfinite(const SpBase<typename T1::elem_type,T1>& X)
{
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();
uword count = 0;
for(uword i=0; i<n_nz; ++i)
{
if(arma_isfinite(*it) == false)
{
const uword index = it.row() + it.col()*n_rows;
tmp_mem[count] = index;
++count;
}
++it;
}
Col<uword> out;
if(count > 0) { out.steal_mem_col(tmp, count); }
return out;
}
示例15: dot_helper
arma_hot
inline
typename T1::elem_type
dot_helper(const SpProxy<T1>& pa, const SpProxy<T2>& pb)
{
typedef typename T1::elem_type eT;
// 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<T1>::const_iterator_type a_end = pa.end();
typename SpProxy<T2>::const_iterator_type b_it = pb.begin();
typename SpProxy<T2>::const_iterator_type b_end = pb.end();
while((a_it != a_end) && (b_it != b_end))
{
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;
}