@@ -133,9 +133,7 @@ void HSimplexNla::update(HVector* aq, HVector* ep, HighsInt* iRow,
133133
134134double HSimplexNla::rowEp2NormInScaledSpace (const HighsInt iRow,
135135 const HVector& row_ep) const {
136- if (scale_ == NULL ) {
137- return row_ep.norm2 ();
138- }
136+ if (!hasMatrixScale ()) return row_ep.norm2 ();
139137 const vector<double >& row_scale = scale_->row ;
140138 // Get the 2-norm of row_ep in the scaled space otherwise for
141139 // checking
@@ -186,7 +184,7 @@ double HSimplexNla::rowEp2NormInScaledSpace(const HighsInt iRow,
186184void HSimplexNla::transformForUpdate (HVector* aq, HVector* ep,
187185 const HighsInt variable_in,
188186 const HighsInt row_out) {
189- if (scale_ == NULL ) return ;
187+ if (! hasMatrixScale () ) return ;
190188 // For (\hat)aq, UPDATE needs packValue and array[row_out] to
191189 // correspond to \bar{B}^{-1}(R.aq.cq), but CB.\bar{B}^{-1}(R.aq)
192190 // has been computed.
@@ -221,13 +219,13 @@ void HSimplexNla::transformForUpdate(HVector* aq, HVector* ep,
221219}
222220
223221double HSimplexNla::variableScaleFactor (const HighsInt iVar) const {
224- if (scale_ == NULL ) return 1.0 ;
222+ if (! hasMatrixScale () ) return 1.0 ;
225223 return iVar < lp_->num_col_ ? scale_->col [iVar]
226224 : 1.0 / scale_->row [iVar - lp_->num_col_ ];
227225}
228226
229227double HSimplexNla::basicColScaleFactor (const HighsInt iCol) const {
230- if (scale_ == NULL ) return 1.0 ;
228+ if (! hasMatrixScale () ) return 1.0 ;
231229 return variableScaleFactor (basic_index_[iCol]);
232230}
233231
@@ -243,7 +241,7 @@ void HSimplexNla::setPivotThreshold(const double new_pivot_threshold) {
243241}
244242
245243void HSimplexNla::applyBasisMatrixRowScale (HVector& rhs) const {
246- if (scale_ == NULL ) return ;
244+ if (! hasMatrixScale () ) return ;
247245 const vector<double >& row_scale = scale_->row ;
248246 HighsInt to_entry;
249247 const bool use_row_indices =
@@ -255,7 +253,7 @@ void HSimplexNla::applyBasisMatrixRowScale(HVector& rhs) const {
255253}
256254
257255void HSimplexNla::applyBasisMatrixColScale (HVector& rhs) const {
258- if (scale_ == NULL ) return ;
256+ if (! hasMatrixScale () ) return ;
259257 const vector<double >& col_scale = scale_->col ;
260258 const vector<double >& row_scale = scale_->row ;
261259 HighsInt to_entry;
@@ -273,7 +271,7 @@ void HSimplexNla::applyBasisMatrixColScale(HVector& rhs) const {
273271}
274272
275273void HSimplexNla::unapplyBasisMatrixRowScale (HVector& rhs) const {
276- if (scale_ == NULL ) return ;
274+ if (! hasMatrixScale () ) return ;
277275 const vector<double >& row_scale = scale_->row ;
278276 HighsInt to_entry;
279277 const bool use_row_indices =
@@ -421,9 +419,15 @@ void HSimplexNla::reportPackValue(const std::string message,
421419 printf (" \n " );
422420}
423421
422+ bool HSimplexNla::hasMatrixScale () const {
423+ if (scale_ == nullptr ) return false ;
424+ if (scale_->col .size () && scale_->row .size ()) return true ;
425+ return false ;
426+ }
427+
424428HighsDebugStatus HSimplexNla::debugCheckData (const std::string message) const {
425429 std::string scale_status;
426- if (scale_ == NULL ) {
430+ if (! hasMatrixScale () ) {
427431 scale_status = " NULL" ;
428432 } else {
429433 scale_status = " non-NULL" ;
@@ -439,7 +443,7 @@ HighsDebugStatus HSimplexNla::debugCheckData(const std::string message) const {
439443 const HighsInt* factor_Aindex = factor_.getAindex ();
440444 const double * factor_Avalue = factor_.getAvalue ();
441445
442- if (scale_ == NULL ) {
446+ if (! hasMatrixScale () ) {
443447 if (factor_Astart != lp_->a_matrix_ .start_ .data ()) error0_found = true ;
444448 if (factor_Aindex != lp_->a_matrix_ .index_ .data ()) error1_found = true ;
445449 if (factor_Avalue != lp_->a_matrix_ .value_ .data ()) error2_found = true ;
0 commit comments