 |
Shiokaze Framework
A research-oriented fluid solver for computer graphics
|
|
Go to the documentation of this file.
25 #ifndef SHKZ_RCMATRIX_UTILITY_H
26 #define SHKZ_RCMATRIX_UTILITY_H
61 for( N row=0; row<matrix->
rows(); ++row ) {
63 if( column < matrix->rows()) {
64 max_error = std::max(max_error,std::abs(value-matrix->
get(column,row)));
66 max_error = std::max(max_error,std::abs(value));
84 N active(0), max_row(0), min_row(std::numeric_limits<N>::max()), active_rows(0);
85 T avg_row(0.0), max_diag(0.0), min_diag(std::numeric_limits<T>::max());
87 bool symm_postive_diag (
true);
89 for( N i=0; i<matrix->
rows(); i++ ) {
90 if( ! matrix->
empty(i) ) {
92 active += row_nonzero;
93 max_row = std::max(max_row,row_nonzero);
94 min_row = std::min(min_row,row_nonzero);
95 avg_row += row_nonzero;
99 if( column == i )
diag = value;
100 else max_nondiag = std::max(max_nondiag,std::abs(value));
101 if( value!=value ) has_nan =
true;
103 max_diag = std::max(max_diag,
diag);
104 min_diag = std::min(min_diag,
diag);
105 if(
diag ) diag_ratio = std::max( diag_ratio, max_nondiag /
diag );
109 if( active_rows ) avg_row /= (T)active_rows;
111 console::dump(
">>> ==== Matrix [%s] analysis ====\n", name.c_str());
113 console::dump(
"Matrix active row size = %d\n", active_rows );
120 console::dump(
"Matrix worst max(non_diag) / diag = %.2e\n", diag_ratio );
121 console::dump(
"Matrix max(symmetricity error) = %.2e\n", symmetric_error );
122 console::dump(
"Matrix has_NaN = %s\n", has_nan ?
"Yes" :
"No");
124 if( min_diag < 0.0 ) {
126 symm_postive_diag =
false;
128 if( symmetric_error ) symm_postive_diag =
false;
129 return symm_postive_diag;
bool empty() const
Get if the matrix is empty.
Definition: RCMatrix_interface.h:456
void dump(std::string format,...)
Print a log message in a single line.
virtual N columns() const =0
Get the size of columns.
static T symmetricity_error(const RCMatrix_interface< N, T > *matrix)
Measure the uniform norm of the symmetericity error.
Definition: RCMatrix_utility.h:59
void const_for_each(N row, std::function< void(N column, T value)> func) const
Read elements in serial order.
Definition: RCMatrix_interface.h:492
virtual void add_to_element(N row, N column, T increment_value)=0
Add a value to an element.
virtual N rows() const =0
Get the size of rows.
virtual T get(N row, N column) const =0
Get the element value at the row and the column.
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
static void diag(const RCMatrix_interface< N, T > *matrix, const std::vector< T > &diag)
Generate a diagonal matrix.
Definition: RCMatrix_utility.h:47
static bool report(const RCMatrix_interface< N, T > *matrix, std::string name)
Report matrix properties.
Definition: RCMatrix_utility.h:82
virtual N non_zeros(N row) const =0
Get the size of non zero entries in a row.
Interface for Row Compressed Matrix.
Definition: RCMatrix_interface.h:38
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
virtual void initialize(N rows, N columns)=0
Initialize matrix with rows and columns.
Class that provides utility functions for RCMatrix_interface.
Definition: RCMatrix_utility.h:37