;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "gsl/gsl-config")



#? *** aux_convert

;; dummy function that adds GSL C header files in C file
(eval `(de dummy_aux_convert () ,gsl-cpheader-cmd ()))

#? * (dummy_aux_convert)


#? * (idx8u_gsl_vector_uchar <lmat> <gvec>)
#? * (idx8s_gsl_vector_char <lmat> <gvec>)
#? * (idx16s_gsl_vector_short <lmat> <gvec>)
#? * (idx32s_gsl_vector_int <lmat> <gvec>)
#? * (idx32f_gsl_vector_float <lmat> <gvec>)
#? * (idx64f_gsl_vector <lmat> <gvec>)
#? * (idx32f_gsl_vector_complex_float <lmat> <gvec>)
#? * (idx64f_gsl_vector_complex <lmat> <gvec>)
#? * (gsl_vector_uchar_idx8u <gvec> <lmat>)
#? * (gsl_vector_char_idx8s <gvec> <lmat>)
#? * (gsl_vector_short_idx16s <gvec> <lmat>)
#? * (gsl_vector_int_idx32s <gvec> <lmat>)
#? * (gsl_vector_float_idx32f <gvec> <lmat>)
#? * (gsl_vector_idx64f <gvec> <lmat>)
#? * (gsl_vector_complex_float_idx32f <gvec> <lmat>)
#? * (gsl_vector_complex_idx64f <gvec> <lmat>)
#? * (idx8u_gsl_matrix_uchar <lmat> <gmat>)
#? * (idx8s_gsl_matrix_char <lmat> <gmat>)
#? * (idx16s_gsl_matrix_short <lmat> <gmat>)
#? * (idx32s_gsl_matrix_int <lmat> <gmat>)
#? * (idx32f_gsl_matrix_float <lmat> <gmat>)
#? * (idx64f_gsl_matrix <lmat> <gmat>)
#? * (idx32f_gsl_matrix_complex_float <lmat> <gmat>)
#? * (idx64f_gsl_matrix_complex <lmat> <gmat>)
#? * (gsl_matrix_uchar_idx8u <gmat> <lmat>)
#? * (gsl_matrix_char_idx8s <gmat> <lmat>)
#? * (gsl_matrix_short_idx16s <gmat> <lmat>)
#? * (gsl_matrix_int_idx32s <gmat> <lmat>)
#? * (gsl_matrix_float_idx32f <gmat> <lmat>)
#? * (gsl_matrix_idx64f <gmat> <lmat>)
#? * (gsl_matrix_complex_float_idx32f <gmat> <lmat>)
#? * (gsl_matrix_complex_idx64f <gmat> <lmat>)

;; ********************************************************


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;       convert  idx  to  gsl_vector 
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(de idx8u_gsl_vector_uchar (lmat  gvec)
    ((-idx1- (-ubyte-)) lmat)
    ((-gptr- "gsl_vector_uchar *") gvec)
    #{ {
    unsigned char * matptr;
    unsigned char * vecptr;
    int  rowbytes;

    rowbytes = sizeof(unsigned char);
    gsl_vector_uchar_free($gvec);
    $gvec = gsl_vector_uchar_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat, unsigned char)
           matptr = IDX_PTR( &tmp, unsigned char);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat, unsigned char)
    } #}
    ())

(de idx8s_gsl_vector_char (lmat  gvec)
    ((-idx1- (-byte-)) lmat)
    ((-gptr- "gsl_vector_char *") gvec)
    #{ {
    char * matptr;
    char * vecptr;
    int  rowbytes;

    rowbytes = sizeof( char);
    gsl_vector_char_free($gvec);
    $gvec = gsl_vector_char_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  char)
           matptr = IDX_PTR( &tmp,  char);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  char)
    } #}
    ())


(de idx16s_gsl_vector_short (lmat  gvec)
    ((-idx1- (-short-)) lmat)
    ((-gptr- "gsl_vector_short *") gvec)
    #{ {
    short * matptr;
    short * vecptr;
    int  rowbytes;

    rowbytes = sizeof( short);
    gsl_vector_short_free($gvec);
    $gvec = gsl_vector_short_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  short)
           matptr = IDX_PTR( &tmp,  short);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  short)
    } #}
    ())

(de idx32s_gsl_vector_int (lmat  gvec)
    ((-idx1- (-int-)) lmat)
    ((-gptr- "gsl_vector_int *") gvec)
    #{ {
    int * matptr;
    int * vecptr;
    int  rowbytes;

    rowbytes = sizeof( int);
    gsl_vector_int_free($gvec);
    $gvec = gsl_vector_int_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  int)
           matptr = IDX_PTR( &tmp,  int);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  int)
    } #}
    ())


(de idx32f_gsl_vector_float (lmat  gvec)
    ((-idx1- (-float-)) lmat)
    ((-gptr- "gsl_vector_float *") gvec)
    #{ {
    float * matptr;
    float * vecptr;
    int  rowbytes;

    rowbytes = sizeof( float);
    gsl_vector_float_free($gvec);
    $gvec = gsl_vector_float_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())


(de idx64f_gsl_vector (lmat  gvec)
    ((-idx1- (-double-)) lmat)
    ((-gptr- "gsl_vector *") gvec)
    #{ {
    double * matptr;
    double * vecptr;
    int  rowbytes;

    rowbytes = sizeof( double);
    gsl_vector_free($gvec);
    $gvec = gsl_vector_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())


(de idx32f_gsl_vector_complex_float (lmat  gvec)
    ((-idx2- (-float-)) lmat)
    ((-gptr- "gsl_vector_complex_float *") gvec)
    #{ {
    float * matptr;
    float * vecptr;
    int  rowbytes;

    rowbytes = 2*sizeof( float);
    gsl_vector_complex_float_free($gvec);
    $gvec = gsl_vector_complex_float_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}

    ())

(de idx64f_gsl_vector_complex (lmat  gvec)
    ((-idx2- (-double-)) lmat)
    ((-gptr- "gsl_vector_complex *") gvec)
    #{ {
    double * matptr;
    double * vecptr;
    int  rowbytes;

    rowbytes = 2*sizeof( double);
    gsl_vector_complex_free($gvec);
    $gvec = gsl_vector_complex_alloc( Midx_dim($lmat,0) );

    vecptr =  $gvec->data;
    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)vecptr, (void *)matptr, rowbytes);
	   vecptr ++;
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;       convert  gsl_vector  to  idx 
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(de gsl_vector_uchar_idx8u (  gvec lmat)
    ((-gptr- "gsl_vector_uchar *") gvec)
    ((-idx1- (-ubyte-)) lmat)
    #{ {
    unsigned char * matptr;
    unsigned char * vecptr;
    int  rowbytes;

    rowbytes = sizeof(unsigned char);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat, unsigned char)
           matptr = IDX_PTR( &tmp, unsigned char);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat, unsigned char)
    } #}
    ())

(de gsl_vector_char_idx8s (  gvec lmat)
    ((-gptr- "gsl_vector_char *") gvec)
    ((-idx1- (-byte-)) lmat)
   #{ {
    char * matptr;
    char * vecptr;
    int  rowbytes;

    rowbytes = sizeof(char);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  char)
           matptr = IDX_PTR( &tmp,  char);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat,  char)
    } #}
    ())


(de gsl_vector_short_idx16s (  gvec lmat)
    ((-gptr- "gsl_vector_short *") gvec)
    ((-idx1- (-short-)) lmat)
    #{ {
    short * matptr;
    short * vecptr;
    int  rowbytes;

    rowbytes = sizeof(short);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  short)
           matptr = IDX_PTR( &tmp,  short);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat,  short)
    } #}
    ())

(de gsl_vector_int_idx32s (  gvec lmat)
    ((-gptr- "gsl_vector_int *") gvec)
    ((-idx1- (-int-)) lmat)
    #{ {
    int * matptr;
    int * vecptr;
    int  rowbytes;

    rowbytes = sizeof(int);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  int)
           matptr = IDX_PTR( &tmp,  int);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat,  int)
    } #}
    ())


(de gsl_vector_float_idx32f (  gvec lmat)
    ((-gptr- "gsl_vector_float *") gvec)
    ((-idx1- (-float-)) lmat)
    #{ {
    float * matptr;
    float * vecptr;
    int  rowbytes;

    rowbytes = sizeof(float);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())


(de gsl_vector_idx64f (  gvec lmat)
    ((-gptr- "gsl_vector *") gvec)
    ((-idx1- (-double-)) lmat)
    #{ {
    double * matptr;
    double * vecptr;
    int  rowbytes;

    rowbytes = sizeof(double);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += $gvec->stride;
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())


(de gsl_vector_complex_float_idx32f ( gvec lmat)
    ((-gptr- "gsl_vector_complex_float *") gvec)
    ((-idx2- (-float-)) lmat)
    #{ {
    float * matptr;
    float * vecptr;
    int  rowbytes;

    rowbytes = 2*sizeof(float);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_dim($lmat,1) = 2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += (2*$gvec->stride);
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())

(de gsl_vector_complex_idx64f ( gvec lmat)
    ((-gptr- "gsl_vector_complex *") gvec)
    ((-idx2- (-double-)) lmat)
    #{ {
    double * matptr;
    double * vecptr;
    int  rowbytes;

    rowbytes = 2*sizeof(double);
    vecptr =  $gvec->data;

    Midx_dim($lmat,0) = $gvec->size;
    Midx_dim($lmat,1) = 2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)matptr, (void *)vecptr, rowbytes);
	   vecptr += (2*$gvec->stride);
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;       convert  idx  to  gsl_matrix
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(de idx8u_gsl_matrix_uchar (lmat  gmat)
    ((-idx2- (-ubyte-)) lmat)
    ((-gptr- "gsl_matrix_uchar *") gmat)
    #{ {
    unsigned char * matptr;
    unsigned char * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( unsigned char);
    gsl_matrix_uchar_free($gmat);
    $gmat = gsl_matrix_uchar_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  unsigned char)
           matptr = IDX_PTR( &tmp,  unsigned char);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat, unsigned char)
    } #}
    ())

(de idx8s_gsl_matrix_char (lmat  gmat)
    ((-idx2- (-byte-)) lmat)
    ((-gptr- "gsl_matrix_char *") gmat)
    #{ {
    char * matptr;
    char * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( char);
    gsl_matrix_char_free($gmat);
    $gmat = gsl_matrix_char_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  char)
           matptr = IDX_PTR( &tmp,  char);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  char)
    } #}
    ())


(de idx16s_gsl_matrix_short (lmat  gmat)
    ((-idx2- (-short-)) lmat)
    ((-gptr- "gsl_matrix_short *") gmat)
    #{ {
    short * matptr;
    short * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( short);
    gsl_matrix_short_free($gmat);
    $gmat = gsl_matrix_short_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  short)
           matptr = IDX_PTR( &tmp,  short);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  short)
    } #}
    ())

(de idx32s_gsl_matrix_int (lmat  gmat)
    ((-idx2- (-int-)) lmat)
    ((-gptr- "gsl_matrix_int *") gmat)
    #{ {
    int * matptr;
    int * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( int);
    gsl_matrix_int_free($gmat);
    $gmat = gsl_matrix_int_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  int)
           matptr = IDX_PTR( &tmp,  int);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  int)
    } #}
    ())


(de idx32f_gsl_matrix_float (lmat  gmat)
    ((-idx2- (-float-)) lmat)
    ((-gptr- "gsl_matrix_float *") gmat)
    #{ {
    float * matptr;
    float * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( float);
    gsl_matrix_float_free($gmat);
    $gmat = gsl_matrix_float_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())


(de idx64f_gsl_matrix (lmat  gmat)
    ((-idx2- (-double-)) lmat)
    ((-gptr- "gsl_matrix *") gmat)
    #{ {
    double * matptr;
    double * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * sizeof( double);
    gsl_matrix_free($gmat);
    $gmat = gsl_matrix_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())


(de idx32f_gsl_matrix_complex_float (lmat  gmat)
    ((-idx3- (-float-)) lmat)
    ((-gptr- "gsl_matrix_complex_float *") gmat)
    #{ {
    float * matptr;
    float * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * 2 * sizeof( float);
    gsl_matrix_complex_float_free($gmat);
    $gmat = gsl_matrix_complex_float_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += (2*$gmat->tda);
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())

(de idx64f_gsl_matrix_complex (lmat  gmat)
    ((-idx3- (-double-)) lmat)
    ((-gptr- "gsl_matrix_complex *") gmat)
    #{ {
    double * matptr;
    double * gslptr;
    int  rowbytes;

    rowbytes = Midx_dim($lmat,1) * 2 * sizeof( double);
    gsl_matrix_complex_free($gmat);
    $gmat = gsl_matrix_complex_alloc( Midx_dim($lmat,0) , Midx_dim($lmat,1) );

    gslptr =  $gmat->data;
    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)gslptr, (void *)matptr, rowbytes);
	   gslptr += (2*$gmat->tda);
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;       convert  gsl_matrix  to  idx
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(de gsl_matrix_uchar_idx8u (  gmat lmat)
    ((-gptr- "gsl_matrix_uchar *") gmat)
    ((-idx2- (-ubyte-)) lmat)
    #{ {
    unsigned char* matptr;
    unsigned char* gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(unsigned char);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  unsigned char)
           matptr = IDX_PTR( &tmp,  unsigned char);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  unsigned char)
    } #}
    ())

(de gsl_matrix_char_idx8s (  gmat lmat)
    ((-gptr- "gsl_matrix_char *") gmat)
    ((-idx2- (-byte-)) lmat)
    #{ {
    char * matptr;
    char * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(char);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  char)
           matptr = IDX_PTR( &tmp,  char);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  char)
    } #}
    ())


(de gsl_matrix_short_idx16s (  gmat lmat)
    ((-gptr- "gsl_matrix_short *") gmat)
    ((-idx2- (-short-)) lmat)
    #{ {
    short * matptr;
    short * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(short);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  short)
           matptr = IDX_PTR( &tmp,  short);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  short)
    } #}
    ())

(de gsl_matrix_int_idx32s (  gmat lmat)
    ((-gptr- "gsl_matrix_int *") gmat)
    ((-idx2- (-int-)) lmat)
    #{ {
    int * matptr;
    int * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(int);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  int)
           matptr = IDX_PTR( &tmp,  int);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  int)
    } #}
    ())


(de gsl_matrix_float_idx32f (  gmat lmat)
    ((-gptr- "gsl_matrix_float *") gmat)
    ((-idx2- (-float-)) lmat)
    #{ {
    float * matptr;
    float * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(float);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())


(de gsl_matrix_idx64f (  gmat lmat)
    ((-gptr- "gsl_matrix *") gmat)
    ((-idx2- (-double-)) lmat)
    #{ {
    double * matptr;
    double * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * sizeof(double);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += $gmat->tda;
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())


(de gsl_matrix_complex_float_idx32f ( gmat lmat)
    ((-gptr- "gsl_matrix_complex_float *") gmat)
    ((-idx3- (-float-)) lmat)
    #{ {
    float * matptr;
    float * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * 2 * sizeof(float);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  float)
           matptr = IDX_PTR( &tmp,  float);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += (2*$gmat->tda);
    Midx_end_bloop1( tmp, $lmat,  float)
    } #}
    ())

(de gsl_matrix_complex_idx64f ( gmat lmat)
    ((-gptr- "gsl_matrix_complex *") gmat)
    ((-idx3- (-double-)) lmat)
    #{ {
    double * matptr;
    double * gslptr;
    int  rowbytes;

    rowbytes = $gmat->size2 * 2 * sizeof(double);
    gslptr =   $gmat->data;

    Midx_dim($lmat,0) = $gmat->size1;
    Midx_dim($lmat,1) = $gmat->size2;
    Midx_update_mod_from_dim($lmat);

    Midx_begin_bloop1( tmp, $lmat,  double)
           matptr = IDX_PTR( &tmp,  double);
	   memcpy((void *)matptr, (void *)gslptr, rowbytes);
	   gslptr += (2*$gmat->tda);
    Midx_end_bloop1( tmp, $lmat,  double)
    } #}
    ())



;; ********************************************************

(dhc-make ()

  dummy_aux_convert
  idx8u_gsl_vector_uchar
  idx8s_gsl_vector_char
  idx16s_gsl_vector_short
  idx32s_gsl_vector_int
  idx32f_gsl_vector_float
  idx64f_gsl_vector
  idx32f_gsl_vector_complex_float
  idx64f_gsl_vector_complex
  gsl_vector_uchar_idx8u
  gsl_vector_char_idx8s
  gsl_vector_short_idx16s
  gsl_vector_int_idx32s
  gsl_vector_float_idx32f
  gsl_vector_idx64f
  gsl_vector_complex_float_idx32f
  gsl_vector_complex_idx64f
  idx8u_gsl_matrix_uchar
  idx8s_gsl_matrix_char
  idx16s_gsl_matrix_short
  idx32s_gsl_matrix_int
  idx32f_gsl_matrix_float
  idx64f_gsl_matrix
  idx32f_gsl_matrix_complex_float
  idx64f_gsl_matrix_complex
  gsl_matrix_uchar_idx8u
  gsl_matrix_char_idx8s
  gsl_matrix_short_idx16s
  gsl_matrix_int_idx32s
  gsl_matrix_float_idx32f
  gsl_matrix_idx64f
  gsl_matrix_complex_float_idx32f
  gsl_matrix_complex_idx64f
)
