genomicSimulationC 0.2.6
|
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... | |
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.
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.
result | pointer to the gsc_DecimalMatrix to whose first row both products will be added. |
amat | pointer to the first gsc_DecimalMatrix. Multiply this to avec. |
avec | a vector of doubles, assumed to be the same length as amat has columns. Multiplied to amat . |
bmat | pointer to the second gsc_DecimalMatrix. Multiply this to bvec. |
bvec | a second vector of doubles, assumed to be the same length as bmat has columns. Multiplied to bmat . |
Definition at line 4454 of file sim-operations.c.
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.
result | pointer to the gsc_DecimalMatrix to whose first row the product a*b will be added. |
a | pointer to the gsc_DecimalMatrix. Multiply this to b. |
b | a vector of doubles, assumed to be the same length as a has columns. Multiplied to a. |
Definition at line 4401 of file sim-operations.c.
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.
r | the number of rows/first index for the new matrix. |
c | the number of columns/second index for the new matrix. |
Definition at line 4371 of file sim-operations.c.
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.
rng | random number generator source |
lambda | the parameter of the Poisson distribution. Corresponds to both expected value and variance of the distribution. |
Definition at line 195 of file sim-operations.c.