本文整理汇总了C++中array_type::size方法的典型用法代码示例。如果您正苦于以下问题:C++ array_type::size方法的具体用法?C++ array_type::size怎么用?C++ array_type::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array_type
的用法示例。
在下文中一共展示了array_type::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_json
/// Turn the array into a JSON array
fostlib::json to_json() const {
fostlib::json r;
for ( std::size_t i = 0; i < array.size(); ++i )
fostlib::jcursor().push_back( r,
fostlib::coerce< fostlib::json >( array[i] )
);
return r;
}
示例2:
/// Print the vector onto a stream
fostlib::ostream &print_on(fostlib::ostream &o) const {
o << "(";
for ( std::size_t i = 0; i < array.size(); ++i ) {
if ( i != 0 )
o << ", ";
o << array[i];
}
return o << ")";
}
示例3: step
void ImplicitEulerScheme::step(array_type& a, Time t) {
using namespace ext::placeholders;
QL_REQUIRE(t-dt_ > -1e-8, "a step towards negative time given");
map_->setTime(std::max(0.0, t-dt_), t);
bcSet_.setTime(std::max(0.0, t-dt_));
bcSet_.applyBeforeSolving(*map_, a);
if (map_->size() == 1) {
a = map_->solve_splitting(0, a, -dt_);
}
else {
const ext::function<Disposable<Array>(const Array&)>
preconditioner(ext::bind(
&FdmLinearOpComposite::preconditioner, map_, _1, -dt_));
const ext::function<Disposable<Array>(const Array&)> applyF(
ext::bind(&ImplicitEulerScheme::apply, this, _1));
if (solverType_ == BiCGstab) {
const BiCGStabResult result =
QuantLib::BiCGstab(applyF, std::max(Size(10), a.size()),
relTol_, preconditioner).solve(a, a);
(*iterations_) += result.iterations;
a = result.x;
}
else if (solverType_ == GMRES) {
const GMRESResult result =
QuantLib::GMRES(applyF, std::max(Size(10), a.size()/10u),
relTol_, preconditioner).solve(a, a);
(*iterations_) += result.errors.size();
a = result.x;
}
else
QL_FAIL("unknown/illegal solver type");
}
bcSet_.applyAfterSolving(a);
}
示例4: insert
//-----------------------------------------------------------------//
handle_type insert(const T& st) {
handle_type h;
if(erase_set_.empty()) {
h = static_cast<handle_type>(array_.size());
array_.push_back(st);
} else {
set_it it = erase_set_.begin();
h = *it;
array_[h] = st;
erase_set_.erase(it);
}
return h;
}
示例5: step
void ImplicitEulerScheme::step(array_type& a, Time t) {
QL_REQUIRE(t-dt_ > -1e-8, "a step towards negative time given");
map_->setTime(std::max(0.0, t-dt_), t);
bcSet_.setTime(std::max(0.0, t-dt_));
bcSet_.applyBeforeSolving(*map_, a);
a = BiCGstab(
boost::function<Disposable<Array>(const Array&)>(
boost::bind(&ImplicitEulerScheme::apply, this, _1)),
10*a.size(), relTol_,
boost::function<Disposable<Array>(const Array&)>(
boost::bind(&FdmLinearOpComposite::preconditioner,
map_, _1, -dt_))
).solve(a).x;
bcSet_.applyAfterSolving(a);
}
示例6: resize
inline void resize ()
{
if ((size + 1) >= position_type (array.size ()))
array.resize ((size + 1) * 2);
}
示例7: size
//-----------------------------------------------------------------//
handle_type size() const { return static_cast<handle_type>(array_.size()); }
示例8: applyTo
void applyTo(array_type& a, Time) const {
for(Size i=0; i < a.size(); i++) {
a[i] = std::max(a[i], 0.0);
}
}
示例9: size
size_type size() const
{
return diagonal.size();
}