本文整理汇总了C++中StatisticsVector::mean方法的典型用法代码示例。如果您正苦于以下问题:C++ StatisticsVector::mean方法的具体用法?C++ StatisticsVector::mean怎么用?C++ StatisticsVector::mean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatisticsVector
的用法示例。
在下文中一共展示了StatisticsVector::mean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (triangulate)
{
if (verbose)
libMesh::out << "...Converting to all simplices...\n";
MeshTools::Modification::all_tri(mesh);
}
/**
* Compute Shape quality metrics
*/
if (do_quality)
{
StatisticsVector<Real> sv;
sv.reserve(mesh.n_elem());
libMesh::out << "Quality type is: " << Quality::name(quality_type) << std::endl;
// What are the quality bounds for this element?
std::pair<Real, Real> bounds = mesh.elem(0)->qual_bounds(quality_type);
libMesh::out << "Quality bounds for this element type are: (" << bounds.first
<< ", " << bounds.second << ") "
<< std::endl;
MeshBase::const_element_iterator it = mesh.active_elements_begin(),
end = mesh.active_elements_end();
for (; it != end; ++it)
{
Elem *e = *it;
sv.push_back(e->quality(quality_type));
}
const unsigned int n_bins = 10;
libMesh::out << "Avg. shape quality: " << sv.mean() << std::endl;
// Find element indices below the specified cutoff.
// These might be considered "bad" elements which need refinement.
std::vector<dof_id_type> bad_elts = sv.cut_below(0.8);
libMesh::out << "Found " << bad_elts.size()
<< " of " << mesh.n_elem()
<< " elements below the cutoff." << std::endl;
/*
for (unsigned int i=0; i<bad_elts.size(); i++)
libMesh::out << bad_elts[i] << " ";
libMesh::out << std::endl;
*/
// Compute the histogram for this distribution
std::vector<dof_id_type> histogram;
sv.histogram(histogram, n_bins);
/*
for (unsigned int i=0; i<n_bins; i++)
histogram[i] = histogram[i] / mesh.n_elem();
*/
const bool do_matlab = true;
if (do_matlab)
{
std::ofstream out ("histo.m");
out << "% This is a sample histogram plot for Matlab." << std::endl;
out << "bin_members = [" << std::endl;
for (unsigned int i=0; i<n_bins; i++)
示例2: main
//.........这里部分代码省略.........
#endif
// Maybe Triangulate
if (triangulate)
{
if (verbose)
libMesh::out << "...Converting to all simplices...\n";
MeshTools::Modification::all_tri(mesh);
}
// Compute Shape quality metrics
if (do_quality)
{
StatisticsVector<Real> sv;
sv.reserve(mesh.n_elem());
libMesh::out << "Quality type is: " << Quality::name(quality_type) << std::endl;
// What are the quality bounds for this element?
std::pair<Real, Real> bounds = mesh.elem_ref(0).qual_bounds(quality_type);
libMesh::out << "Quality bounds for this element type are: ("
<< bounds.first
<< ", "
<< bounds.second
<< ") "
<< std::endl;
for (const auto & elem : mesh.active_element_ptr_range())
sv.push_back(elem->quality(quality_type));
const unsigned int n_bins = 10;
libMesh::out << "Avg. shape quality: " << sv.mean() << std::endl;
// Find element indices below the specified cutoff.
// These might be considered "bad" elements which need refinement.
std::vector<dof_id_type> bad_elts = sv.cut_below(0.8);
libMesh::out << "Found " << bad_elts.size()
<< " of " << mesh.n_elem()
<< " elements below the cutoff." << std::endl;
// Compute the histogram for this distribution
std::vector<dof_id_type> histogram;
sv.histogram(histogram, n_bins);
const bool do_matlab = true;
if (do_matlab)
{
std::ofstream out ("histo.m");
out << "% This is a sample histogram plot for Matlab." << std::endl;
out << "bin_members = [" << std::endl;
for (unsigned int i=0; i<n_bins; i++)
out << static_cast<Real>(histogram[i]) / static_cast<Real>(mesh.n_elem())
<< std::endl;
out << "];" << std::endl;
std::vector<Real> bin_coords(n_bins);
const Real max = *(std::max_element(sv.begin(), sv.end()));
const Real min = *(std::min_element(sv.begin(), sv.end()));
const Real delta = (max - min) / static_cast<Real>(n_bins);
for (unsigned int i=0; i<n_bins; i++)
bin_coords[i] = min + (i * delta) + delta / 2.0 ;