typename boost::enable_if_c< is_readable_matrix<Matrix1>::value && is_readable_matrix<Matrix2>::value, bool >::type is_equal_mat(const Matrix1& M1, const Matrix2& M2, typename mat_traits<Matrix1>::value_type NumTol = typename mat_traits<Matrix1>::value_type(1E-8) ) { if( ( M1.get_row_count() != M2.get_row_count() ) || ( M1.get_col_count() != M2.get_col_count() ) ) return false; typedef typename mat_traits<Matrix1>::size_type SizeType; using std::fabs; for(SizeType i = 0; i < M1.get_row_count(); ++i) for(SizeType j = 0; j < M1.get_col_count(); ++j) if( fabs(M1(i,j) - M2(i,j)) > NumTol ) return false; return true; };
typename boost::enable_if_c< is_fully_writable_matrix<Matrix1>::value && is_readable_matrix<Matrix2>::value && is_readable_matrix<Matrix3>::value && is_readable_matrix<Matrix4>::value, Matrix1 >::type block_mat(Matrix1 MUL,const Matrix2& MUR,const Matrix3& MLL,const Matrix4& MLR) { if((MUL.get_row_count() != MUR.get_row_count()) || (MUL.get_col_count() != MLL.get_col_count()) || (MLL.get_row_count() != MLR.get_row_count()) || (MUR.get_col_count() != MLR.get_col_count())) throw std::range_error("Matrix dimension mismatch."); typedef typename mat_traits<Matrix1>::size_type SizeType; SizeType oldColCount = MUL.get_col_count(); SizeType oldRowCount = MUL.get_row_count(); append_block_diag(MUL,MLR); for(SizeType i = 0; i < MUR.get_row_count(); ++i) for(SizeType j = 0; j < MUR.get_col_count(); ++j) MUL(i,j + oldColCount) = MUR(i,j); for(SizeType i = 0; i < MLL.get_row_count(); ++i) for(SizeType j = 0; j < MLL.get_col_count(); ++j) MUL(i + oldRowCount,j) = MLL(i,j); return MUL; };