Skip to content

Commit

Permalink
delete trailing white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tvercaut committed Jan 26, 2025
1 parent 6d38c52 commit adfea91
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Source/lsmrBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )
std::fill( v, v+n, zero);
std::fill( w, v+n, zero);
std::fill( x, x+n, zero);

this->Scale( m, (-1.0), u );
this->Aprod1( m, n, x, u );
this->Scale( m, (-1.0), u );
Expand Down
2 changes: 1 addition & 1 deletion Source/lsmrBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class lsmrBase
*/
unsigned int GetStoppingReason() const;

/**
/**
* Returns an string giving the reason for termination.
* Expands on GetStoppingReason
*
Expand Down
2 changes: 0 additions & 2 deletions Source/lsmrDense.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,3 @@ Aprod2(unsigned int m, unsigned int n, double * x, const double * y ) const
x[col] += sum;
}
}


6 changes: 3 additions & 3 deletions Source/lsmrDense.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
/** \class lsmrDense
*
* Specific implementation of the solver for a type of dense Matrix.
*
*
*/
class lsmrDense : public lsmrBase
class lsmrDense : public lsmrBase
{
public:

Expand Down Expand Up @@ -57,4 +57,4 @@ class lsmrDense : public lsmrBase
double ** A;
};

#endif
#endif
30 changes: 15 additions & 15 deletions Source/lsqrBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ lsqrBase::GetFinalEstimateOfNormRbar() const
}


double
double
lsqrBase::GetFinalEstimateOfNormOfResiduals() const
{
return this->Arnorm;
}


double
double
lsqrBase::GetFinalEstimateOfNormOfX() const
{
return this->xnorm;
Expand Down Expand Up @@ -209,7 +209,7 @@ lsqrBase::D2Norm( double a, double b ) const
{
return zero;
}

const double sa = a / scale;
const double sb = b / scale;

Expand Down Expand Up @@ -239,12 +239,12 @@ lsqrBase::Dnrm2( unsigned int n, const double *x ) const

for ( unsigned int i = 0; i < n; i++ )
{
if ( x[i] != 0.0 )
if ( x[i] != 0.0 )
{
double dx = x[i];
const double absxi = std::abs(dx);

if ( magnitudeOfLargestElement < absxi )
if ( magnitudeOfLargestElement < absxi )
{
// rescale the sum to the range of the new element
dx = magnitudeOfLargestElement / absxi;
Expand All @@ -266,7 +266,7 @@ lsqrBase::Dnrm2( unsigned int n, const double *x ) const
}


/**
/**
*
* The array b must have size m
*
Expand All @@ -281,16 +281,16 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )
{
(*this->nout) << "Enter LSQR " << std::endl;
(*this->nout) << m << ", " << n << std::endl;
(*this->nout) << this->damp << ", " << this->wantse << std::endl;
(*this->nout) << this->atol << ", " << this->conlim << std::endl;
(*this->nout) << this->btol << ", " << this->itnlim << std::endl;
(*this->nout) << this->damp << ", " << this->wantse << std::endl;
(*this->nout) << this->atol << ", " << this->conlim << std::endl;
(*this->nout) << this->btol << ", " << this->itnlim << std::endl;
}

this->damped = ( this->damp > zero );

this->itn = 0;
this->istop = 0;

unsigned int nstop = 0;
this->maxdx = 0;

Expand Down Expand Up @@ -363,7 +363,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )

return;
}

double rhobar = alpha;
double phibar = beta;

Expand All @@ -372,7 +372,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )

double test1 = 0.0;
double test2 = 0.0;


if ( this->nout )
{
Expand Down Expand Up @@ -416,7 +416,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )
//
do {

this->itn++;
this->itn++;

//----------------------------------------------------------------
// Perform the next step of the bidiagonalization to obtain the
Expand Down Expand Up @@ -488,7 +488,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )
double t3 = one / rho;
double dknorm = zero;

if ( this->wantse )
if ( this->wantse )
{
for ( unsigned int i = 0; i < n; i++ )
{
Expand Down Expand Up @@ -649,7 +649,7 @@ Solve( unsigned int m, unsigned int n, const double * b, double * x )
}
}

} while ( istop == 0);
} while ( istop == 0);

//===================================================================
// End of iteration loop.
Expand Down
70 changes: 35 additions & 35 deletions Source/lsqrBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,44 @@
* \brief implement a solver for a set of linear equations.
*
* LSQR finds a solution x to the following problems:
*
*
* 1. Unsymmetric equations: Solve A*x = b
*
*
* 2. Linear least squares: Solve A*x = b
* in the least-squares sense
*
*
* 3. Damped least squares: Solve ( A )*x = ( b )
* ( damp*I ) ( 0 )
* in the least-squares sense
*
*
* where A is a matrix with m rows and n columns, b is an m-vector,
* and damp is a scalar. (All quantities are real.)
* The matrix A is treated as a linear operator. It is accessed
* by means of subroutine calls with the following purpose:
*
*
* call Aprod1(m,n,x,y) must compute y = y + A*x without altering x.
* call Aprod2(m,n,x,y) must compute x = x + A'*y without altering y.
*
*
* LSQR uses an iterative method to approximate the solution.
* The number of iterations required to reach a certain accuracy
* depends strongly on the scaling of the problem. Poor scaling of
* the rows or columns of A should therefore be avoided where
* possible.
*
*
* For example, in problem 1 the solution is unaltered by
* row-scaling. If a row of A is very small or large compared to
* the other rows of A, the corresponding row of ( A b ) should be
* scaled up or down.
*
*
* In problems 1 and 2, the solution x is easily recovered
* following column-scaling. Unless better information is known,
* the nonzero columns of A should be scaled so that they all have
* the same Euclidean norm (e.g., 1.0).
*
*
* In problem 3, there is no freedom to re-scale if damp is
* nonzero. However, the value of damp should be assigned only
* after attention has been paid to the scaling of A.
*
*
* The parameter damp is intended to help regularize
* ill-conditioned systems, by preventing the true solution from
* being very large. Another aid to regularization is provided by
Expand All @@ -74,13 +74,13 @@
* of the solver that is available at
* http://www.stanford.edu/group/SOL/software.html
* distributed under a BSD license.
*
*
* This class is a replacement for the lsqr code taken from netlib.
* That code had to be removed because it is copyrighted by ACM and
* its license was incompatible with a BSD license.
*
*
*/
class lsqrBase
class lsqrBase
{
public:

Expand All @@ -102,7 +102,7 @@ class lsqrBase
* The size of the vector y is m.
*/
virtual void Aprod2(unsigned int m, unsigned int n, double * x, const double * y ) const = 0;

/**
* returns sqrt( a**2 + b**2 )
* with precautions to avoid overflow.
Expand All @@ -114,20 +114,20 @@ class lsqrBase
* with precautions to avoid overflow.
*/
double Dnrm2( unsigned int n, const double *x ) const;

/**
* Scale a vector by multiplying with a constant
*/
void Scale( unsigned int n, double factor, double *x ) const;

/** A logical variable to say if the array se(*) of standard error estimates
* should be computed. If m > n or damp > 0, the system is overdetermined
* and the standard errors may be useful. (See the first LSQR reference.)
* Otherwise (m <= n and damp = 0) they do not mean much. Some time and
* storage can be saved by setting wantse = .false. and using any convenient
* array for se(*), which won't be touched. If you call this method with the
* flag ON, then you MUST provide a working memory array to store the standard
* error estimates, via the method SetStandardErrorEstimates()
* error estimates, via the method SetStandardErrorEstimates()
*/
void SetStandardErrorEstimatesFlag( bool );

Expand All @@ -137,8 +137,8 @@ class lsqrBase
*/
void SetToleranceA( double );

/** An estimate of the relative error in the data
* defining the rhs b. For example, if b is
/** An estimate of the relative error in the data
* defining the rhs b. For example, if b is
* accurate to about 6 digits, set btol = 1.0e-6.
*/
void SetToleranceB( double );
Expand Down Expand Up @@ -181,9 +181,9 @@ class lsqrBase
* of damp in the range 0 to sqrt(eps)*norm(A)
* will probably have a negligible effect.
* Larger values of damp will tend to decrease
* the norm of x and reduce the number of
* the norm of x and reduce the number of
* iterations required by LSQR.
*
*
* The work per iteration and the storage needed
* by LSQR are the same for all values of damp.
*
Expand All @@ -198,47 +198,47 @@ class lsqrBase
*/
void SetMaximumNumberOfIterations( unsigned int );

/**
/**
* If provided, a summary will be printed out to this stream during
* the execution of the Solve function.
*/
void SetOutputStream( std::ostream & os );

/** Provide the array where the standard error estimates will be stored.
/** Provide the array where the standard error estimates will be stored.
* You MUST provide this working memory array if you turn on the computation
* of standard error estimates with teh method SetStandardErrorEstimatesFlag().
*/
void SetStandardErrorEstimates( double * array );

/**
/**
* Returns an integer giving the reason for termination:
*
*
* 0 x = 0 is the exact solution.
* No iterations were performed.
*
*
* 1 The equations A*x = b are probably compatible.
* Norm(A*x - b) is sufficiently small, given the
* values of atol and btol.
*
*
* 2 damp is zero. The system A*x = b is probably
* not compatible. A least-squares solution has
* been obtained that is sufficiently accurate,
* given the value of atol.
*
*
* 3 damp is nonzero. A damped least-squares
* solution has been obtained that is sufficiently
* accurate, given the value of atol.
*
*
* 4 An estimate of cond(Abar) has exceeded conlim.
* The system A*x = b appears to be ill-conditioned,
* or there could be an error in Aprod1 or Aprod2.
*
*
* 5 The iteration limit itnlim was reached.
*
*/
unsigned int GetStoppingReason() const;

/**
/**
* Returns an string giving the reason for termination.
* Expands on GetStoppingReason
*
Expand All @@ -250,7 +250,7 @@ class lsqrBase
unsigned int GetNumberOfIterationsPerformed() const;


/**
/**
* An estimate of the Frobenius norm of Abar.
* This is the square-root of the sum of squares
* of the elements of Abar.
Expand All @@ -263,7 +263,7 @@ class lsqrBase
double GetFrobeniusNormEstimateOfAbar() const;


/**
/**
* An estimate of cond(Abar), the condition
* number of Abar. A very high value of Acond
* may again indicate an error in Aprod1 or Aprod2.
Expand Down Expand Up @@ -297,7 +297,7 @@ class lsqrBase

/**
* Execute the solver
*
*
* solves Ax = b or min ||Ax - b|| with or without damping,
*
* m is the size of the input vector b
Expand Down Expand Up @@ -338,4 +338,4 @@ class lsqrBase
double * se;
};

#endif
#endif
4 changes: 1 addition & 3 deletions Source/lsqrDense.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Aprod2(unsigned int m, unsigned int n, double * x, const double * y ) const
}


/*
/*
returns x = (I - 2*z*z')*x.
Expand Down Expand Up @@ -111,5 +111,3 @@ HouseholderTransformation(unsigned int n, const double * z, double * x ) const
*xp++ -= scalarProduct * (*zp++);
}
}


Loading

0 comments on commit adfea91

Please sign in to comment.