MS_GENFACTMULT(3)

DESCRIPTION
Generate SEED sample rate factor and multiplier

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
ms_genfactmult generates an appropriate SEED sample rate factor and multiplier pair from a double precision sample rate (samprate). The factor and multiplier are cast as int16_t because that is the integer size needed for the fixed section of the SEED data header. If the input sample rate is already integer (within 0.000001) it will be placed into the factor and the multiplier will be set to 1. An error will be produced if the sample rate is very high (> 32727) or negative. ms_ratapprox 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.

RETURN VALUES
ms_genfactmult returns 0 on success and -1 on error. ms_ratapprox returns the number of iterations performed.

AUTHOR
Chad Trabant
IRIS Data Management Center