solve
Called by: main each iteration.
Includes: iscloc.h
External: max_err_factor set in read_config.
Input arguments:
Pointer to solution structure.
Array of phase structures.
Structure members updated:
time, lat, lon, dircos, depth and covar in solution structure.
Return: 0/1 for success/failure.
This function solves a set of simultaneous equations, one for
each defining phase, and stores the results as the current solution. The
equation of condition between each arrival and the source in terms of members
of a phase structure is:
- x.sin(esaz).dtdd - y.cos(esaz).dtdd + z.dtdh + t = resid
Where x,y,z and t are the amounts that the
source longitude, latitude, depth, and time need to be altered by to conform
with the observed arrival time. These equations constitute a least squares
problem and are solved using the method of normal equations, LU decomposition
and back substitution for both the 4 unknowns and the covariance matrix.
To avoid pivoting problems the diagonal elements of the matrix of normal
equations are checked to make sure that none of them approach zero too closely.
This is done by comparing them with a threshold calculated using a value
assigned in the configuration file max_err_factor. Once x,y,z and t have been found they are used to correct lon, lat, depth and time in the solution structure. The 4x4 covariance matrix is saved as covar in the solution structure so that standard errors can be calculated for the final solution.