|
tico 0.1
Mechanical Watch Terminal Timegrapher
|
Math and matrix utilities. More...
Functions | |
| void | transpone (double *arr, unsigned int Nrows, unsigned int Ncols) |
| Transposes a matrix in-place. More... | |
| void | invert (double *arr, unsigned int Nrows, unsigned int Ncols) |
| Inverts a square matrix in-place. More... | |
| double * | mulmat (const double *matrix0, unsigned int Nrows, unsigned int Ncols, const double *matrix1, unsigned int Mrows, unsigned int Mcols) |
| Multiplies two matrices and returns the result as a new matrix. More... | |
| void | matlinreg (double coeffs[2], const double *xmat, unsigned int Nrows, unsigned int Ncols, double *vec, const double *weight) |
| Performs linear regression on a dataset with optional weighting. More... | |
| void | fitNpeaks (double *intercept, double *slope, unsigned int curPos, const struct myarr *maxvals, const struct myarr *maxes, const struct myarr *subpos, unsigned int npeaks, double SDthreshold) |
| Fits a line to N peaks in the data, with outlier rejection. More... | |
| void | fastlinreg (double coeffs[2], const double *xmat, unsigned int Npoints, const double *vec, const double *weightArr) |
| Performs fast weighted linear regression. More... | |
| size_t | getmaxpos (const int *array, size_t ArrayLength) |
| Returns the index of the maximum value in an integer array. More... | |
| void | linreg (const double *xarr, const double *yarr, size_t ArrayLength, double *intercept, double *slope, double *stdev) |
| Performs simple linear regression on two arrays. More... | |
| int | shiftHalf (size_t value, size_t ArrayLength) |
| Shifts a value by half the array length, wrapping around. More... | |
Math and matrix utilities.
| void fastlinreg | ( | double | coeffs[2], |
| const double * | xmat, | ||
| unsigned int | Npoints, | ||
| const double * | vec, | ||
| const double * | weightArr | ||
| ) |
Performs fast weighted linear regression.
| coeffs | Array to store the resulting coefficients (intercept and slope). |
| xmat | The array of x values. |
| Npoints | The number of points. |
| vec | The array of y values. |
| weightArr | The array of weights. |
| void fitNpeaks | ( | double * | intercept, |
| double * | slope, | ||
| unsigned int | curPos, | ||
| const struct myarr * | maxvals, | ||
| const struct myarr * | maxes, | ||
| const struct myarr * | subpos, | ||
| unsigned int | npeaks, | ||
| double | SDthreshold | ||
| ) |
Fits a line to N peaks in the data, with outlier rejection.
| intercept | Pointer to store the intercept. |
| slope | Pointer to store the slope. |
| curPos | The current position in the data. |
| maxvals | Array of weights. |
| maxes | Array of y values. |
| subpos | Array of sub-positions. |
| npeaks | Number of peaks to fit. |
| SDthreshold | Standard deviation threshold for outlier rejection. |
| size_t getmaxpos | ( | const int * | array, |
| size_t | ArrayLength | ||
| ) |
Returns the index of the maximum value in an integer array.
| array | The array to search. |
| ArrayLength | The number of elements in the array. |
| void invert | ( | double * | arr, |
| unsigned int | Nrows, | ||
| unsigned int | Ncols | ||
| ) |
Inverts a square matrix in-place.
| arr | The square matrix to invert, stored as a 1D array in row-major order. The result will overwrite the original matrix. |
| Nrows | The number of rows (and columns) in the square matrix. |
| Ncols | The number of columns (and rows) in the square matrix. |
| void linreg | ( | const double * | xarr, |
| const double * | yarr, | ||
| size_t | ArrayLength, | ||
| double * | intercept, | ||
| double * | slope, | ||
| double * | stdev | ||
| ) |
Performs simple linear regression on two arrays.
| xarr | The array of x values. |
| yarr | The array of y values. |
| ArrayLength | The number of elements in the arrays. |
| intercept | Pointer to store the intercept. |
| slope | Pointer to store the slope. |
| stdev | Pointer to store the standard deviation of the fit. |
| void matlinreg | ( | double | coeffs[2], |
| const double * | xmat, | ||
| unsigned int | Nrows, | ||
| unsigned int | Ncols, | ||
| double * | vec, | ||
| const double * | weight | ||
| ) |
Performs linear regression on a dataset with optional weighting.
| coeffs | An array of size 2 where the resulting coefficients (intercept and slope) will be stored. |
| xmat | The design matrix, stored as a 1D array in row-major order. |
| Nrows | The number of rows in the design matrix. |
| Ncols | The number of columns in the design matrix. |
| vec | The response vector, stored as a 1D array. |
| weight | An optional array of weights for each data point, stored as a 1D array. If NULL, unweighted regression is performed. |
| double * mulmat | ( | const double * | matrix0, |
| unsigned int | Nrows, | ||
| unsigned int | Ncols, | ||
| const double * | matrix1, | ||
| unsigned int | Mrows, | ||
| unsigned int | Mcols | ||
| ) |
Multiplies two matrices and returns the result as a new matrix.
| matrix0 | The first matrix, stored as a 1D array in row-major order. |
| Nrows | The number of rows in the first matrix. |
| Ncols | The number of columns in the first matrix. |
| matrix1 | The second matrix, stored as a 1D array in row-major order. |
| Mrows | The number of rows in the second matrix. |
| Mcols | The number of columns in the second matrix. |
| int shiftHalf | ( | size_t | value, |
| size_t | ArrayLength | ||
| ) |
Shifts a value by half the array length, wrapping around.
| value | The value to shift. |
| ArrayLength | The length of the array. |
| void transpone | ( | double * | arr, |
| unsigned int | Nrows, | ||
| unsigned int | Ncols | ||
| ) |
Transposes a matrix in-place.
| arr | The matrix to transpose, stored as a 1D array in row-major order. |
| Nrows | The number of rows in the original matrix. |
| Ncols | The number of columns in the original matrix. |