本文整理汇总了C++中matrix_type::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix_type::swap方法的具体用法?C++ matrix_type::swap怎么用?C++ matrix_type::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix_type
的用法示例。
在下文中一共展示了matrix_type::swap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fit
void fit()
{
std::cerr << "\nbefore the fit, thickness is set to be " << thickness << "\n";
assert( ug_size );
assert( ar_dim );
assert( column_index < ar_dim );
assert( std::abs(std::real(thickness)) < 1.0e-10 );
assert( std::imag(thickness) > 1.0e-10 );
assert( diag_matrix.col() == ar_dim );
assert( diag_matrix.row() == intensity_matrix.row() );
assert( intensity_matrix.col() == ar_dim );
assert( initial_ug.row() == ug_size );
assert( initial_ug.col() == 1 );
assert( ar.row() == ar.col() );
assert( ar_dim == ar.row() );
assert( progress_ratio >= value_type{0} );
assert( progress_ratio <= value_type{1} );
assert( alpha );
assert( beta );
assert( gamma );
new_residual = iterate( initial_ug, new_ug );
matrix_type second_ug{ initial_ug };
size_type current_iteration = 0;
matrix_vector_type vm;
vector_type vr;
vm.push_back( new_ug );
vr.push_back( new_residual );
value_type best_residual_so_far = new_residual;
while ( true )
{
value_type const second_residual = iterate( new_ug, second_ug );
bool break_flag = false;
//??
if ( best_residual_so_far > max_iteration * second_residual ) break_flag = true;
best_residual_so_far = std::min( second_residual, best_residual_so_far );
if( ++current_iteration > max_iteration ) break_flag = true;
new_ug.swap( second_ug );
new_residual = second_residual;
vm.push_back( new_ug );
vr.push_back( new_residual );
if ( break_flag ) break;
}
size_type const elite_index = std::distance( vr.begin(), std::min_element( vr.begin(), vr.end() ) );
std::copy( vm[elite_index].begin(), vm[elite_index].end(), new_ug.begin() );
//std::cout << "\ncurrent elite residual is " << vr[elite_index] << ", at iteration " << current_iteration << std::endl;
}