|
MRTKLIB 0.7.14
Modernized GNSS Positioning Library
|
MRTKLIB Matrix Module — Matrix/vector operations and estimation. More...
Go to the source code of this file.
Typedefs | |
| typedef void | fatalfunc_t(const char *) |
| Fatal callback function type for allocation failures. | |
Functions | |
| void | add_fatal (fatalfunc_t *func) |
| Add fatal callback function for mat(), zeros(), imat(). | |
| double * | mat (int n, int m) |
| Allocate memory for a double matrix. | |
| int * | imat (int n, int m) |
| Allocate memory for an integer matrix. | |
| double * | zeros (int n, int m) |
| Allocate a new zero matrix. | |
| double * | eye (int n) |
| Generate a new identity matrix. | |
| double | dot (const double *a, const double *b, int n) |
| Inner product of vectors. | |
| double | norm (const double *a, int n) |
| Euclidean norm of vector. | |
| void | cross3 (const double *a, const double *b, double *c) |
| Cross product of 3D vectors. | |
| int | normv3 (const double *a, double *b) |
| Normalize 3D vector. | |
| void | matcpy (double *A, const double *B, int n, int m) |
| Copy matrix. | |
| void | matmul (const char *tr, int n, int k, int m, double alpha, const double *A, const double *B, double beta, double *C) |
| Multiply matrix by matrix (C = alpha*A*B + beta*C). | |
| int | matinv (double *A, int n) |
| Inverse of matrix (A = A^-1). | |
| int | solve (const char *tr, const double *A, const double *Y, int n, int m, double *X) |
| Solve linear equation (X = A\Y or X = A'\Y). | |
| int | lsq (const double *A, const double *y, int n, int m, double *x, double *Q) |
| Least square estimation by solving normal equation. | |
| int | filter (double *x, double *P, const double *H, const double *v, const double *R, int n, int m) |
| Kalman filter state update. | |
| int | smoother (const double *xf, const double *Qf, const double *xb, const double *Qb, int n, double *xs, double *Qs) |
| Combine forward and backward filters by fixed-interval smoother. | |
| void | matfprint (const double *A, int n, int m, int p, int q, FILE *fp) |
| Print matrix to file pointer. | |
| void | matprint (const double *A, int n, int m, int p, int q) |
| Print matrix to stdout. | |
MRTKLIB Matrix Module — Matrix/vector operations and estimation.
This header provides matrix and vector allocation, arithmetic, linear algebra (LU decomposition, matrix inversion, linear solve), and estimation algorithms (least squares, Kalman filter, smoother).
Definition in file mrtk_mat.h.
| typedef void fatalfunc_t(const char *) |
Fatal callback function type for allocation failures.
Definition at line 43 of file mrtk_mat.h.
| void add_fatal | ( | fatalfunc_t * | func | ) |
| void cross3 | ( | const double * | a, |
| const double * | b, | ||
| double * | c ) |
Cross product of 3D vectors.
| [in] | a | Vector a (3 x 1) |
| [in] | b | Vector b (3 x 1) |
| [out] | c | Cross product a x b (3 x 1) |
Definition at line 172 of file mrtk_mat.c.
Referenced by clas_osr_adjust_r_dts(), clas_osr_satcorr_update(), plane(), satantoff(), satpos_ssr(), and windupcorr().
| double dot | ( | const double * | a, |
| const double * | b, | ||
| int | n ) |
Inner product of vectors.
| [in] | a | Vector a (n x 1) |
| [in] | b | Vector b (n x 1) |
| [in] | n | Size of vectors |
Definition at line 151 of file mrtk_mat.c.
Referenced by antmodel(), clas_osr_satcorr_update(), clas_stec_grid_data(), clas_trop_grid_data(), deq(), ecef2pos(), find_grid_surround_pos(), norm(), ocean_tide_clasgrid(), peph2pos(), resdop(), satazel(), satpos_ssr(), tide_pl(), toml_rtod_ex(), valsol(), and windupcorr().
| double * eye | ( | int | n | ) |
Generate a new identity matrix.
| [in] | n | Number of rows and columns |
Definition at line 129 of file mrtk_mat.c.
References zeros().
Referenced by filter2_(), filter2_(), filter_(), lambda(), udpos(), udpos(), and udpos_ppp().
| int filter | ( | double * | x, |
| double * | P, | ||
| const double * | H, | ||
| const double * | v, | ||
| const double * | R, | ||
| int | n, | ||
| int | m ) |
Kalman filter state update.
K=P*H*(H'*P*H+R)^-1, xp=x+K*v, Pp=(I-K*H')*P
| [in,out] | x | States vector (n x 1) |
| [in,out] | P | Covariance matrix of states (n x n) |
| [in] | H | Transpose of design matrix (n x m) |
| [in] | v | Innovation (measurement - model) (m x 1) |
| [in] | R | Covariance matrix of measurement error (m x m) |
| [in] | n | Number of states |
| [in] | m | Number of measurements |
Definition at line 524 of file mrtk_mat.c.
References filter_(), free, imat(), and mat().
Referenced by holdamb(), holdamb(), holdamb(), and relpos().
| int * imat | ( | int | n, |
| int | m ) |
Allocate memory for an integer matrix.
| [in] | n | Number of rows |
| [in] | m | Number of columns |
Definition at line 92 of file mrtk_mat.c.
References fatalerr(), and malloc.
Referenced by clas_trop_grid_data(), filter(), filter2(), filter2(), filter2_(), filter2_(), matinv(), raim_fde(), resamb_LAMBDA(), and udpos().
| int lsq | ( | const double * | A, |
| const double * | y, | ||
| int | n, | ||
| int | m, | ||
| double * | x, | ||
| double * | Q ) |
Least square estimation by solving normal equation.
Solves x = (A*A')^-1 * A * y.
| [in] | A | Transpose of (weighted) design matrix (n x m) |
| [in] | y | (Weighted) measurements (m x 1) |
| [in] | n | Number of parameters |
| [in] | m | Number of measurements (n <= m) |
| [out] | x | Estimated parameters (n x 1) |
| [out] | Q | Estimated parameters covariance matrix (n x n) |
Definition at line 470 of file mrtk_mat.c.
References free, mat(), matinv(), and matmul().
Referenced by estpos(), and estvel().
| double * mat | ( | int | n, |
| int | m ) |
Allocate memory for a double matrix.
| [in] | n | Number of rows |
| [in] | m | Number of columns |
Definition at line 76 of file mrtk_mat.c.
References fatalerr(), and malloc.
Referenced by calc_3points_weight(), clas_get_grid_index(), clas_ssr2osr(), clas_stec_grid_data(), clas_trop_grid_data(), ddres(), ddres(), ddres(), estpos(), estvel(), filter(), filter2(), filter2(), filter2_(), filter2_(), filter_(), holdamb(), holdamb(), holdamb(), lambda(), lambda_reduction(), lambda_search(), LD(), lsq(), ludcmp(), matinv(), pntpos(), ppp_rtk_pos(), raim_fde(), relpos(), relposvrs(), resamb_LAMBDA(), resamb_LAMBDA(), resamb_LAMBDA(), sddop(), sddop(), search(), smoother(), solve(), udpos(), udpos(), udpos_ppp(), zddop(), zddop(), and zeros().
| void matcpy | ( | double * | A, |
| const double * | B, | ||
| int | n, | ||
| int | m ) |
Copy matrix.
| [out] | A | Destination matrix (n x m) |
| [in] | B | Source matrix (n x m) |
| [in] | n | Number of rows |
| [in] | m | Number of columns |
Definition at line 205 of file mrtk_mat.c.
Referenced by clas_get_grid_index(), decode_bdsraw(), decode_bnx_00(), decode_cnav(), decode_enav(), decode_galrawfnav(), decode_galrawinav(), decode_glorawca(), decode_gnav(), decode_ionutc(), decode_ionutc(), decode_L1ionutc(), decode_navicraw(), decode_qzssrawsubframeb(), estvel(), filter2_(), filter2_(), filter_(), matinv(), pntpos(), ppp_rtk_pos(), raim_fde(), raw2rtcm(), readpcv(), relpos(), relposvrs(), send_nmea(), setopt_apppos(), setopt_sta(), smoother(), solve(), strsvrthread(), udpos(), udpos_ppp(), and update_ionutc().
| void matfprint | ( | const double * | A, |
| int | n, | ||
| int | m, | ||
| int | p, | ||
| int | q, | ||
| FILE * | fp ) |
Print matrix to file pointer.
| [in] | A | Matrix A (n x m) |
| [in] | n,m | Number of rows and columns |
| [in] | p,q | Total columns, columns under decimal point |
| [in] | fp | Output file pointer |
| int matinv | ( | double * | A, |
| int | n ) |
Inverse of matrix (A = A^-1).
| [in,out] | A | Matrix (n x n) |
| [in] | n | Size of matrix |
Definition at line 421 of file mrtk_mat.c.
References free, imat(), lubksb(), ludcmp(), mat(), and matcpy().
Referenced by calc_3points_weight(), clas_get_grid_index(), dops(), filter2_(), filter2_(), filter_(), lsq(), resamb_LAMBDA(), resamb_LAMBDA(), resamb_LAMBDA(), sddop(), sddop(), smoother(), and solve().
| void matmul | ( | const char * | tr, |
| int | n, | ||
| int | k, | ||
| int | m, | ||
| double | alpha, | ||
| const double * | A, | ||
| const double * | B, | ||
| double | beta, | ||
| double * | C ) |
Multiply matrix by matrix (C = alpha*A*B + beta*C).
| [in] | tr | Transpose flags ("N":normal, "T":transpose) |
| [in] | n,k,m | Size of (transposed) matrix A, B |
| [in] | alpha | Alpha coefficient |
| [in] | A,B | (Transposed) matrix A (n x m), B (m x k) |
| [in] | beta | Beta coefficient |
| [in,out] | C | Matrix C (n x k) |
Definition at line 310 of file mrtk_mat.c.
Referenced by calc_3points_weight(), clas_stec_grid_data(), clas_trop_grid_data(), covecef(), covenu(), dops(), ecef2enu(), eci2ecef(), enu2ecef(), filter2_(), filter2_(), filter_(), lambda(), lsq(), ocean_tide_clasgrid(), resamb_LAMBDA(), resamb_LAMBDA(), resamb_LAMBDA(), resdop(), sddop(), sddop(), smoother(), solve(), sunmoonpos(), tidedisp(), udpos(), udpos(), and udpos_ppp().
| void matprint | ( | const double * | A, |
| int | n, | ||
| int | m, | ||
| int | p, | ||
| int | q ) |
Print matrix to stdout.
| [in] | A | Matrix A (n x m) |
| [in] | n,m | Number of rows and columns |
| [in] | p,q | Total columns, columns under decimal point |
| double norm | ( | const double * | a, |
| int | n ) |
Euclidean norm of vector.
| [in] | a | Vector a (n x 1) |
| [in] | n | Size of vector |
Definition at line 165 of file mrtk_mat.c.
References dot().
Referenced by antpos(), baseline(), baseline(), baseline_len(), clas_osr_satcorr_update(), clas_osr_zdres(), clas_ssr2osr(), combpeph(), constbl(), convrnx_s(), estpos(), estvel(), find_grid_surround_pos(), geodist(), ionmodel(), ionocorr(), miono_sel_area(), normv3(), out_iono_sys(), out_leaps(), out_time_sys(), outrnxevent(), outsols(), pcv_slot_has_data(), pephpos(), pickup_candidates_of_grid(), pntpos(), posdist(), ppp_rtk_pos(), readpcv(), relposvrs(), resdop(), satpos_ssr(), send_nmea(), setopt_sta(), setpcv(), shapiro(), tide_pl(), tidedisp(), udpos(), udpos(), udpos_ppp(), windupcorr(), zdres(), and zdres().
| int normv3 | ( | const double * | a, |
| double * | b ) |
Normalize 3D vector.
| [in] | a | Vector a (3 x 1) |
| [out] | b | Normalized vector (3 x 1), || b || = 1 |
Definition at line 183 of file mrtk_mat.c.
References norm().
Referenced by clas_osr_adjust_r_dts(), clas_osr_satcorr_update(), plane(), satantoff(), satpos_ssr(), and windupcorr().
| int smoother | ( | const double * | xf, |
| const double * | Qf, | ||
| const double * | xb, | ||
| const double * | Qb, | ||
| int | n, | ||
| double * | xs, | ||
| double * | Qs ) |
Combine forward and backward filters by fixed-interval smoother.
xs=Qs*(Qf^-1*xf+Qb^-1*xb), Qs=(Qf^-1+Qb^-1)^-1
| [in] | xf | Forward solutions (n x 1) |
| [in] | Qf | Forward solutions covariance matrix (n x n) |
| [in] | xb | Backward solutions (n x 1) |
| [in] | Qb | Backward solutions covariance matrix (n x n) |
| [in] | n | Number of solutions |
| [out] | xs | Smoothed solutions (n x 1) |
| [out] | Qs | Smoothed solutions covariance matrix (n x n) |
Definition at line 579 of file mrtk_mat.c.
References free, mat(), matcpy(), matinv(), and matmul().
Referenced by combres().
| int solve | ( | const char * | tr, |
| const double * | A, | ||
| const double * | Y, | ||
| int | n, | ||
| int | m, | ||
| double * | X ) |
Solve linear equation (X = A\Y or X = A'\Y).
| [in] | tr | Transpose flag ("N":normal, "T":transpose) |
| [in] | A | Input matrix A (n x n) |
| [in] | Y | Input matrix Y (n x m) |
| [in] | n,m | Size of matrix A, Y |
| [out] | X | Solution X = A\Y or X = A'\Y (n x m) |
Definition at line 443 of file mrtk_mat.c.
References free, mat(), matcpy(), matinv(), and matmul().
Referenced by lambda().
| double * zeros | ( | int | n, |
| int | m ) |
Allocate a new zero matrix.
| [in] | n | Number of rows |
| [in] | m | Number of columns |
Definition at line 108 of file mrtk_mat.c.
References calloc, fatalerr(), and mat().
Referenced by clas_ssr2osr(), eye(), filter2(), holdamb(), holdamb(), holdamb(), lambda(), lambda_reduction(), lambda_search(), pntpos(), ppp_rtk_pos(), raim_fde(), relpos(), relposvrs(), resamb_LAMBDA(), resamb_LAMBDA(), residual_test(), residual_test(), rtkinit(), search(), set_init_pb(), set_init_pb(), udbias(), udbias_ppp(), and udbias_ppp().