|
MRTKLIB 0.7.14
Modernized GNSS Positioning Library
|
MRTKLIB Matrix Module — Matrix/vector operations and estimation. More...
#include "mrtklib/mrtk_mat.h"#include <math.h>#include <stdarg.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Functions | |
| static void | fatalerr (const char *format,...) |
| 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). | |
| static int | ludcmp (double *A, int n, int *indx, double *d) |
| static void | lubksb (const double *A, int n, const int *indx, double *b) |
| 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. | |
| static int | filter_ (const double *x, const double *P, const double *H, const double *v, const double *R, int n, int m, double *xp, double *Pp) |
| 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) |
| void | matprint (const double A[], int n, int m, int p, int q) |
Variables | |
| static fatalfunc_t * | fatalfunc = NULL |
MRTKLIB Matrix Module — Matrix/vector operations and estimation.
This file contains all matrix/vector and estimation functions extracted from rtkcmn.c with zero algorithmic changes (pure cut-and-paste).
Definition in file mrtk_mat.c.
|
extern |
|
extern |
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(), model_phw(), plane(), sat_yaw(), satantoff(), satpos_ssr(), and windupcorr().
|
extern |
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(), model_phw(), norm(), ocean_tide_clasgrid(), peph2pos(), resdop(), sat_yaw(), satantpcv(), satazel(), satpos_ssr(), testeclipse(), tide_pl(), toml_rtod_ex(), valsol(), and windupcorr().
|
extern |
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(), udpos_ppp(), and udpos_ppp().
|
static |
|
extern |
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(), pppos(), relpos(), and update_states().
|
static |
|
extern |
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(), udpos(), and udpos_ppp().
|
extern |
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().
|
static |
Definition at line 400 of file mrtk_mat.c.
Referenced by matinv().
|
static |
Definition at line 345 of file mrtk_mat.c.
Referenced by matinv().
|
extern |
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_amb_ILS(), ppp_rtk_pos(), pppos(), raim_fde(), relpos(), relposvrs(), resamb_LAMBDA(), resamb_LAMBDA(), resamb_LAMBDA(), sddop(), sddop(), search(), smoother(), solve(), udpos(), udpos(), udpos_ppp(), udpos_ppp(), write_trace_sd_amb(), zddop(), zddop(), and zeros().
|
extern |
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(), model_trop(), pntpos(), ppp_amb_ILS(), ppp_rtk_pos(), pppos(), raim_fde(), raw2rtcm(), readpcv(), relpos(), relposvrs(), sat_yaw(), send_nmea(), setopt_apppos(), setopt_sta(), smoother(), solve(), strsvrthread(), udpos(), udpos_ppp(), and update_ionutc().
|
extern |
Definition at line 615 of file mrtk_mat.c.
Referenced by matprint().
|
extern |
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().
|
extern |
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(), udpos_ppp(), udpos_ppp(), and write_trace_sd_amb().
|
extern |
Definition at line 625 of file mrtk_mat.c.
References matfprint().
|
extern |
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(), decode_solsss(), estpos(), estvel(), find_grid_surround_pos(), geodist(), ionmodel(), ionocorr(), miono_sel_area(), model_phw(), normv3(), out_iono_sys(), out_leaps(), out_time_sys(), outnmea_rmc(), outrnxevent(), outsols(), pcv_slot_has_data(), pephpos(), pickup_candidates_of_grid(), pntpos(), posdist(), ppp_amb_ILS(), ppp_rtk_pos(), pppos(), readpcv(), relposvrs(), resdop(), satpos_ssr(), send_nmea(), setopt_sta(), setpcv(), shapiro(), testeclipse(), tide_pl(), tidedisp(), udpos(), udpos(), udpos_ppp(), udpos_ppp(), windupcorr(), zdres(), and zdres().
|
extern |
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(), model_phw(), plane(), sat_yaw(), satantoff(), satantpcv(), satpos_ssr(), testeclipse(), and windupcorr().
|
extern |
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().
|
extern |
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().
|
extern |
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_amb_ILS(), ppp_rtk_pos(), pppos(), raim_fde(), relpos(), relposvrs(), resamb_LAMBDA(), resamb_LAMBDA(), residual_test(), residual_test(), rtkinit(), search(), set_init_pb(), set_init_pb(), udbias(), udbias_ppp(), udbias_ppp(), update_states(), and write_trace_sd_amb().
|
static |
Definition at line 34 of file mrtk_mat.c.
Referenced by add_fatal(), and fatalerr().