home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / mesch12a.zip / zmemory.c < prev    next >
C/C++ Source or Header  |  1994-01-13  |  16KB  |  715 lines

  1.  
  2. /**************************************************************************
  3. **
  4. ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
  5. **
  6. **                 Meschach Library
  7. ** 
  8. ** This Meschach Library is provided "as is" without any express 
  9. ** or implied warranty of any kind with respect to this software. 
  10. ** In particular the authors shall not be liable for any direct, 
  11. ** indirect, special, incidental or consequential damages arising 
  12. ** in any way from use of the software.
  13. ** 
  14. ** Everyone is granted permission to copy, modify and redistribute this
  15. ** Meschach Library, provided:
  16. **  1.  All copies contain this copyright notice.
  17. **  2.  All modified copies shall carry a notice stating who
  18. **      made the last modification and the date of such modification.
  19. **  3.  No charge is made for this software or works derived from it.  
  20. **      This clause shall not be construed as constraining other software
  21. **      distributed on the same medium as this software, nor is a
  22. **      distribution fee considered a charge.
  23. **
  24. ***************************************************************************/
  25.  
  26.  
  27. /* Memory allocation and de-allocation for complex matrices and vectors */
  28.  
  29. #include    <stdio.h>
  30. #include    "zmatrix.h"
  31.  
  32. static    char    rcsid[] = "$Id: zmemory.c,v 1.1 1994/01/13 04:21:55 des Exp $";
  33.  
  34.  
  35.  
  36. /* zv_zero -- zeros all entries of a complex vector
  37.    -- uses __zzero__() */
  38. ZVEC    *zv_zero(x)
  39. ZVEC    *x;
  40. {
  41.    if ( ! x )
  42.      error(E_NULL,"zv_zero");
  43.    __zzero__(x->ve,x->dim);
  44.    
  45.    return x;
  46. }
  47.  
  48. /* zm_zero -- zeros all entries of a complex matrix
  49.    -- uses __zzero__() */
  50. ZMAT    *zm_zero(A)
  51. ZMAT    *A;
  52. {
  53.    int        i;
  54.    
  55.    if ( ! A )
  56.      error(E_NULL,"zm_zero");
  57.    for ( i = 0; i < A->m; i++ )
  58.      __zzero__(A->me[i],A->n);
  59.    
  60.    return A;
  61. }
  62.  
  63. /* zm_get -- gets an mxn complex matrix (in ZMAT form) */
  64. ZMAT    *zm_get(m,n)
  65. int    m,n;
  66. {
  67.    ZMAT    *matrix;
  68.    u_int    i;
  69.    
  70.    if (m < 0 || n < 0)
  71.      error(E_NEG,"zm_get");
  72.  
  73.    if ((matrix=NEW(ZMAT)) == (ZMAT *)NULL )
  74.      error(E_MEM,"zm_get");
  75.    else if (mem_info_is_on()) {
  76.       mem_bytes(TYPE_ZMAT,0,sizeof(ZMAT));
  77.       mem_numvar(TYPE_ZMAT,1);
  78.    }
  79.    
  80.    matrix->m = m;        matrix->n = matrix->max_n = n;
  81.    matrix->max_m = m;    matrix->max_size = m*n;
  82. #ifndef SEGMENTED
  83.    if ((matrix->base = NEW_A(m*n,complex)) == (complex *)NULL )
  84.    {
  85.       free(matrix);
  86.       error(E_MEM,"zm_get");
  87.    }
  88.    else if (mem_info_is_on()) {
  89.       mem_bytes(TYPE_ZMAT,0,m*n*sizeof(complex));
  90.    }
  91. #else
  92.    matrix->base = (complex *)NULL;
  93. #endif
  94.    if ((matrix->me = (complex **)calloc(m,sizeof(complex *))) == 
  95.        (complex **)NULL )
  96.    {    free(matrix);    free(matrix->base);
  97.     error(E_MEM,"zm_get");
  98.      }
  99.    else if (mem_info_is_on()) {
  100.       mem_bytes(TYPE_ZMAT,0,m*sizeof(complex *));
  101.    }
  102. #ifndef SEGMENTED
  103.    /* set up pointers */
  104.    for ( i=0; i<m; i++ )
  105.      matrix->me[i] = &(matrix->base[i*n]);
  106. #else
  107.    for ( i = 0; i < m; i++ )
  108.      if ( (matrix->me[i]=NEW_A(n,Real)) == (Real *)NULL )
  109.        error(E_MEM,"zm_get");
  110.      else if (mem_info_is_on()) {
  111.     mem_bytes(TYPE_ZMAT,0,n*sizeof(Real));
  112.      }
  113. #endif
  114.    
  115.    return (matrix);
  116. }
  117.  
  118.  
  119. /* zv_get -- gets a ZVEC of dimension 'dim'
  120.    -- Note: initialized to zero */
  121. ZVEC    *zv_get(size)
  122. int    size;
  123. {
  124.    ZVEC    *vector;
  125.  
  126.    if (size < 0)
  127.      error(E_NEG,"zv_get");
  128.  
  129.    if ((vector=NEW(ZVEC)) == (ZVEC *)NULL )
  130.      error(E_MEM,"zv_get");
  131.    else if (mem_info_is_on()) {
  132.       mem_bytes(TYPE_ZVEC,0,sizeof(ZVEC));
  133.       mem_numvar(TYPE_ZVEC,1);
  134.    }
  135.    vector->dim = vector->max_dim = size;
  136.    if ((vector->ve=NEW_A(size,complex)) == (complex *)NULL )
  137.    {
  138.       free(vector);
  139.       error(E_MEM,"zv_get");
  140.    }
  141.    else if (mem_info_is_on()) {
  142.       mem_bytes(TYPE_ZVEC,0,size*sizeof(complex));
  143.    }
  144.    return (vector);
  145. }
  146.  
  147. /* zm_free -- returns ZMAT & asoociated memory back to memory heap */
  148. int    zm_free(mat)
  149. ZMAT    *mat;
  150. {
  151. #ifdef SEGMENTED
  152.    int    i;
  153. #endif
  154.    
  155.    if ( mat==(ZMAT *)NULL || (int)(mat->m) < 0 ||
  156.        (int)(mat->n) < 0 )
  157.      /* don't trust it */
  158.      return (-1);
  159.    
  160. #ifndef SEGMENTED
  161.    if ( mat->base != (complex *)NULL ) {
  162.       if (mem_info_is_on()) {
  163.      mem_bytes(TYPE_ZMAT,mat->max_m*mat->max_n*sizeof(complex),0);
  164.       }       
  165.       free((char *)(mat->base));
  166.    }
  167. #else
  168.    for ( i = 0; i < mat->m; i++ )
  169.      if ( mat->me[i] != (complex *)NULL ) {
  170.     if (mem_info_is_on()) {
  171.        mem_bytes(TYPE_ZMAT,mat->max_n*sizeof(complex),0);
  172.     }
  173.     free((char *)(mat->me[i]));
  174.      }
  175. #endif
  176.    if ( mat->me != (complex **)NULL ) {
  177.       if (mem_info_is_on()) {
  178.      mem_bytes(TYPE_ZMAT,mat->max_m*sizeof(complex *),0);
  179.       }       
  180.       free((char *)(mat->me));
  181.    }
  182.    
  183.    if (mem_info_is_on()) {
  184.       mem_bytes(TYPE_ZMAT,sizeof(ZMAT),0);
  185.       mem_numvar(TYPE_ZMAT,-1);
  186.    }
  187.    free((char *)mat);
  188.    
  189.    return (0);
  190. }
  191.  
  192.  
  193. /* zv_free -- returns ZVEC & asoociated memory back to memory heap */
  194. int    zv_free(vec)
  195. ZVEC    *vec;
  196. {
  197.    if ( vec==(ZVEC *)NULL || (int)(vec->dim) < 0 )
  198.      /* don't trust it */
  199.      return (-1);
  200.    
  201.    if ( vec->ve == (complex *)NULL ) {
  202.       if (mem_info_is_on()) {
  203.      mem_bytes(TYPE_ZVEC,sizeof(ZVEC),0);
  204.      mem_numvar(TYPE_ZVEC,-1);
  205.       }
  206.       free((char *)vec);
  207.    }
  208.    else
  209.    {
  210.       if (mem_info_is_on()) {
  211.      mem_bytes(TYPE_ZVEC,vec->max_dim*sizeof(complex)+
  212.               sizeof(ZVEC),0);
  213.      mem_numvar(TYPE_ZVEC,-1);
  214.       }
  215.       
  216.       free((char *)vec->ve);
  217.       free((char *)vec);
  218.    }
  219.    
  220.    return (0);
  221. }
  222.  
  223.  
  224. /* zm_resize -- returns the matrix A of size new_m x new_n; A is zeroed
  225.    -- if A == NULL on entry then the effect is equivalent to m_get() */
  226. ZMAT    *zm_resize(A,new_m,new_n)
  227. ZMAT    *A;
  228. int    new_m, new_n;
  229. {
  230.    u_int    i, new_max_m, new_max_n, new_size, old_m, old_n;
  231.    
  232.    if (new_m < 0 || new_n < 0)
  233.      error(E_NEG,"zm_resize");
  234.  
  235.    if ( ! A )
  236.      return zm_get(new_m,new_n);
  237.    
  238.    if (new_m == A->m && new_n == A->n)
  239.      return A;
  240.  
  241.    old_m = A->m;    old_n = A->n;
  242.    if ( new_m > A->max_m )
  243.    {    /* re-allocate A->me */
  244.       if (mem_info_is_on()) {
  245.      mem_bytes(TYPE_ZMAT,A->max_m*sizeof(complex *),
  246.               new_m*sizeof(complex *));
  247.       }
  248.  
  249.       A->me = RENEW(A->me,new_m,complex *);
  250.       if ( ! A->me )
  251.     error(E_MEM,"zm_resize");
  252.    }
  253.    new_max_m = max(new_m,A->max_m);
  254.    new_max_n = max(new_n,A->max_n);
  255.    
  256. #ifndef SEGMENTED
  257.    new_size = new_max_m*new_max_n;
  258.    if ( new_size > A->max_size )
  259.    {    /* re-allocate A->base */
  260.       if (mem_info_is_on()) {
  261.      mem_bytes(TYPE_ZMAT,A->max_m*A->max_n*sizeof(complex),
  262.         new_size*sizeof(complex));      
  263.       }
  264.  
  265.       A->base = RENEW(A->base,new_size,complex);
  266.       if ( ! A->base )
  267.     error(E_MEM,"zm_resize");
  268.       A->max_size = new_size;
  269.    }
  270.    
  271.    /* now set up A->me[i] */
  272.    for ( i = 0; i < new_m; i++ )
  273.      A->me[i] = &(A->base[i*new_n]);
  274.    
  275.    /* now shift data in matrix */
  276.    if ( old_n > new_n )
  277.    {
  278.       for ( i = 1; i < min(old_m,new_m); i++ )
  279.     MEM_COPY((char *)&(A->base[i*old_n]),
  280.          (char *)&(A->base[i*new_n]),
  281.          sizeof(complex)*new_n);
  282.    }
  283.    else if ( old_n < new_n )
  284.    {
  285.       for ( i = min(old_m,new_m)-1; i > 0; i-- )
  286.       {   /* copy & then zero extra space */
  287.      MEM_COPY((char *)&(A->base[i*old_n]),
  288.           (char *)&(A->base[i*new_n]),
  289.           sizeof(complex)*old_n);
  290.      __zzero__(&(A->base[i*new_n+old_n]),(new_n-old_n));
  291.       }
  292.       __zzero__(&(A->base[old_n]),(new_n-old_n));
  293.       A->max_n = new_n;
  294.    }
  295.    /* zero out the new rows.. */
  296.    for ( i = old_m; i < new_m; i++ )
  297.      __zzero__(&(A->base[i*new_n]),new_n);
  298. #else
  299.    if ( A->max_n < new_n )
  300.    {
  301.       complex    *tmp;
  302.       
  303.       for ( i = 0; i < A->max_m; i++ )
  304.       {
  305.      if (mem_info_is_on()) {
  306.         mem_bytes(TYPE_ZMAT,A->max_n*sizeof(complex),
  307.              new_max_n*sizeof(complex));
  308.      }
  309.  
  310.      if ( (tmp = RENEW(A->me[i],new_max_n,complex)) == NULL )
  311.        error(E_MEM,"zm_resize");
  312.      else {
  313.         A->me[i] = tmp;
  314.      }
  315.       }
  316.       for ( i = A->max_m; i < new_max_m; i++ )
  317.       {
  318.      if ( (tmp = NEW_A(new_max_n,complex)) == NULL )
  319.        error(E_MEM,"zm_resize");
  320.      else {
  321.         A->me[i] = tmp;
  322.         if (mem_info_is_on()) {
  323.            mem_bytes(TYPE_ZMAT,0,new_max_n*sizeof(complex));
  324.         }
  325.      }
  326.       }
  327.    }
  328.    
  329.    if ( A->max_m < new_m )
  330.    {
  331.       for ( i = A->max_m; i < new_m; i++ )
  332.     if ( (A->me[i] = NEW_A(new_max_n,complex)) == NULL )
  333.       error(E_MEM,"zm_resize");
  334.     else if (mem_info_is_on()) {
  335.        mem_bytes(TYPE_ZMAT,0,new_max*sizeof(complex));
  336.     }
  337.       
  338.    }
  339.    
  340.    if ( old_n < new_n )
  341.    {
  342.       for ( i = 0; i < old_m; i++ )
  343.     __zzero__(&(A->me[i][old_n]),new_n-old_n);
  344.    }
  345.    
  346.    /* zero out the new rows.. */
  347.    for ( i = old_m; i < new_m; i++ )
  348.      __zzero__(A->me[i],new_n);
  349. #endif
  350.    
  351.    A->max_m = new_max_m;
  352.    A->max_n = new_max_n;
  353.    A->max_size = A->max_m*A->max_n;
  354.    A->m = new_m;    A->n = new_n;
  355.    
  356.    return A;
  357. }
  358.  
  359.  
  360. /* zv_resize -- returns the (complex) vector x with dim new_dim
  361.    -- x is set to the zero vector */
  362. ZVEC    *zv_resize(x,new_dim)
  363. ZVEC    *x;
  364. int    new_dim;
  365. {
  366.    if (new_dim < 0)
  367.      error(E_NEG,"zv_resize");
  368.  
  369.    if ( ! x )
  370.      return zv_get(new_dim);
  371.  
  372.    if (new_dim == x->dim)
  373.      return x;
  374.  
  375.    if ( x->max_dim == 0 )    /* assume that it's from sub_zvec */
  376.      return zv_get(new_dim);
  377.    
  378.    if ( new_dim > x->max_dim )
  379.    {
  380.       if (mem_info_is_on()) { 
  381.      mem_bytes(TYPE_ZVEC,x->max_dim*sizeof(complex),
  382.               new_dim*sizeof(complex));
  383.       }
  384.  
  385.       x->ve = RENEW(x->ve,new_dim,complex);
  386.       if ( ! x->ve )
  387.     error(E_MEM,"zv_resize");
  388.       x->max_dim = new_dim;
  389.    }
  390.    
  391.    if ( new_dim > x->dim )
  392.      __zzero__(&(x->ve[x->dim]),new_dim - x->dim);
  393.    x->dim = new_dim;
  394.    
  395.    return x;
  396. }
  397.  
  398.  
  399. /* varying arguments */
  400.  
  401. #ifdef ANSI_C
  402.  
  403. #include <stdarg.h>
  404.  
  405.  
  406. /* To allocate memory to many arguments. 
  407.    The function should be called:
  408.    zv_get_vars(dim,&x,&y,&z,...,NULL);
  409.    where 
  410.      int dim;
  411.      ZVEC *x, *y, *z,...;
  412.      The last argument should be NULL ! 
  413.      dim is the length of vectors x,y,z,...
  414.      returned value is equal to the number of allocated variables
  415.      Other gec_... functions are similar.
  416. */
  417.  
  418. int zv_get_vars(int dim,...) 
  419. {
  420.    va_list ap;
  421.    int i=0;
  422.    ZVEC **par;
  423.    
  424.    va_start(ap, dim);
  425.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  426.       *par = zv_get(dim);
  427.       i++;
  428.    } 
  429.  
  430.    va_end(ap);
  431.    return i;
  432. }
  433.  
  434.  
  435.  
  436. int zm_get_vars(int m,int n,...) 
  437. {
  438.    va_list ap;
  439.    int i=0;
  440.    ZMAT **par;
  441.    
  442.    va_start(ap, n);
  443.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  444.       *par = zm_get(m,n);
  445.       i++;
  446.    } 
  447.  
  448.    va_end(ap);
  449.    return i;
  450. }
  451.  
  452.  
  453.  
  454. /* To resize memory for many arguments. 
  455.    The function should be called:
  456.    v_resize_vars(new_dim,&x,&y,&z,...,NULL);
  457.    where 
  458.      int new_dim;
  459.      ZVEC *x, *y, *z,...;
  460.      The last argument should be NULL ! 
  461.      rdim is the resized length of vectors x,y,z,...
  462.      returned value is equal to the number of allocated variables.
  463.      If one of x,y,z,.. arguments is NULL then memory is allocated to this 
  464.      argument. 
  465.      Other *_resize_list() functions are similar.
  466. */
  467.  
  468. int zv_resize_vars(int new_dim,...)
  469. {
  470.    va_list ap;
  471.    int i=0;
  472.    ZVEC **par;
  473.    
  474.    va_start(ap, new_dim);
  475.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  476.       *par = zv_resize(*par,new_dim);
  477.       i++;
  478.    } 
  479.  
  480.    va_end(ap);
  481.    return i;
  482. }
  483.  
  484.  
  485.  
  486. int zm_resize_vars(int m,int n,...) 
  487. {
  488.    va_list ap;
  489.    int i=0;
  490.    ZMAT **par;
  491.    
  492.    va_start(ap, n);
  493.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  494.       *par = zm_resize(*par,m,n);
  495.       i++;
  496.    } 
  497.  
  498.    va_end(ap);
  499.    return i;
  500. }
  501.  
  502.  
  503. /* To deallocate memory for many arguments. 
  504.    The function should be called:
  505.    v_free_vars(&x,&y,&z,...,NULL);
  506.    where 
  507.      ZVEC *x, *y, *z,...;
  508.      The last argument should be NULL ! 
  509.      There must be at least one not NULL argument.
  510.      returned value is equal to the number of allocated variables.
  511.      Returned value of x,y,z,.. is VNULL.
  512.      Other *_free_list() functions are similar.
  513. */
  514.  
  515. int zv_free_vars(ZVEC **pv,...)
  516. {
  517.    va_list ap;
  518.    int i=1;
  519.    ZVEC **par;
  520.    
  521.    zv_free(*pv);
  522.    *pv = ZVNULL;
  523.    va_start(ap, pv);
  524.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  525.       zv_free(*par); 
  526.       *par = ZVNULL;
  527.       i++;
  528.    } 
  529.  
  530.    va_end(ap);
  531.    return i;
  532. }
  533.  
  534.  
  535.  
  536. int zm_free_vars(ZMAT **va,...)
  537. {
  538.    va_list ap;
  539.    int i=1;
  540.    ZMAT **par;
  541.    
  542.    zm_free(*va);
  543.    *va = ZMNULL;
  544.    va_start(ap, va);
  545.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  546.       zm_free(*par); 
  547.       *par = ZMNULL;
  548.       i++;
  549.    } 
  550.  
  551.    va_end(ap);
  552.    return i;
  553. }
  554.  
  555.  
  556.  
  557. #elif VARARGS
  558.  
  559. #include <varargs.h>
  560.  
  561. /* To allocate memory to many arguments. 
  562.    The function should be called:
  563.    v_get_vars(dim,&x,&y,&z,...,NULL);
  564.    where 
  565.      int dim;
  566.      ZVEC *x, *y, *z,...;
  567.      The last argument should be NULL ! 
  568.      dim is the length of vectors x,y,z,...
  569.      returned value is equal to the number of allocated variables
  570.      Other gec_... functions are similar.
  571. */
  572.  
  573. int zv_get_vars(va_alist) va_dcl
  574. {
  575.    va_list ap;
  576.    int dim,i=0;
  577.    ZVEC **par;
  578.    
  579.    va_start(ap);
  580.    dim = va_arg(ap,int);
  581.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  582.       *par = zv_get(dim);
  583.       i++;
  584.    } 
  585.  
  586.    va_end(ap);
  587.    return i;
  588. }
  589.  
  590.  
  591.  
  592. int zm_get_vars(va_alist) va_dcl
  593. {
  594.    va_list ap;
  595.    int i=0, n, m;
  596.    ZMAT **par;
  597.    
  598.    va_start(ap);
  599.    m = va_arg(ap,int);
  600.    n = va_arg(ap,int);
  601.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  602.       *par = zm_get(m,n);
  603.       i++;
  604.    } 
  605.  
  606.    va_end(ap);
  607.    return i;
  608. }
  609.  
  610.  
  611.  
  612. /* To resize memory for many arguments. 
  613.    The function should be called:
  614.    v_resize_vars(new_dim,&x,&y,&z,...,NULL);
  615.    where 
  616.      int new_dim;
  617.      ZVEC *x, *y, *z,...;
  618.      The last argument should be NULL ! 
  619.      rdim is the resized length of vectors x,y,z,...
  620.      returned value is equal to the number of allocated variables.
  621.      If one of x,y,z,.. arguments is NULL then memory is allocated to this 
  622.      argument. 
  623.      Other *_resize_list() functions are similar.
  624. */
  625.  
  626. int zv_resize_vars(va_alist) va_dcl
  627. {
  628.    va_list ap;
  629.    int i=0, new_dim;
  630.    ZVEC **par;
  631.    
  632.    va_start(ap);
  633.    new_dim = va_arg(ap,int);
  634.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  635.       *par = zv_resize(*par,new_dim);
  636.       i++;
  637.    } 
  638.  
  639.    va_end(ap);
  640.    return i;
  641. }
  642.  
  643.  
  644. int zm_resize_vars(va_alist) va_dcl
  645. {
  646.    va_list ap;
  647.    int i=0, m, n;
  648.    ZMAT **par;
  649.    
  650.    va_start(ap);
  651.    m = va_arg(ap,int);
  652.    n = va_arg(ap,int);
  653.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  654.       *par = zm_resize(*par,m,n);
  655.       i++;
  656.    } 
  657.  
  658.    va_end(ap);
  659.    return i;
  660. }
  661.  
  662.  
  663.  
  664. /* To deallocate memory for many arguments. 
  665.    The function should be called:
  666.    v_free_vars(&x,&y,&z,...,NULL);
  667.    where 
  668.      ZVEC *x, *y, *z,...;
  669.      The last argument should be NULL ! 
  670.      There must be at least one not NULL argument.
  671.      returned value is equal to the number of allocated variables.
  672.      Returned value of x,y,z,.. is VNULL.
  673.      Other *_free_list() functions are similar.
  674. */
  675.  
  676. int zv_free_vars(va_alist) va_dcl
  677. {
  678.    va_list ap;
  679.    int i=0;
  680.    ZVEC **par;
  681.    
  682.    va_start(ap);
  683.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  684.       zv_free(*par); 
  685.       *par = ZVNULL;
  686.       i++;
  687.    } 
  688.  
  689.    va_end(ap);
  690.    return i;
  691. }
  692.  
  693.  
  694.  
  695. int zm_free_vars(va_alist) va_dcl
  696. {
  697.    va_list ap;
  698.    int i=0;
  699.    ZMAT **par;
  700.    
  701.    va_start(ap);
  702.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  703.       zm_free(*par); 
  704.       *par = ZMNULL;
  705.       i++;
  706.    } 
  707.  
  708.    va_end(ap);
  709.    return i;
  710. }
  711.  
  712.  
  713. #endif
  714.  
  715.