.TH MS_GENFACTMULT 3 2016/10/07 "Libmseed API" .SH NAME ms_genfactmult - Generate SEED sample rate factor and multiplier .SH SYNOPSIS .nf .B #include .BI "int \fBms_genfactmult\fP ( double " samprate ", int16_t *" factor ", .BI " int16_t *" multiplier " );" .BI "int \fBms_ratapprox\fP ( double " real ", int *" num ", int *" den ", .BI " int " maxval ", double " precision " );" .fi .SH DESCRIPTION \fBms_genfactmult\fP generates an appropriate SEED sample rate \fIfactor\fP and \fImultiplier\fP pair from a double precision sample rate. If \fIsamprate\fP is positive it is expected to represent a rate in samples/second, if negative is is expected to represent a period in seconds/sample. Non-integer sample rates and periods are supported between 32767.0 and 1/32767.0. An error will be returned for non-integer rates and periods outside this range. Integer sample rates and periods are supported between 1 and the maximum possible value (32767 * 32767). Values from 1 to 32767 are represented directly. Values larger than 32767 are factored and represented exactly when possible and approximated otherwise, with the discrepency becoming larger as the values reach the maximum possible value. The factor and multiplier are int16_t because that is the integer size needed for the fixed section of the SEED data header. \fBms_ratapprox\fP finds an approximate rational number for a real through continued fraction expansion. Given a double precision \fIreal\fP the routine tries to find a rational in numerator (\fInum\fP) and denominator (\fIden\fP) form whose absolute values are not larger than \fImaxval\fP while trying to reach a specified \fIprecision\fP. .SH RETURN VALUES \fBms_genfactmult\fP returns 0 on success and -1 when value is outside of the supported range or error. \fBms_ratapprox\fP returns the number of iterations performed. .SH AUTHOR .nf Chad Trabant IRIS Data Management Center .fi