本文整理汇总了C++中typenameSpMat类的典型用法代码示例。如果您正苦于以下问题:C++ typenameSpMat类的具体用法?C++ typenameSpMat怎么用?C++ typenameSpMat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了typenameSpMat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:EmanueleCannizzaro,项目名称:armadillo,代码行数:37,代码来源:spop_strans_meat.hpp
示例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);
}
开发者ID:dragly,项目名称:molecular-dynamics,代码行数:6,代码来源:SpSubview_iterators_meat.hpp
示例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);
}
开发者ID:DASLaboratories,项目名称:Armadillo,代码行数:66,代码来源:arma_ostream_meat.hpp
示例4: eT
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<eT>::const_iterator begin, const uword n_elem, const typename arma_not_cx<eT>::result* junk)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
o.unsetf(ios::showbase);
o.unsetf(ios::uppercase);
o.unsetf(ios::showpos);
o.fill(' ');
std::streamsize cell_width;
bool use_layout_B = false;
bool use_layout_C = false;
for(typename SpMat<eT>::const_iterator it = begin; it.pos() < n_elem; ++it)
{
const eT val = *it;
if(
val >= eT(+100) ||
( (is_signed<eT>::value == true) && (val <= eT(-100)) ) ||
( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT(+1e-4)) ) ||
( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == true) && (val < eT(0)) && (val >= eT(-1e-4)) )
)
{
use_layout_C = true;
break;
}
if(
(val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-10)) )
)
{
use_layout_B = true;
}
}
if(use_layout_C == true)
{
o.setf(ios::scientific);
o.setf(ios::right);
o.unsetf(ios::fixed);
o.precision(4);
cell_width = 13;
}
else
if(use_layout_B == true)
{
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(4);
cell_width = 10;
}
else
{
o.unsetf(ios::scientific);
o.setf(ios::right);
o.setf(ios::fixed);
o.precision(4);
cell_width = 9;
}
return cell_width;
}
开发者ID:DASLaboratories,项目名称:Armadillo,代码行数:69,代码来源:arma_ostream_meat.hpp
注:本文中的typenameSpMat类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论