| 830 | } |
| 831 | |
| 832 | void HighsSparseMatrix::considerColScaling( |
| 833 | const HighsInt max_scale_factor_exponent, double* col_scale) { |
| 834 | const double log2 = log(2.0); |
| 835 | const double max_allow_scale = pow(2.0, max_scale_factor_exponent); |
| 836 | const double min_allow_scale = 1 / max_allow_scale; |
| 837 | |
| 838 | const double min_allow_col_scale = min_allow_scale; |
| 839 | const double max_allow_col_scale = max_allow_scale; |
| 840 | |
| 841 | if (this->isColwise()) { |
| 842 | for (HighsInt iCol = 0; iCol < this->num_col_; iCol++) { |
| 843 | double col_max_value = 0; |
| 844 | for (HighsInt iEl = this->start_[iCol]; iEl < this->start_[iCol + 1]; |
| 845 | iEl++) |
| 846 | col_max_value = max(fabs(this->value_[iEl]), col_max_value); |
| 847 | if (col_max_value) { |
| 848 | double col_scale_value = 1 / col_max_value; |
| 849 | // Convert the col scale factor to the nearest power of two, and |
| 850 | // ensure that it is not excessively large or small |
| 851 | col_scale_value = pow(2.0, floor(log(col_scale_value) / log2 + 0.5)); |
| 852 | col_scale_value = |
| 853 | min(max(min_allow_col_scale, col_scale_value), max_allow_col_scale); |
| 854 | col_scale[iCol] = col_scale_value; |
| 855 | // Scale the column |
| 856 | for (HighsInt iEl = this->start_[iCol]; iEl < this->start_[iCol + 1]; |
| 857 | iEl++) |
| 858 | this->value_[iEl] *= col_scale[iCol]; |
| 859 | } else { |
| 860 | // Empty column |
| 861 | col_scale[iCol] = 1; |
| 862 | } |
| 863 | } |
| 864 | } else { |
| 865 | assert(1 == 0); |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | void HighsSparseMatrix::considerRowScaling( |
| 870 | const HighsInt max_scale_factor_exponent, double* row_scale) { |
no test coverage detected