本文整理汇总了C++中SpProxy::end_row方法的典型用法代码示例。如果您正苦于以下问题:C++ SpProxy::end_row方法的具体用法?C++ SpProxy::end_row怎么用?C++ SpProxy::end_row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpProxy
的用法示例。
在下文中一共展示了SpProxy::end_row方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
inline
void
spop_var::apply_noalias
(
SpMat<typename T1::pod_type>& out_ref,
const SpProxy<T1>& p,
const uword norm_type,
const uword dim
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type in_eT;
//typedef typename T1::pod_type out_eT;
const uword p_n_rows = p.get_n_rows();
const uword p_n_cols = p.get_n_cols();
if(dim == 0)
{
arma_extra_debug_print("spop_var::apply(), dim = 0");
arma_debug_check((p_n_rows == 0), "var(): given object has zero rows");
out_ref.set_size(1, p_n_cols);
for(uword col = 0; col < p_n_cols; ++col)
{
if(SpProxy<T1>::must_use_iterator == true)
{
// We must use an iterator; we can't access memory directly.
typename SpProxy<T1>::const_iterator_type it = p.begin_col(col);
typename SpProxy<T1>::const_iterator_type end = p.begin_col(col + 1);
const uword n_zero = p.get_n_rows() - (end.pos() - it.pos());
// in_eT is used just to get the specialization right (complex / noncomplex)
out_ref.at(col) = spop_var::iterator_var(it, end, n_zero, norm_type, in_eT(0));
}
else
{
// We can use direct memory access to calculate the variance.
out_ref.at(col) = spop_var::direct_var
(
&p.get_values()[p.get_col_ptrs()[col]],
p.get_col_ptrs()[col + 1] - p.get_col_ptrs()[col],
p.get_n_rows(),
norm_type
);
}
}
}
else if(dim == 1)
{
arma_extra_debug_print("spop_var::apply_noalias(), dim = 1");
arma_debug_check((p_n_cols == 0), "var(): given object has zero columns");
out_ref.set_size(p_n_rows, 1);
for(uword row = 0; row < p_n_rows; ++row)
{
// We have to use an iterator here regardless of whether or not we can
// directly access memory.
typename SpProxy<T1>::const_row_iterator_type it = p.begin_row(row);
typename SpProxy<T1>::const_row_iterator_type end = p.end_row(row);
const uword n_zero = p.get_n_cols() - (end.pos() - it.pos());
out_ref.at(row) = spop_var::iterator_var(it, end, n_zero, norm_type, in_eT(0));
}
}
}
示例2: eT
inline
void
spop_mean::apply_noalias_slow
(
SpMat<typename T1::elem_type>& out,
const SpProxy<T1>& p,
const uword dim
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
const uword p_n_rows = p.get_n_rows();
const uword p_n_cols = p.get_n_cols();
if(dim == 0) // find the mean in each column
{
arma_extra_debug_print("spop_mean::apply_noalias(): dim = 0");
out.set_size((p_n_rows > 0) ? 1 : 0, p_n_cols);
if( (p_n_rows == 0) || (p.get_n_nonzero() == 0) ) { return; }
for(uword col = 0; col < p_n_cols; ++col)
{
// Do we have to use an iterator or can we use memory directly?
if(SpProxy<T1>::must_use_iterator)
{
typename SpProxy<T1>::const_iterator_type it = p.begin_col(col);
typename SpProxy<T1>::const_iterator_type end = p.begin_col(col + 1);
const uword n_zero = p_n_rows - (end.pos() - it.pos());
out.at(0,col) = spop_mean::iterator_mean(it, end, n_zero, eT(0));
}
else
{
out.at(0,col) = spop_mean::direct_mean
(
&p.get_values()[p.get_col_ptrs()[col]],
p.get_col_ptrs()[col + 1] - p.get_col_ptrs()[col],
p_n_rows
);
}
}
}
else
if(dim == 1) // find the mean in each row
{
arma_extra_debug_print("spop_mean::apply_noalias(): dim = 1");
out.set_size(p_n_rows, (p_n_cols > 0) ? 1 : 0);
if( (p_n_cols == 0) || (p.get_n_nonzero() == 0) ) { return; }
for(uword row = 0; row < p_n_rows; ++row)
{
// We must use an iterator regardless of how it is stored.
typename SpProxy<T1>::const_row_iterator_type it = p.begin_row(row);
typename SpProxy<T1>::const_row_iterator_type end = p.end_row(row);
const uword n_zero = p_n_cols - (end.pos() - it.pos());
out.at(row,0) = spop_mean::iterator_mean(it, end, n_zero, eT(0));
}
}
}
示例3:
inline
void
spop_var::apply_noalias
(
SpMat<typename T1::pod_type>& out,
const SpProxy<T1>& p,
const uword norm_type,
const uword dim
)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type in_eT;
//typedef typename T1::pod_type out_eT;
const uword p_n_rows = p.get_n_rows();
const uword p_n_cols = p.get_n_cols();
// TODO: this is slow; rewrite based on the approach used by sparse mean()
if(dim == 0) // find variance in each column
{
arma_extra_debug_print("spop_var::apply_noalias(): dim = 0");
out.set_size((p_n_rows > 0) ? 1 : 0, p_n_cols);
if( (p_n_rows == 0) || (p.get_n_nonzero() == 0) ) { return; }
for(uword col = 0; col < p_n_cols; ++col)
{
if(SpProxy<T1>::must_use_iterator)
{
// We must use an iterator; we can't access memory directly.
typename SpProxy<T1>::const_iterator_type it = p.begin_col(col);
typename SpProxy<T1>::const_iterator_type end = p.begin_col(col + 1);
const uword n_zero = p_n_rows - (end.pos() - it.pos());
// in_eT is used just to get the specialization right (complex / noncomplex)
out.at(0, col) = spop_var::iterator_var(it, end, n_zero, norm_type, in_eT(0));
}
else
{
// We can use direct memory access to calculate the variance.
out.at(0, col) = spop_var::direct_var
(
&p.get_values()[p.get_col_ptrs()[col]],
p.get_col_ptrs()[col + 1] - p.get_col_ptrs()[col],
p_n_rows,
norm_type
);
}
}
}
else
if(dim == 1) // find variance in each row
{
arma_extra_debug_print("spop_var::apply_noalias(): dim = 1");
out.set_size(p_n_rows, (p_n_cols > 0) ? 1 : 0);
if( (p_n_cols == 0) || (p.get_n_nonzero() == 0) ) { return; }
for(uword row = 0; row < p_n_rows; ++row)
{
// We have to use an iterator here regardless of whether or not we can
// directly access memory.
typename SpProxy<T1>::const_row_iterator_type it = p.begin_row(row);
typename SpProxy<T1>::const_row_iterator_type end = p.end_row(row);
const uword n_zero = p_n_cols - (end.pos() - it.pos());
out.at(row, 0) = spop_var::iterator_var(it, end, n_zero, norm_type, in_eT(0));
}
}
}