本文整理汇总了C++中vector_type::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_type::size方法的具体用法?C++ vector_type::size怎么用?C++ vector_type::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_type
的用法示例。
在下文中一共展示了vector_type::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: y
public: vector_type simulate(vector_type const& u, vector_type const& e, real_type na_value = real_type(0)) const
{
namespace ublas = ::boost::numeric::ublas;
namespace ublasx = ::boost::numeric::ublasx;
size_type n_obs = u.size();
size_type n_e = e.size();
DCS_ASSERT(
n_obs == n_e,
throw ::std::logic_error("Size of Input Data and Noise Data does not match.")
);
size_type n_a = ublasx::size(a_); // # of output channels
size_type n_b = ublasx::size(b_); // # of input channels
size_type k_min = 0;
size_type k_max = n_obs - ::std::min(static_cast<size_type>(d_*ts_), n_obs);
vector_type y(n_obs, na_value);
// for (size_type k = 0; k < k_min; ++k)
// {
// y(k) = e_var_*e(k);
// }
for (size_type k = k_min; k < k_max; ++k)
{
y(k) = 0;
if (n_a > 0 && k > 0)
{
size_type nn_a = ::std::min(n_a, k);
y(k) -= ublas::inner_prod(
//a_,
ublas::subrange(a_, 0, nn_a),
//::dcs::math::la::subslice(y, k-1, -1, n_a)
ublas::subslice(y, k-1, -1, nn_a)
);
}
if (n_b > 0)
{
size_type nn_b = ::std::min(n_b, k+1);
y(k) += ublas::inner_prod(
//b_,
ublas::subrange(b_, 0, nn_b),
//::dcs::math::la::subslice(u, k, -1, n_b)
ublas::subslice(u, k, -1, nn_b)
);
}
y(k) += e_var_*e(k);
}
return y;
}
示例2: Reflector
matrix_type Reflector(const vector_type& x)
{
using namespace boost::numeric::ublas;
matrix_type F(x.size(), x.size());
Reflector<matrix_type, vector_type>(x, F);
return F;
}
示例3: setBounds
void setBounds( vector_type const& __lb, vector_type const& __up )
{
GST_SMART_ASSERT( __lb.size() == __up.size() )( __lb )( __up )( "inconsistent bounds definition" );
M_lb = __lb;
M_ub = __up;
M_lb_ub = __up - __lb;
GST_SMART_ASSERT( *std::min_element( M_lb_ub.begin(), M_lb_ub.end() ) >= 0 )
( M_lb )( M_ub )( "lower and upper bounds are not properly defined" );
}
示例4: is_empty
bool is_empty() const
{
for (unsigned i = 0; i < m_lower.size(); ++i)
if (m_lower[i] >= m_upper[i])
return true;
return false;
}
示例5: n
public: uniform_signal_generator(vector_type const& u_min, vector_type const& u_max, random_generator_type& rng)
: rng_(rng),
ub_( ::std::numeric_limits<value_type>::infinity()),
lb_(-::std::numeric_limits<value_type>::infinity())
{
// pre: size(u_min) == size(u_max)
DCS_ASSERT(u_min.size() == u_max.size(),
DCS_EXCEPTION_THROW(::std::invalid_argument,
"Size of min and max vectors does not match"));
::std::size_t n(u_min.size());
for (::std::size_t i = 0; i < n; ++i)
{
distrs_.push_back(uniform_distribution_type(u_min[i], u_max[i]));
}
}
示例6: contains
bool contains(VecType const &pt, double threshold=1e-10) const
{
for (unsigned i = 0; i < m_lower.size(); ++i)
if (pt[i] < m_lower[i] - threshold
|| pt[i] >= m_upper[i]+threshold)
return false;
return true;
}
示例7: zeta
void
DirScalingMatrix<NumType>::update( value_type const& __Delta,
vector_type const& __x,
vector_type const& __s,
mode_type __mode )
{
GST_SMART_ASSERT( __x.size() == M_lb.size() )( __x )( M_lb )( "inconsistent bounds definition" );
GST_SMART_ASSERT( __x.size() == M_ub.size() )( __x )( M_ub )( "inconsistent bounds definition" );
M_value.resize( __x.size(), __x.size(), 0, 0 );
M_jacobian.resize( __x.size(), __x.size(), 0, 0 );
M_zeta = zeta( __x );
vector_type __dl = distanceToLB( __x );
vector_type __du = distanceToUB( __x );
if ( M_zeta * std::min( norm_inf( __dl ), norm_inf( __du ) ) > __Delta )
{
// we are in the trust region
M_value = identity_matrix<value_type>( M_value.size1(), M_value.size2() );
}
else
{
M_trust_region_active = true;
for ( size_t __i = 0; __i < __x.size(); ++__i )
{
if ( __s ( __i ) < 0 )
M_value ( __i, __i ) = M_zeta * std::min( 1. , __dl( __i ) ) / __Delta;
else
M_value ( __i, __i ) = M_zeta * std::min( 1. , __du( __i ) ) / __Delta;
}
}
if ( __mode == WITH_JACOBIAN )
{
for ( size_t i = 0; i < __x.size(); i++ )
{
if ( ( __s( i ) < 0 ) && ( __x( i ) < M_lb( i ) + __Delta ) )
{
M_jacobian ( i, i ) = M_zeta / __Delta;
}
else if ( ( __s ( i ) > 0 ) && ( __x ( i ) > M_ub( i ) - __Delta ) )
{
M_jacobian ( i, i ) = -M_zeta / __Delta;
}
else
{
M_jacobian ( i, i ) = 0;
}
}
}
}
示例8: super
decorated_tuple(cow_pointer_type d, const vector_type& v)
: super(tuple_impl_info::statically_typed)
, m_decorated(std::move(d)), m_mapping(v) {
# ifdef CPPA_DEBUG
const cow_pointer_type& ptr = m_decorated; // prevent detaching
# endif
CPPA_REQUIRE(ptr->size() >= sizeof...(ElementTypes));
CPPA_REQUIRE(v.size() == sizeof...(ElementTypes));
CPPA_REQUIRE(*(std::max_element(v.begin(), v.end())) < ptr->size());
}
示例9: make
decorated_tuple::cow_ptr decorated_tuple::make(cow_ptr d, vector_type v) {
auto ptr = dynamic_cast<const decorated_tuple*>(d.get());
if (ptr) {
d = ptr->decorated();
auto& pmap = ptr->mapping();
for (size_t i = 0; i < v.size(); ++i) {
v[i] = pmap[v[i]];
}
}
return make_counted<decorated_tuple>(std::move(d), std::move(v));
}
示例10: do_filter
void do_filter(const vector_type& src, vector_type& dest)
{
typedef regex_iterator<const Ch*, Ch, Tr> iterator;
if (src.empty())
return;
iterator first(&src[0], &src[0] + src.size(), re_, flags_);
iterator last;
const Ch* suffix = 0; // Prevent GCC 2.95 warning.
for (; first != last; ++first) {
dest.insert( dest.end(),
first->prefix().first,
first->prefix().second );
string_type replacement = replace_(*first);
dest.insert( dest.end(),
replacement.begin(),
replacement.end() );
suffix = first->suffix().first;
}
dest.insert(dest.end(), suffix, &src[0] + src.size());
}
示例11: operator
value_type NBS::operator() (const vector_type& in, const value_type T, vector_type& out) const
{
out = vector_type::Zero (in.size());
value_type max_value = value_type(0);
for (ssize_t seed = 0; seed != in.size(); ++seed) {
if (std::isfinite (in[seed]) && in[seed] >= T && !out[seed]) {
BitSet visited (in.size());
visited[seed] = true;
vector<size_t> to_expand (1, seed);
size_t cluster_size = 0;
while (to_expand.size()) {
const uint32_t index = to_expand.back();
to_expand.pop_back();
cluster_size++;
for (vector<size_t>::const_iterator i = (*adjacency)[index].begin(); i != (*adjacency)[index].end(); ++i) {
if (!visited[*i] && std::isfinite(in[*i]) && in[*i] >= T) {
visited[*i] = true;
to_expand.push_back (*i);
}
}
}
max_value = std::max (max_value, value_type(cluster_size));
for (ssize_t i = 0; i != in.size(); ++i)
out[i] += (visited[i] ? 1.0 : 0.0) * cluster_size;
}
}
return max_value;
}
示例12:
per_turn_visitor(std::string const& complete_caseid,
vector_type const& points)
{
namespace bg = boost::geometry;
if (points.size() > 100u)
{
// Defensive check. Too much intersections. Don't create anything
return;
}
BOOST_FOREACH(pair_type const& p, points)
{
mappers.push_back(new mapper_visitor<Point>(complete_caseid, p.second, p.first));
}
示例13: intersect
box intersect(box<VecType2> const &b2) const
{
const unsigned dims = m_lower.size();
const vector_type d_vector_lower(dims);
const vector_type d_vector_upper(dims);
box<vector_type> result(d_vector_lower, d_vector_upper);
for (unsigned i = 0; i < dims; ++i)
{
result.m_lower[i] = std::max(m_lower[i], b2.m_lower[i]);
result.m_upper[i] = std::min(m_upper[i], b2.m_upper[i]);
}
return result;
}
示例14: solve
vector_type solve(const matrix_type& A,
const vector_type& y)
{
namespace ublas = boost::numeric::ublas;
matrix_type A_factorized = A;
ublas::permutation_matrix<size_t> pm(y.size());
int singular = lu_factorize(A_factorized, pm);
if (singular) throw std::runtime_error("[LinearSolver<LU>::solve()] A is singular.");
vector_type result(y);
lu_substitute(A_factorized, pm, result);
return result;
}
示例15: DirScalingMatrix
DirScalingMatrix( vector_type const& __lb, vector_type const& __ub )
:
M_lb( __lb ),
M_ub( __ub ),
M_lb_ub( M_ub - M_lb ),
M_value( __lb.size(), __lb.size(), 0, 0 ),
M_jacobian( __lb.size(), __lb.size(), 0, 0 ),
M_trust_region_active( false )
{
GST_SMART_ASSERT( __lb.size() == __ub.size() )( __lb )( __ub )( "inconsistent bounds definition" );
GST_SMART_ASSERT( *std::min_element( M_lb_ub.begin(), M_lb_ub.end() ) >= 0 )
( M_lb )( M_ub )( "lower and upper bounds are not properly defined" );
}