当前位置: 首页>>代码示例>>C++>>正文


C++ boost::irange方法代码示例

本文整理汇总了C++中boost::irange方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::irange方法的具体用法?C++ boost::irange怎么用?C++ boost::irange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost的用法示例。


在下文中一共展示了boost::irange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fill_padding_repeat

    void fill_padding_repeat()
    {
        using boost::irange;

        const auto offset = ValueLayer::padding_offset;
        const auto last_row = this->num_rows() + offset - 1;
        const auto last_col = this->num_cols() + offset - 1;

        auto& layer_array = this->layer_array;

        for (auto row : irange(0lu, util::rows(layer_array))) {
            auto const& x = layer_array[row][last_col];
            auto const& y = layer_array[row][offset];
            for (auto i : irange(1, offset + 1)) {
                layer_array[row][last_col + i] = x;
                layer_array[row][offset - i] = y;
            }
        }
        for (auto col : irange(0lu, util::cols(layer_array))) {
            auto const& x = layer_array[last_row][col];
            auto const& y = layer_array[offset][col];
            for (auto i : irange(1, offset + 1)) {
                layer_array[last_row + i][col] = x;
                layer_array[offset - i][col] = y;
            }
        }
    }
开发者ID:mforner,项目名称:wpl-polsar,代码行数:27,代码来源:ValueLayer.hpp

示例2: add_aligned_pair_score_value_list

/// \brief TODOCUMENT
///
/// \todo Could this be generalised (perhaps with a non-member function
///       to make it convenient for the particulars of aligned_pair_score_value_list) ?
void score_classn_value_results_set::add_aligned_pair_score_value_list(const aligned_pair_score_value_list &arg_aligned_pair_score_value_list, ///< TODOCUMENT
                                                                       const bool                          &arg_condition_is_positive,         ///< TODOCUMENT
                                                                       const string                        &arg_instance_label                 ///< TODOCUMENT
                                                                       ) {
	const size_t num_score_values = arg_aligned_pair_score_value_list.size();
	if ( empty() ) {
		for (const size_t &score_value_ctr : irange( 0_z, num_score_values ) ) {
			const auto   &score            = arg_aligned_pair_score_value_list.get_aligned_pair_score_of_index( score_value_ctr );
			const string &name             = score.human_friendly_short_name();
			const bool   &higher_is_better = score.higher_is_better();
			score_classn_value_lists.push_back( make_score_classn_value_list( {}, higher_is_better, name ) );
		}
		sort_score_classn_value_lists();
	}
	else {
		const auto    new_names      = get_all_names( arg_aligned_pair_score_value_list );
		const str_set new_names_set( common::cbegin( new_names ), common::cend( new_names ) );
		const size_t  num_series     = size();
		const auto    existing_names = transform_build<str_vec>(
			irange( 0_z, num_series ),
			[&] (const size_t &x) { return get_name_of_index( *this, x ); }
		);

		if ( ! equal( existing_names, new_names_set ) ) {
//			cerr << "existing_names : " << join( existing_names, ", " ) << endl;
//			cerr << "new_names_set  : " << join( new_names_set,  ", " ) << endl;
			BOOST_THROW_EXCEPTION(invalid_argument_exception("Cannot add aligned_pair_score_value_list because the series names don't match the existing ones"));
		}
	}

	for (const size_t &score_value_ctr : irange( 0_z, num_score_values ) ) {
		const auto   &value            = arg_aligned_pair_score_value_list.get_value_of_index             ( score_value_ctr );
		const auto   &score            = arg_aligned_pair_score_value_list.get_aligned_pair_score_of_index( score_value_ctr );
		const string &name             = score.human_friendly_short_name();
		const bool   &higher_is_better = score.higher_is_better();

		score_classn_value_list &the_list = get_score_classn_value_list_of_name( name );
		if ( get_higher_is_better( the_list ) != higher_is_better ) {
			BOOST_THROW_EXCEPTION(invalid_argument_exception( "Cannot add aligned_pair_score_value_list to score_classn_value_results_set because they conflict regarding the higher_is_better value for score " + name ));
		}

		the_list.add_score_classn_value(
			score_classn_value(
				value,
				arg_condition_is_positive,
				arg_instance_label
			)
		);
	}
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:54,代码来源:score_classn_value_results_set.cpp

示例3: do_select_common_residues_with_scores

/// \brief TODOCUMENT
size_vec common_residue_select_best_score_percent_policy::do_select_common_residues_with_scores(const doub_doub_pair_vec &arg_scores ///< TODOCUMENT
                                                                                                ) const {
	// Grab the a list of the smaller value from each pair of scores
	const auto min_scores = transform_build<doub_vec>(
		arg_scores,
		[] (const doub_doub_pair &x) { return min( x.first, x.second ); }
	);

	// Build a stable_sorted list of indices in descending order of the score to which each corresponds
	const auto score_sorted_indices = stable_sort_build<size_vec>(
		irange( 0_z, min_scores.size() ),
		[&] (const size_t &x, const size_t &y) {
			return ( min_scores.at( x ) > min_scores.at( y ) );
		}
	);

	// Calculate the total score of all values and the cutoff for best_score_percentage % of it
	const double total_score            = accumulate( min_scores, 0.0 );
	const double percentile_total_score = total_score * best_score_percentage / 100.0;

	// Step through score_sorted_indices and grab them until the sum of their scores exceeds
	// percentile_total_score, then return a sorted copy of all those indices
	double temp_sum( 0.0 );
	return sort_build<size_vec>(
		common::cbegin( score_sorted_indices ),
		find_if(
			score_sorted_indices,
			[&] (const size_t &x) {
				temp_sum += min_scores[ x ];
				return ( temp_sum > percentile_total_score );
			}
		)
	);
}
开发者ID:sillitoe,项目名称:cath-tools,代码行数:35,代码来源:common_residue_select_best_score_percent_policy.cpp

示例4: decltype

decltype(auto) convert_helper(const std::vector<cv::Mat>& input,
                              CONVERT_FUN convert_element)
{
    using boost::irange;

    const auto ROWS = input[0].rows;
    const auto COLS = input[0].cols;

    auto result = util::make_vector_2d<MATRIX_TYPE>(ROWS, COLS);
    for (auto row : irange(0, ROWS)) {
        for (auto col : irange(0, COLS)) {
            result[row][col] = convert_element(input, row, col);
        }
    }
    return result;
}
开发者ID:mforner,项目名称:wpl-polsar,代码行数:16,代码来源:Utilities.hpp

示例5: generate_colour_names

/// \brief Generate names to use in the viewer for the specified number of colours
str_vec cath::generate_colour_names(const size_t &arg_num_colours ///< The total number of colours
                                    ) {
	return transform_build<str_vec>(
		irange( 0_z, arg_num_colours ),
		[&] (const size_t &x) { return generate_colour_name( x, arg_num_colours ); }
	);
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:8,代码来源:viewer.cpp

示例6: get_score_classn_values_of_instance_labels

/// \brief TODOCUMENT
///
/// \relates score_classn_value_results_set
void cath::score::write_to_svm_light_data_files(const score_classn_value_results_set &arg_results_set,      ///< TODOCUMENT
                                                const path                           &arg_output_file_stem, ///< TODOCUMENT
                                                const size_t                         &arg_num_repeats,      ///< TODOCUMENT
                                                mt19937                              &arg_rng,              ///< TODOCUMENT
                                                const double                         &arg_fraction_train    ///< TODOCUMENT
                                                ) {
	const auto num_instances   = get_num_instances      ( arg_results_set );
	const auto names           = get_names              ( arg_results_set );
	const auto instance_labels = get_instance_labels    ( arg_results_set );
	const auto scalings        = get_value_list_scalings( arg_results_set );

	// Get a data structure in which all lists are sorted in the same way
	const auto results = transform_build<score_classn_value_vec_vec>(
		names,
		[&] (const string &x) {
			const auto &results_list = arg_results_set.get_score_classn_value_list_of_name( x );
			return get_score_classn_values_of_instance_labels( results_list, instance_labels );
		}
	);

	for (const size_t &repeat_ctr : irange( 1_z, arg_num_repeats + 1 ) ) {
		const auto repeat_ctr_str = lexical_cast<string>( repeat_ctr );

		const path train_file  = replace_extension_copy( arg_output_file_stem, "." + repeat_ctr_str + ".train" );
		const path test_file   = replace_extension_copy( arg_output_file_stem, "." + repeat_ctr_str + ".test"  );

		const size_vec_size_vec_pair split_indices = random_split( arg_rng, num_instances, arg_fraction_train );

		write_to_svm_light_data_files_impl( results, scalings, train_file, split_indices.first  );
		write_to_svm_light_data_files_impl( results, scalings, test_file,  split_indices.second );
	}
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:35,代码来源:score_classn_value_results_set.cpp

示例7: do_check

/// \brief TODOCUMENT
///
/// Things for investigation:
///  * raw/final score from alignment
///  * expected raw/final score
///  * top categorised reasons by raw score
///  * repeat for varying scan_stride (can just be called by nmnf fn)
alignment_scan_comparison check_scan_on_final_alignment::do_check(const alignment     &arg_alignment,  ///< TODOCUMENT
                                                                  const protein       &arg_protein_a,  ///< TODOCUMENT
                                                                  const protein       &arg_protein_b,  ///< TODOCUMENT
                                                                  const quad_criteria &arg_criteria,   ///< TODOCUMENT
                                                                  const scan_stride   &arg_scan_stride ///< TODOCUMENT
                                                                  ) const {
	const auto aln_range = irange( 0_z, arg_alignment.length() );
	cerr << "SHOULD THE RANGE BE 7.0 RATHER THAN SQRT(40.0)????\n";
	return accumulate(
		cross( aln_range, aln_range ),
		alignment_scan_comparison{},
		[&] (alignment_scan_comparison x, const size_size_tpl &y) {
			const size_t aln_from_ctr   = get<0>( y );
			const size_t aln_to_ctr     = get<1>( y );
			const bool   from_alns_both = has_both_positions_of_index( arg_alignment, aln_from_ctr );
			const bool   to_alns_both   = has_both_positions_of_index( arg_alignment, aln_to_ctr   );

			if ( from_alns_both && to_alns_both ) {

				const auto a_from     = get_a_position_of_index( arg_alignment, aln_from_ctr );
				const auto b_from     = get_b_position_of_index( arg_alignment, aln_from_ctr );
				const auto a_to       = get_a_position_of_index( arg_alignment, aln_to_ctr   );
				const auto b_to       = get_b_position_of_index( arg_alignment, aln_to_ctr   );
				const bool a_included = difference( a_from, a_to ) > NUM_EXCLUDED_ON_SIDES;
				const bool b_included = difference( b_from, b_to ) > NUM_EXCLUDED_ON_SIDES;

				if ( a_included && b_included ) {
					const auto the_distance = distance_between_points(
						view_vector_of_residue_pair(
							arg_protein_a.get_residue_ref_of_index( a_from ),
							arg_protein_a.get_residue_ref_of_index( a_to   )
						),
						view_vector_of_residue_pair(
							arg_protein_b.get_residue_ref_of_index( b_from ),
							arg_protein_b.get_residue_ref_of_index( b_to   )
						)
					);
//					const auto score       = ( the_distance >= 7.0 ) ? 0.0 : ( 1.0 - the_distance / 7.0 );
					const auto score       = ( the_distance >= sqrt( 40.0 ) ) ? 0.0 : ( 1.0 - the_distance / 7.0 );
					if ( score > 0.0 ) {
						const auto scan_result = quad_and_rep_criteria_result_of(
							arg_protein_a,
							arg_protein_b,
							arg_criteria,
							arg_scan_stride,
							numeric_cast<index_type>( a_from ),
							numeric_cast<index_type>( a_to   ),
							numeric_cast<index_type>( b_from ),
							numeric_cast<index_type>( b_to   )
						);
						x += make_pair( scan_result, score );
					}
				}
			}

			return x;
		}
	);
}
开发者ID:sillitoe,项目名称:cath-tools,代码行数:66,代码来源:check_scan_on_final_alignment.cpp

示例8: result

/// \brief Generate a string describing the difference between the specified dssp_dupl_ress parsed from a DSSP file
///        and the specified bifur_hbond_list or return none if there isn't any difference
///
/// \relates dssp_dupl_res
str_opt cath::sec::difference_string(const dssp_dupl_res_vec &arg_dssp_dupl_res_vec, ///< A vector of dssp_dupl_res parsed from a DSSP file
                                     const bifur_hbond_list  &arg_bifur_hbond_list   ///< The dssp_dupl_res_list to be compared to the dssp_dupl_res vector
                                     ) {
	const auto num_dssp_dupl_res = arg_dssp_dupl_res_vec.size();
	const auto arg_bifur_hbonds  = arg_bifur_hbond_list.size();

	const auto dssp_non_null_indices = copy_build<size_vec>(
		irange( 0_z, num_dssp_dupl_res )
			| filtered(
				[&] (const size_t &x) {
					return ! arg_dssp_dupl_res_vec[ x ].pdb_residue_name.is_null();
				}
			)
	);

	const size_t num_non_null_residues = dssp_non_null_indices.size();

	const str_opt num_prob = make_optional(
		( num_non_null_residues != arg_bifur_hbonds ),
		"Number of (non-null) DSSP hbond residues ("
			+ ::std::to_string( num_non_null_residues )
			+ "), doesn't match the number of calculated hbond residues ("
			+ ::std::to_string( arg_bifur_hbonds )
			+ "). "
	);

	const auto normal_index_of_dssp_index = [&] () {
		size_vec result( num_dssp_dupl_res, 0 );
		for (const size_t &x : irange( 0_z, dssp_non_null_indices.size() ) ) {
			result[ dssp_non_null_indices[ x ] ] = x;
		}
		return result;
	}();

	for (const size_t &index : irange( 0_z, min( num_dssp_dupl_res, arg_bifur_hbonds ) ) ) {
		const auto diff_str = difference_string( arg_dssp_dupl_res_vec[ dssp_non_null_indices[ index ] ], arg_bifur_hbond_list[ index ], normal_index_of_dssp_index );
		if ( diff_str ) {
			return ( num_prob ? *num_prob : string{} ) + *diff_str;
		}
	}

	return num_prob
		? make_optional( *num_prob + " No differences spotted until the end of the shortest" )
		: none;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:49,代码来源:dssp_dupl_fixture.cpp

示例9: get_name_of_index

/// \brief TODOCUMENT
///
/// \relates score_classn_value_results_set
str_vec cath::score::get_names(const score_classn_value_results_set &arg_results_set ///< TODOCUMENT
                               ) {
	return transform_build<str_vec>(
		irange( 0_z, arg_results_set.size() ),
		[&] (const size_t &x) {
			return get_name_of_index( arg_results_set, x );
		}
	);
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:12,代码来源:score_classn_value_results_set.cpp

示例10: generateStitchSet

std::vector<std::string> generateStitchSet(const std::string& directory, boost::format pattern, bool reverse, int start, int rowSize) {
	std::cout << format("Generating stitch set for range %1% to %2%\n") % start % (start + rowSize);
	std::cout << format("Reversing? %1%\n") % reverse;
	std::vector<std::string> files;
	for (auto i : irange(start, rowSize + start + 1)) {
		std::string filename = boost::str(pattern % directory % i);
		files.push_back(filename);
	}
	if (reverse) std::reverse(files.begin(), files.end());
	return files;
}
开发者ID:birryree,项目名称:registrator,代码行数:11,代码来源:stitch.cpp

示例11: build_views

/// \brief Private static method that implements the process of building the views from proteins
coord_vec_vec view_cache::build_views(const protein &arg_protein ///< The protein which the view_cache should be built to represent
                                      ) {
	// Grab the number of residues and prepare the views accordingly
	const size_t num_residues = arg_protein.get_length();
	coord_vec_vec new_views( num_residues );
	for (coord_vec &view_of : new_views) {
		view_of.reserve( num_residues );
	}

	// Loop over the all from-versus-to residue pairs and add the resulting views
	for (const size_t &from_res_ctr : irange( 0_z, num_residues ) ) {
		for (const size_t &to_res_ctr : irange( 0_z, num_residues ) ) {
			coord_vec &view_of_from = new_views[ from_res_ctr ];
			view_of_from.push_back( view_vector_of_residue_pair(
				arg_protein.get_residue_ref_of_index( from_res_ctr ),
				arg_protein.get_residue_ref_of_index( to_res_ctr   )
			) );
		}
	}
	return new_views;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:22,代码来源:view_cache.cpp

示例12: do_get_colour_spec_from_num_entries

/// \brief TODOCUMENT
broad_display_colour_spec display_colourer_consecutive::do_get_colour_spec_from_num_entries(const size_t &arg_num_entries ///< The number of structures to be coloured
                                                                                            ) const {
	// Create a new display_colour_spec and populate it for the entries with colours
	broad_display_colour_spec new_spec;
	for (const size_t entry_ctr : irange( 0_z, arg_num_entries ) ) {
		new_spec.colour_pdb(
			entry_ctr,
			colour_of_mod_index( colours, entry_ctr )
		);
	}

	// Return the generated display_colour_spec
	return new_spec;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:15,代码来源:display_colourer_consecutive.cpp

示例13: remove_duplicates

/// \brief TODOCUMENT
hmmer_scores_entry_vec hmmer_scores_file::remove_duplicates(const hmmer_scores_entry_vec &arg_hmmer_scores_entries ///< TODOCUMENT
                                                            ) {
	hmmer_scores_entry_vec  results;

	str_str_pair_size_map index_of_previously_seen;

	return transform_build<hmmer_scores_entry_vec>(
		irange( 0_z, arg_hmmer_scores_entries.size() )
			| filtered(
				[&] (const size_t &x) {
					const auto &entry     = arg_hmmer_scores_entries[ x ];
					const auto &id1       = entry.get_name_1();
					const auto &id2       = entry.get_name_2();
					const auto &evalue    = entry.get_full_sequence_evalue();
					const auto  name_pair = make_pair( id1, id2 );

					if ( ! contains( index_of_previously_seen, name_pair ) ) {
						index_of_previously_seen.emplace( name_pair, x );
						return true;
					}

					cerr << "Ooo - crazy things happening with HMMER parsing" << "\n";

					const auto prev_entry = arg_hmmer_scores_entries[ index_of_previously_seen.at( name_pair ) ];
//					if ( entry.get_hit_num() <= prev_entry.get_hit_num() ) {
//						BOOST_THROW_EXCEPTION(invalid_argument_exception(
//							"When parsing PRC results, found hit between " + id1 + " and " + id2 + " with hit number that isn't higher than for previous result"
//						));
//						BOOST_LOG_TRIVIAL( warning ) << "When parsing PRC results, found hit between " << id1 << " and " << id2 << " with hit number that isn't higher than for previous result";
//					}
					if ( evalue          <  prev_entry.get_full_sequence_evalue()  ) {
						BOOST_THROW_EXCEPTION(invalid_argument_exception(
							"When parsing HMMER results, found hit between " + id1 + " and " + id2 + " with evalue better than for previous result"
						));
					}
					if ( entry.get_full_sequence_score()  >  prev_entry.get_full_sequence_score()  ) {
						BOOST_THROW_EXCEPTION(invalid_argument_exception(
							"When parsing HMMER results, found hit between " + id1 + " and " + id2 + " with simple score better than for previous result "
							+ " " + std::to_string( entry.get_full_sequence_score() )
							+ " " + std::to_string( prev_entry.get_full_sequence_score() )
						));
					}
					return false;
				}
			),
		[&] (const size_t &x) { return arg_hmmer_scores_entries[ x ]; }
	);
	return results;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:50,代码来源:hmmer_scores_file.cpp

示例14:

/// \brief TODOCUMENT
size_size_pair_vec cath::align::get_alignment_break_pairs(const alignment &arg_alignment ///< TODOCUMENT
                                                          ) {
	const auto alignment_breaks     = get_alignment_breaks( arg_alignment );
	const auto num_alignment_breaks = alignment_breaks.size();

	size_size_pair_vec break_pairs;
	break_pairs.reserve( num_alignment_breaks );

	for (const size_t &idx_one : irange( 0_z, num_alignment_breaks ) ) {
		for (const size_t &idx_two : irange( idx_one, num_alignment_breaks ) ) {
			const size_t &break_one = alignment_breaks[ idx_one ];
			const size_t &break_two = alignment_breaks[ idx_two ];

			const auto pair_result = check_pair( arg_alignment, break_one, break_two );
			if ( pair_result.first  == break_pair_validity::GOOD ) {
				break_pairs.emplace_back( break_one, break_two );
			}
			if ( pair_result.second == break_pair_future::NEVER_AGAIN ) {
				break;
			}
		}
	}
	return break_pairs;
}
开发者ID:UCLOrengoGroup,项目名称:cath-tools,代码行数:25,代码来源:alignment_breaks.cpp

示例15: add_entries_from_permutation

void add_entries_from_permutation( binary_truth_table& spec, const std::vector<unsigned>& permutation )
{
  using boost::combine;
  using boost::irange;
  using boost::get;

  unsigned n = (unsigned)ceil( log( permutation.size() ) / log( 2 ) );

  for ( const auto& i : combine( irange( 0u, (unsigned)permutation.size() ),
                                 permutation ) )
  {
    spec.add_entry( number_to_truth_table_cube( get<0>( i ), n ),
                    number_to_truth_table_cube( get<1>( i ), n ) );
  }
}
开发者ID:Siddhant,项目名称:revkit-2.0,代码行数:15,代码来源:synthesis.cpp


注:本文中的boost::irange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。