MS_GENFACTMULT(3)
π MS_GENFACTMULT β generate SEED sample rate factor and multiplier π
okay bestie, welcome to the <libmseed.h> corner of the library, this page lives in section 3 (library functions, iykyk) and it's literally about turning a lil sample rate into the exact pair of numbers SEED headers are obsessed with. let's go π¦
β¨ SYNOPSIS β¨
#include <libmseed.h>
int ms_genfactmult ( double samprate, int16_t *factor,
int16_t *multiplier );
int ms_ratapprox ( double real, int *num, int *den,
int maxval, double precision );
πΈ DESCRIPTION πΈ
so ms_genfactmult is the main character here: it generates an appropriate SEED sample rate factor and multiplier pair from a double precision sample rate. periodt. π
and here's the vibe check on samprate: if it's positive it's expected to represent a rate in samples/second, but if it's negative it's expected to represent a period in seconds/sample. yes, the sign is doing the talking. π
non-integer sample rates and periods are supported between 32767.0 and 1/32767.0. and if you try to hand it a non-integer rate or period outside that range? nope. an error will be returned. not me getting rejected by the range check π
integer sample rates and periods are supported between 1 and the maximum possible value (32767 * 32767). values from 1 to 32767 are represented directly, super simple, no drama. values larger than 32767 get factored, and they're represented exactly when possible and approximated otherwise β and the discrepancy becomes larger as the values reach the maximum possible value. so like, the closer you get to the limit, the more it's giving "close enough β¨". highkey important to know.
and why are factor and multiplier int16_t?? because that is the integer size needed for the fixed section of the SEED data header. the format said 16 bits and the format got 16 bits. iconic behavior tbh. π
now, ms_ratapprox is the supporting character that eats every single time: it finds an approximate rational number for a real through continued fraction expansion. given a double precision real, the routine tries to find a rational in numerator (num) and denominator (den) form whose absolute values are not larger than maxval while trying to reach a specified precision. chef's kiss, math girlies rise π§
β RETURN VALUES β
ms_genfactmultβ returns0on success, and-1when the value is outside of the supported range or on error. so like, zero is the slay, negative one is the "we don't know her". πms_ratapproxβ returns the number of iterations performed. that's it, that's the tea. π
π AUTHOR π
Chad Trabant IRIS Data Management Center
reminder bestie: the factor/multiplier pair isint16_tbecause the SEED fixed header demands it, and out-of-range non-integer rates/periods are a hard error, not a vibe. do not test that boundary unless you enjoy-1. π
okay that's the whole page, you understood it perfectly, I'm so proud of you π«Άβ¨ this was Libmseed API, dated 2016/10/07, and it's the MS_GENFACTMULT(3) manual page β now go generate some factors and multipliers, you've got this ππ
π¦ where this page comes from
- debian bookworm: libmseed-doc 2.19.8-1 Β· LGPL-3.0-or-later
- debian trixie: libmseed-doc 2.19.8-1 Β· LGPL-3.0-or-later
- fedora 43: libmseed-devel 2.19.5-21.fc43 Β· LGPL-3.0-or-later
- fedora 43: libmseed-devel 2.19.5-21.fc43 Β· LGPL-3.0-or-later
- fedora 44: libmseed-devel 2.19.5-22.fc44 Β· LGPL-3.0-or-later
- fedora 44: libmseed-devel 2.19.5-22.fc44 Β· LGPL-3.0-or-later
- ubuntu jammy: libmseed-doc 2.19.6-3 Β· LGPL-3.0-or-later
- ubuntu noble: libmseed-doc 2.19.8-1ubuntu2 Β· LGPL-3.0-or-later
- ubuntu questing: libmseed-doc 2.19.8-1ubuntu2
- ubuntu resolute: libmseed-doc 2.19.8-1ubuntu3 Β· LGPL-3.0-or-later
- ubuntu stonking: libmseed-doc 2.19.8-1ubuntu3 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms