addition of gsl_combination_memcpy

Mario Pernici Mario.Pernici@mi.infn.it
Tue Mar 18 15:09:00 GMT 2003


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;
}
============================================








More information about the Gsl-discuss mailing list