本文整理汇总了C++中typenameSpMat::col方法的典型用法代码示例。如果您正苦于以下问题:C++ typenameSpMat::col方法的具体用法?C++ typenameSpMat::col怎么用?C++ typenameSpMat::col使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenameSpMat
的用法示例。
在下文中一共展示了typenameSpMat::col方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locs
arma_hot
inline
void
spop_strans::apply_spmat(SpMat<eT>& out, const SpMat<eT>& X)
{
arma_extra_debug_sigprint();
typedef typename umat::elem_type ueT;
const uword N = X.n_nonzero;
if(N == uword(0))
{
out.zeros(X.n_cols, X.n_rows);
return;
}
umat locs(2, N);
typename SpMat<eT>::const_iterator it = X.begin();
for(uword count = 0; count < N; ++count)
{
ueT* locs_ptr = locs.colptr(count);
locs_ptr[0] = it.col();
locs_ptr[1] = it.row();
++it;
}
const Col<eT> vals(const_cast<eT*>(X.values), N, false);
SpMat<eT> tmp(locs, vals, X.n_cols, X.n_rows);
out.steal_mem(tmp);
}
示例2: return
inline
bool
SpSubview<eT>::const_row_iterator::operator!=(const typename SpMat<eT>::const_row_iterator& rhs) const
{
return (rhs.row() != row()) || (rhs.col() != iterator_base::internal_col);
}
示例3: stream_state
inline
void
arma_ostream::print(std::ostream& o, const SpMat<eT>& m, const bool modify)
{
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
o.unsetf(ios::showbase);
o.unsetf(ios::uppercase);
o.unsetf(ios::showpos);
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(2);
const uword m_n_nonzero = m.n_nonzero;
o << "[matrix size: " << m.n_rows << 'x' << m.n_cols << "; n_nonzero: " << m_n_nonzero
<< "; density: " << ((m.n_elem > 0) ? (double(m_n_nonzero) / double(m.n_elem) * double(100)) : double(0))
<< "%]\n\n";
if(modify == false) { stream_state.restore(o); }
if(m_n_nonzero > 0)
{
const std::streamsize cell_width = modify ? modify_stream<eT>(o, m.begin(), m_n_nonzero) : o.width();
typename SpMat<eT>::const_iterator begin = m.begin();
while(begin != m.end())
{
const uword row = begin.row();
// TODO: change the maximum number of spaces before and after each location to be dependent on n_rows and n_cols
if(row < 10) { o << " "; }
else if(row < 100) { o << " "; }
else if(row < 1000) { o << " "; }
else if(row < 10000) { o << " "; }
else if(row < 100000) { o << ' '; }
const uword col = begin.col();
o << '(' << row << ", " << col << ") ";
if(col < 10) { o << " "; }
else if(col < 100) { o << " "; }
else if(col < 1000) { o << " "; }
else if(col < 10000) { o << " "; }
else if(col < 100000) { o << ' '; }
if(cell_width > 0) { o.width(cell_width); }
arma_ostream::print_elem(o, eT(*begin), modify);
o << '\n';
++begin;
}
o << '\n';
}
o.flush();
stream_state.restore(o);
}