genomicSimulationC 0.2.6
Functions
Mathematical functions

For mathematical and statistical operations as required by the package. More...

Functions

int gsc_randpoi (rnd_pcg_t *rng, double lambda)
 Generates randomly a number from the Poisson distribution with parameter lambda, using the Knuth approach. More...
 
gsc_DecimalMatrix gsc_generate_zero_dmatrix (const size_t r, const size_t c)
 Generates a matrix of c columns, r rows with all 0. More...
 
int gsc_add_matrixvector_product_to_dmatrix (gsc_DecimalMatrix *result, const gsc_DecimalMatrix *a, const double *b)
 Multiply a gsc_DecimalMatrix to a vector, and add that product to the first column of a provided gsc_DecimalMatrix. More...
 
int gsc_add_doublematrixvector_product_to_dmatrix (gsc_DecimalMatrix *result, const gsc_DecimalMatrix *amat, const double *avec, const gsc_DecimalMatrix *bmat, const double *bvec)
 Multiply two sets of a gsc_DecimalMatrix and vector, and add both products to the first column of a provided gsc_DecimalMatrix. More...
 

Detailed Description

For mathematical and statistical operations as required by the package.

Includes matrix operations defined on a gsc_DecimalMatrix struct, and draws from certain random distributions.

Function Documentation

◆ gsc_add_doublematrixvector_product_to_dmatrix()

int gsc_add_doublematrixvector_product_to_dmatrix ( gsc_DecimalMatrix result,
const gsc_DecimalMatrix amat,
const double *  avec,
const gsc_DecimalMatrix bmat,
const double *  bvec 
)

Multiply two sets of a gsc_DecimalMatrix and vector, and add both products to the first column of a provided gsc_DecimalMatrix.

Performs the double fused multiply-add operation: result + amat * avec + bmat * bvec and saves it to result.

The matrices amat and bmat must have the same dimensions, and must have the same number of rows as result has columns.

Assumes that the vectors have the same number of entries as their matrices have columns. That is, assumes the dimensions are valid for multiplication.

Parameters
resultpointer to the gsc_DecimalMatrix to whose first row both products will be added.
amatpointer to the first gsc_DecimalMatrix. Multiply this to avec.
aveca vector of doubles, assumed to be the same length as amat has columns. Multiplied to amat.
bmatpointer to the second gsc_DecimalMatrix. Multiply this to bvec.
bveca second vector of doubles, assumed to be the same length as bmat has columns. Multiplied to bmat.
Returns
0 on success, nonzero on failure.

Definition at line 4454 of file sim-operations.c.

+ Here is the caller graph for this function:

◆ gsc_add_matrixvector_product_to_dmatrix()

int gsc_add_matrixvector_product_to_dmatrix ( gsc_DecimalMatrix result,
const gsc_DecimalMatrix a,
const double *  b 
)

Multiply a gsc_DecimalMatrix to a vector, and add that product to the first column of a provided gsc_DecimalMatrix.

Performs the fused multiply-add operation: result + a * b and saves it to result.

Assumes that the vector b has the same number of entries as a has columns. That is, assumes the dimensions are valid for multiplication.

Parameters
resultpointer to the gsc_DecimalMatrix to whose first row the product a*b will be added.
apointer to the gsc_DecimalMatrix. Multiply this to b.
ba vector of doubles, assumed to be the same length as a has columns. Multiplied to a.
Returns
0 on success, nonzero on failure.

Definition at line 4401 of file sim-operations.c.

+ Here is the caller graph for this function:

◆ gsc_generate_zero_dmatrix()

gsc_DecimalMatrix gsc_generate_zero_dmatrix ( const size_t  r,
const size_t  c 
)

Generates a matrix of c columns, r rows with all 0.

Parameters
rthe number of rows/first index for the new matrix.
cthe number of columns/second index for the new matrix.
Returns
a gsc_DecimalMatrix with r rows, c cols, and a matrix of the correct size, with all values zeroed.

Definition at line 4371 of file sim-operations.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gsc_randpoi()

int gsc_randpoi ( rnd_pcg_t *  rng,
double  lambda 
)

Generates randomly a number from the Poisson distribution with parameter lambda, using the Knuth approach.

Returns 0 if parameter is invalid (<= 0)

This approach is known to run slow for larger values of lambda.

Parameters
rngrandom number generator source
lambdathe parameter of the Poisson distribution. Corresponds to both expected value and variance of the distribution.
Returns
a random integer generated from the Poisson distribution with parameter lambda.

Definition at line 195 of file sim-operations.c.

+ Here is the caller graph for this function: