This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
addition of gsl_combination_memcpy
- From: Mario Pernici <Mario dot Pernici at mi dot infn dot it>
- To: gsl-discuss at sources dot redhat dot com
- Date: Tue, 18 Mar 2003 15:39:31 +0100 (CET)
- Subject: addition of gsl_combination_memcpy
gsl version: 1.3
Red Hat 7.3
gcc version 2.96
Dear Sirs,
I propose, in analogy with gsl_permutation_memcpy, the addition of
gsl_combination_memcpy (I use it in Ruby binding to gsl).
Best Regards
Mario Pernici
==============================================
//( declaration in combination/gsl_combination.h)
int gsl_combination_memcpy (gsl_combination * dest, const gsl_combination
* src);
===========================================
//( definition in combination/combination.c)
int
gsl_combination_memcpy (gsl_combination * dest,
const gsl_combination * src)
{
const size_t src_n = src->n;
const size_t src_k = src->k;
const size_t dest_n = dest->n;
const size_t dest_k = dest->k;
if (src_n != dest_n || src_k != dest_k)
{
GSL_ERROR ("combination lengths are not equal", GSL_EBADLEN);
}
{
size_t j;
for (j = 0; j < src_n; j++)
{
dest->data[j] = src->data[j];
}
}
return GSL_SUCCESS;
}
===================================================
//(Example)
#include <stdio.h>
#include <gsl/gsl_combination.h>
int main (void)
{
gsl_combination *c1, *c2;
c1 = gsl_combination_calloc (4, 3);
c2 = gsl_combination_calloc (4, 3);
gsl_combination_next(c1);
gsl_combination_memcpy(c2,c1);
do {
printf("{");
gsl_combination_fprintf (stdout, c2, " %u");
printf(" }\n");
}
while (gsl_combination_next(c2) == GSL_SUCCESS);
gsl_combination_free(c2);
return 0;
}
============================================