gcc/libgfortran/intrinsics/pack_generic.c
Toon Moene 57dea9f62e re PR libfortran/19280 (Inconsistent licensing of libgfortran)
2005-01-12  Toon Moene  <toon@moene.indiv.nluug.nl>

	PR libfortran/19280
	c99_protos.h: License changed to GPL+exception.
	libgfortran.h: Ditto.
	intrinsics/abort.c: Ditto.
	intrinsics/args.c: Ditto.
	intrinsics/associated.c: Ditto.
	intrinsics/bessel.c: Ditto.
	intrinsics/c99_functions.c: Ditto.
	intrinsics/cpu_time.c: Ditto.
	intrinsics/cshift0.c: Ditto.
	intrinsics/date_and_time.c: Ditto.
	intrinsics/env.c: Ditto.
	intrinsics/eoshift0.c: Ditto.
	intrinsics/eoshift2.c: Ditto.
	intrinsics/erf.c: Ditto.
	intrinsics/etime.c: Ditto.
	intrinsics/exit.c: Ditto.
	intrinsics/flush.c: Ditto.
	intrinsics/fnum.c: Ditto.
	intrinsics/getXid.c: Ditto.
	intrinsics/getcwd.c: Ditto.
	intrinsics/ishftc.c: Ditto.
	intrinsics/mvbits.c: Ditto.
	intrinsics/pack_generic.c: Ditto.
	intrinsics/rand.c: Ditto.
	intrinsics/random.c: Ditto.
	intrinsics/reshape_generic.c: Ditto.
	intrinsics/reshape_packed.c: Ditto.
	intrinsics/size.c: Ditto.
	intrinsics/spread_generic.c: Ditto.
	intrinsics/stat.c: Ditto.
	intrinsics/string_intrinsics.c: Ditto.
	intrinsics/system.c: Ditto.
	intrinsics/system_clock.c: Ditto.
	intrinsics/transpose_generic.c: Ditto.
	intrinsics/umask.c: Ditto.
	intrinsics/unlink.c: Ditto.
	intrinsics/unpack_generic.c: Ditto.
	io/backspace.c: Ditto.
	io/close.c: Ditto.
	io/endfile.c: Ditto.
	io/format.c: Ditto.
	io/inquire.c: Ditto.
	io/io.h: Ditto.
	io/list_read.c: Ditto.
	io/lock.c: Ditto.
	io/open.c: Ditto.
	io/read.c: Ditto.
	io/rewind.c: Ditto.
	io/transfer.c: Ditto.
	io/unit.c: Ditto.
	io/unix.c: Ditto.
	io/write.c: Ditto.
	m4/all.m4: Ditto.
	m4/any.m4: Ditto.
	m4/cexp.m4: Ditto.
	m4/chyp.m4: Ditto.
	m4/count.m4: Ditto.
	m4/cshift1.m4: Ditto.
	m4/ctrig.m4: Ditto.
	m4/dotprod.m4: Ditto.
	m4/dotprodc.m4: Ditto.
	m4/dotprodl.m4: Ditto.
	m4/eoshift1.m4: Ditto.
	m4/eoshift3.m4: Ditto.
	m4/exponent.m4: Ditto.
	m4/fraction.m4: Ditto.
	m4/head.m4: Ditto.
	m4/iforeach.m4: Ditto.
	m4/ifunction.m4: Ditto.
	m4/in_pack.m4: Ditto.
	m4/in_unpack.m4: Ditto.
	m4/iparm.m4: Ditto.
	m4/matmul.m4: Ditto.
	m4/matmull.m4: Ditto.
	m4/maxloc0.m4: Ditto.
	m4/maxloc1.m4: Ditto.
	m4/maxval.m4: Ditto.
	m4/minloc0.m4: Ditto.
	m4/minloc1.m4: Ditto.
	m4/minval.m4: Ditto.
	m4/mtype.m4: Ditto.
	m4/nearest.m4: Ditto.
	m4/pow.m4: Ditto.
	m4/product.m4: Ditto.
	m4/reshape.m4: Ditto.
	m4/set_exponent.m4: Ditto.
	m4/shape.m4: Ditto.
	m4/specific.m4: Ditto.
	m4/specific2.m4: Ditto.
	m4/sum.m4: Ditto.
	m4/transpose.m4: Ditto.
	m4/types.m4: Ditto.
	runtime/environ.c: Ditto.
	runtime/error.c: Ditto.
	runtime/in_pack_generic.c: Ditto.
	runtime/in_unpack_generic.c: Ditto.
	runtime/main.c: Ditto.
	runtime/memory.c: Ditto.
	runtime/normalize.c: Ditto.
	runtime/pause.c: Ditto.
	runtime/select.c: Ditto.
	runtime/stop.c: Ditto.
	runtime/string.c: Ditto.
	generated/_abs_c4.f90: Regenerated.
	generated/_abs_c8.f90: Regenerated.
	generated/_abs_i4.f90: Regenerated.
	generated/_abs_i8.f90: Regenerated.
	generated/_abs_r4.f90: Regenerated.
	generated/_abs_r8.f90: Regenerated.
	generated/_acos_r4.f90: Regenerated.
	generated/_acos_r8.f90: Regenerated.
	generated/_aint_r4.f90: Regenerated.
	generated/_aint_r8.f90: Regenerated.
	generated/_anint_r4.f90: Regenerated.
	generated/_anint_r8.f90: Regenerated.
	generated/_asin_r4.f90: Regenerated.
	generated/_asin_r8.f90: Regenerated.
	generated/_atan2_r4.f90: Regenerated.
	generated/_atan2_r8.f90: Regenerated.
	generated/_atan_r4.f90: Regenerated.
	generated/_atan_r8.f90: Regenerated.
	generated/_conjg_c4.f90: Regenerated.
	generated/_conjg_c8.f90: Regenerated.
	generated/_cos_c4.f90: Regenerated.
	generated/_cos_c8.f90: Regenerated.
	generated/_cos_r4.f90: Regenerated.
	generated/_cos_r8.f90: Regenerated.
	generated/_cosh_r4.f90: Regenerated.
	generated/_cosh_r8.f90: Regenerated.
	generated/_dim_i4.f90: Regenerated.
	generated/_dim_i8.f90: Regenerated.
	generated/_dim_r4.f90: Regenerated.
	generated/_dim_r8.f90: Regenerated.
	generated/_exp_c4.f90: Regenerated.
	generated/_exp_c8.f90: Regenerated.
	generated/_exp_r4.f90: Regenerated.
	generated/_exp_r8.f90: Regenerated.
	generated/_log10_r4.f90: Regenerated.
	generated/_log10_r8.f90: Regenerated.
	generated/_log_c4.f90: Regenerated.
	generated/_log_c8.f90: Regenerated.
	generated/_log_r4.f90: Regenerated.
	generated/_log_r8.f90: Regenerated.
	generated/_mod_i4.f90: Regenerated.
	generated/_mod_i8.f90: Regenerated.
	generated/_mod_r4.f90: Regenerated.
	generated/_mod_r8.f90: Regenerated.
	generated/_sign_i4.f90: Regenerated.
	generated/_sign_i8.f90: Regenerated.
	generated/_sign_r4.f90: Regenerated.
	generated/_sign_r8.f90: Regenerated.
	generated/_sin_c4.f90: Regenerated.
	generated/_sin_c8.f90: Regenerated.
	generated/_sin_r4.f90: Regenerated.
	generated/_sin_r8.f90: Regenerated.
	generated/_sinh_r4.f90: Regenerated.
	generated/_sinh_r8.f90: Regenerated.
	generated/_sqrt_c4.f90: Regenerated.
	generated/_sqrt_c8.f90: Regenerated.
	generated/_sqrt_r4.f90: Regenerated.
	generated/_sqrt_r8.f90: Regenerated.
	generated/_tan_r4.f90: Regenerated.
	generated/_tan_r8.f90: Regenerated.
	generated/_tanh_r4.f90: Regenerated.
	generated/_tanh_r8.f90: Regenerated.
	generated/all_l4.c: Regenerated.
	generated/all_l8.c: Regenerated.
	generated/any_l4.c: Regenerated.
	generated/any_l8.c: Regenerated.
	generated/count_4_l4.c: Regenerated.
	generated/count_4_l8.c: Regenerated.
	generated/count_8_l4.c: Regenerated.
	generated/count_8_l8.c: Regenerated.
	generated/cshift1_4.c: Regenerated.
	generated/cshift1_8.c: Regenerated.
	generated/dotprod_c4.c: Regenerated.
	generated/dotprod_c8.c: Regenerated.
	generated/dotprod_i4.c: Regenerated.
	generated/dotprod_i8.c: Regenerated.
	generated/dotprod_l4.c: Regenerated.
	generated/dotprod_l8.c: Regenerated.
	generated/dotprod_r4.c: Regenerated.
	generated/dotprod_r8.c: Regenerated.
	generated/eoshift1_4.c: Regenerated.
	generated/eoshift1_8.c: Regenerated.
	generated/eoshift3_4.c: Regenerated.
	generated/eoshift3_8.c: Regenerated.
	generated/exp_c4.c: Regenerated.
	generated/exp_c8.c: Regenerated.
	generated/exponent_r4.c: Regenerated.
	generated/exponent_r8.c: Regenerated.
	generated/fraction_r4.c: Regenerated.
	generated/fraction_r8.c: Regenerated.
	generated/hyp_c4.c: Regenerated.
	generated/hyp_c8.c: Regenerated.
	generated/in_pack_i4.c: Regenerated.
	generated/in_pack_i8.c: Regenerated.
	generated/in_unpack_i4.c: Regenerated.
	generated/in_unpack_i8.c: Regenerated.
	generated/matmul_c4.c: Regenerated.
	generated/matmul_c8.c: Regenerated.
	generated/matmul_i4.c: Regenerated.
	generated/matmul_i8.c: Regenerated.
	generated/matmul_l4.c: Regenerated.
	generated/matmul_l8.c: Regenerated.
	generated/matmul_r4.c: Regenerated.
	generated/matmul_r8.c: Regenerated.
	generated/maxloc0_4_i4.c: Regenerated.
	generated/maxloc0_4_i8.c: Regenerated.
	generated/maxloc0_4_r4.c: Regenerated.
	generated/maxloc0_4_r8.c: Regenerated.
	generated/maxloc0_8_i4.c: Regenerated.
	generated/maxloc0_8_i8.c: Regenerated.
	generated/maxloc0_8_r4.c: Regenerated.
	generated/maxloc0_8_r8.c: Regenerated.
	generated/maxloc1_4_i4.c: Regenerated.
	generated/maxloc1_4_i8.c: Regenerated.
	generated/maxloc1_4_r4.c: Regenerated.
	generated/maxloc1_4_r8.c: Regenerated.
	generated/maxloc1_8_i4.c: Regenerated.
	generated/maxloc1_8_i8.c: Regenerated.
	generated/maxloc1_8_r4.c: Regenerated.
	generated/maxloc1_8_r8.c: Regenerated.
	generated/maxval_i4.c: Regenerated.
	generated/maxval_i8.c: Regenerated.
	generated/maxval_r4.c: Regenerated.
	generated/maxval_r8.c: Regenerated.
	generated/minloc0_4_i4.c: Regenerated.
	generated/minloc0_4_i8.c: Regenerated.
	generated/minloc0_4_r4.c: Regenerated.
	generated/minloc0_4_r8.c: Regenerated.
	generated/minloc0_8_i4.c: Regenerated.
	generated/minloc0_8_i8.c: Regenerated.
	generated/minloc0_8_r4.c: Regenerated.
	generated/minloc0_8_r8.c: Regenerated.
	generated/minloc1_4_i4.c: Regenerated.
	generated/minloc1_4_i8.c: Regenerated.
	generated/minloc1_4_r4.c: Regenerated.
	generated/minloc1_4_r8.c: Regenerated.
	generated/minloc1_8_i4.c: Regenerated.
	generated/minloc1_8_i8.c: Regenerated.
	generated/minloc1_8_r4.c: Regenerated.
	generated/minloc1_8_r8.c: Regenerated.
	generated/minval_i4.c: Regenerated.
	generated/minval_i8.c: Regenerated.
	generated/minval_r4.c: Regenerated.
	generated/minval_r8.c: Regenerated.
	generated/nearest_r4.c: Regenerated.
	generated/nearest_r8.c: Regenerated.
	generated/pow_c4_i4.c: Regenerated.
	generated/pow_c4_i8.c: Regenerated.
	generated/pow_c8_i4.c: Regenerated.
	generated/pow_c8_i8.c: Regenerated.
	generated/pow_i4_i4.c: Regenerated.
	generated/pow_i4_i8.c: Regenerated.
	generated/pow_i8_i4.c: Regenerated.
	generated/pow_i8_i8.c: Regenerated.
	generated/pow_r4_i4.c: Regenerated.
	generated/pow_r4_i8.c: Regenerated.
	generated/pow_r8_i4.c: Regenerated.
	generated/pow_r8_i8.c: Regenerated.
	generated/product_c4.c: Regenerated.
	generated/product_c8.c: Regenerated.
	generated/product_i4.c: Regenerated.
	generated/product_i8.c: Regenerated.
	generated/product_r4.c: Regenerated.
	generated/product_r8.c: Regenerated.
	generated/reshape_i4.c: Regenerated.
	generated/reshape_i8.c: Regenerated.
	generated/set_exponent_r4.c: Regenerated.
	generated/set_exponent_r8.c: Regenerated.
	generated/shape_i4.c: Regenerated.
	generated/shape_i8.c: Regenerated.
	generated/sum_c4.c: Regenerated.
	generated/sum_c8.c: Regenerated.
	generated/sum_i4.c: Regenerated.
	generated/sum_i8.c: Regenerated.
	generated/sum_r4.c: Regenerated.
	generated/sum_r8.c: Regenerated.
	generated/transpose_i4.c: Regenerated.
	generated/transpose_i8.c: Regenerated.
	generated/trig_c4.c: Regenerated.
	generated/trig_c8.c: Regenerated.

From-SVN: r93235
2005-01-12 21:27:33 +00:00

430 lines
12 KiB
C

/* Generic implementation of the PACK intrinsic
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
Libgfortran 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
Ligbfortran 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 libgfortran; see the file COPYING. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "libgfortran.h"
/* PACK is specified as follows:
13.14.80 PACK (ARRAY, MASK, [VECTOR])
Description: Pack an array into an array of rank one under the
control of a mask.
Class: Transformational fucntion.
Arguments:
ARRAY may be of any type. It shall not be scalar.
MASK shall be of type LOGICAL. It shall be conformable with ARRAY.
VECTOR (optional) shall be of the same type and type parameters
as ARRAY. VECTOR shall have at least as many elements as
there are true elements in MASK. If MASK is a scalar
with the value true, VECTOR shall have at least as many
elements as there are in ARRAY.
Result Characteristics: The result is an array of rank one with the
same type and type parameters as ARRAY. If VECTOR is present, the
result size is that of VECTOR; otherwise, the result size is the
number /t/ of true elements in MASK unless MASK is scalar with the
value true, in which case the result size is the size of ARRAY.
Result Value: Element /i/ of the result is the element of ARRAY
that corresponds to the /i/th true element of MASK, taking elements
in array element order, for /i/ = 1, 2, ..., /t/. If VECTOR is
present and has size /n/ > /t/, element /i/ of the result has the
value VECTOR(/i/), for /i/ = /t/ + 1, ..., /n/.
Examples: The nonzero elements of an array M with the value
| 0 0 0 |
| 9 0 0 | may be "gathered" by the function PACK. The result of
| 0 0 7 |
PACK (M, MASK = M.NE.0) is [9,7] and the result of PACK (M, M.NE.0,
VECTOR = (/ 2,4,6,8,10,12 /)) is [9,7,6,8,10,12].
There are two variants of the PACK intrinsic: one, where MASK is
array valued, and the other one where MASK is scalar. */
extern void pack (gfc_array_char *, const gfc_array_char *,
const gfc_array_l4 *, const gfc_array_char *);
export_proto(pack);
void
pack (gfc_array_char *ret, const gfc_array_char *array,
const gfc_array_l4 *mask, const gfc_array_char *vector)
{
/* r.* indicates the return array. */
index_type rstride0;
char *rptr;
/* s.* indicates the source array. */
index_type sstride[GFC_MAX_DIMENSIONS];
index_type sstride0;
const char *sptr;
/* m.* indicates the mask array. */
index_type mstride[GFC_MAX_DIMENSIONS];
index_type mstride0;
const GFC_LOGICAL_4 *mptr;
index_type count[GFC_MAX_DIMENSIONS];
index_type extent[GFC_MAX_DIMENSIONS];
index_type n;
index_type dim;
index_type size;
index_type nelem;
size = GFC_DESCRIPTOR_SIZE (array);
dim = GFC_DESCRIPTOR_RANK (array);
for (n = 0; n < dim; n++)
{
count[n] = 0;
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
sstride[n] = array->dim[n].stride * size;
mstride[n] = mask->dim[n].stride;
}
if (sstride[0] == 0)
sstride[0] = size;
if (mstride[0] == 0)
mstride[0] = 1;
sptr = array->data;
mptr = mask->data;
/* Use the same loop for both logical types. */
if (GFC_DESCRIPTOR_SIZE (mask) != 4)
{
if (GFC_DESCRIPTOR_SIZE (mask) != 8)
runtime_error ("Funny sized logical array");
for (n = 0; n < dim; n++)
mstride[n] <<= 1;
mstride0 <<= 1;
mptr = GFOR_POINTER_L8_TO_L4 (mptr);
}
if (ret->data == NULL)
{
/* Allocate the memory for the result. */
int total;
if (vector != NULL)
{
/* The return array will have as many
elements as there are in VECTOR. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
}
else
{
/* We have to count the true elements in MASK. */
/* TODO: We could speed up pack easily in the case of only
few .TRUE. entries in MASK, by keeping track of where we
would be in the source array during the initial traversal
of MASK, and caching the pointers to those elements. Then,
supposed the number of elements is small enough, we would
only have to traverse the list, and copy those elements
into the result array. In the case of datatypes which fit
in one of the integer types we could also cache the
value instead of a pointer to it.
This approach might be bad from the point of view of
cache behavior in the case where our cache is not big
enough to hold all elements that have to be copied. */
const GFC_LOGICAL_4 *m = mptr;
total = 0;
while (m)
{
/* Test this element. */
if (*m)
total++;
/* Advance to the next element. */
m += mstride[0];
count[0]++;
n = 0;
while (count[n] == extent[n])
{
/* When we get to the end of a dimension, reset it
and increment the next dimension. */
count[n] = 0;
/* We could precalculate this product, but this is a
less frequently used path so proabably not worth
it. */
m -= mstride[n] * extent[n];
n++;
if (n >= dim)
{
/* Break out of the loop. */
m = NULL;
break;
}
else
{
count[n]++;
mptr += mstride[n];
}
}
}
}
/* Setup the array descriptor. */
ret->dim[0].lbound = 0;
ret->dim[0].ubound = total - 1;
ret->dim[0].stride = 1;
ret->data = internal_malloc_size (size * total);
ret->base = 0;
if (total == 0)
/* In this case, nothing remains to be done. */
return;
}
rstride0 = ret->dim[0].stride * size;
if (rstride0 == 0)
rstride0 = size;
sstride0 = sstride[0];
mstride0 = mstride[0];
rptr = ret->data;
while (sptr)
{
/* Test this element. */
if (*mptr)
{
/* Add it. */
memcpy (rptr, sptr, size);
rptr += rstride0;
}
/* Advance to the next element. */
sptr += sstride0;
mptr += mstride0;
count[0]++;
n = 0;
while (count[n] == extent[n])
{
/* When we get to the end of a dimension, reset it and increment
the next dimension. */
count[n] = 0;
/* We could precalculate these products, but this is a less
frequently used path so proabably not worth it. */
sptr -= sstride[n] * extent[n];
mptr -= mstride[n] * extent[n];
n++;
if (n >= dim)
{
/* Break out of the loop. */
sptr = NULL;
break;
}
else
{
count[n]++;
sptr += sstride[n];
mptr += mstride[n];
}
}
}
/* Add any remaining elements from VECTOR. */
if (vector)
{
n = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
nelem = ((rptr - ret->data) / rstride0);
if (n > nelem)
{
sstride0 = vector->dim[0].stride * size;
if (sstride0 == 0)
sstride0 = size;
sptr = vector->data + sstride0 * nelem;
n -= nelem;
while (n--)
{
memcpy (rptr, sptr, size);
rptr += rstride0;
sptr += sstride0;
}
}
}
}
extern void pack_s (gfc_array_char *ret, const gfc_array_char *array,
const GFC_LOGICAL_4 *, const gfc_array_char *);
export_proto(pack_s);
void
pack_s (gfc_array_char *ret, const gfc_array_char *array,
const GFC_LOGICAL_4 *mask, const gfc_array_char *vector)
{
/* r.* indicates the return array. */
index_type rstride0;
char *rptr;
/* s.* indicates the source array. */
index_type sstride[GFC_MAX_DIMENSIONS];
index_type sstride0;
const char *sptr;
index_type count[GFC_MAX_DIMENSIONS];
index_type extent[GFC_MAX_DIMENSIONS];
index_type n;
index_type dim;
index_type size;
index_type nelem;
size = GFC_DESCRIPTOR_SIZE (array);
dim = GFC_DESCRIPTOR_RANK (array);
for (n = 0; n < dim; n++)
{
count[n] = 0;
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
sstride[n] = array->dim[n].stride * size;
}
if (sstride[0] == 0)
sstride[0] = size;
sstride0 = sstride[0];
sptr = array->data;
if (ret->data == NULL)
{
/* Allocate the memory for the result. */
int total;
if (vector != NULL)
{
/* The return array will have as many elements as there are
in vector. */
total = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
}
else
{
if (*mask)
{
/* The result array will have as many elements as the input
array. */
total = extent[0];
for (n = 1; n < dim; n++)
total *= extent[n];
}
else
{
/* The result array will be empty. */
ret->dim[0].lbound = 0;
ret->dim[0].ubound = -1;
ret->dim[0].stride = 1;
ret->data = internal_malloc_size (0);
ret->base = 0;
return;
}
}
/* Setup the array descriptor. */
ret->dim[0].lbound = 0;
ret->dim[0].ubound = total - 1;
ret->dim[0].stride = 1;
ret->data = internal_malloc_size (size * total);
ret->base = 0;
}
rstride0 = ret->dim[0].stride * size;
if (rstride0 == 0)
rstride0 = size;
rptr = ret->data;
/* The remaining possibilities are now:
If MASK is .TRUE., we have to copy the source array into the
result array. We then have to fill it up with elements from VECTOR.
If MASK is .FALSE., we have to copy VECTOR into the result
array. If VECTOR were not present we would have already returned. */
if (*mask)
{
while (sptr)
{
/* Add this element. */
memcpy (rptr, sptr, size);
rptr += rstride0;
/* Advance to the next element. */
sptr += sstride0;
count[0]++;
n = 0;
while (count[n] == extent[n])
{
/* When we get to the end of a dimension, reset it and
increment the next dimension. */
count[n] = 0;
/* We could precalculate these products, but this is a
less frequently used path so proabably not worth it. */
sptr -= sstride[n] * extent[n];
n++;
if (n >= dim)
{
/* Break out of the loop. */
sptr = NULL;
break;
}
else
{
count[n]++;
sptr += sstride[n];
}
}
}
}
/* Add any remaining elements from VECTOR. */
if (vector)
{
n = vector->dim[0].ubound + 1 - vector->dim[0].lbound;
nelem = ((rptr - ret->data) / rstride0);
if (n > nelem)
{
sstride0 = vector->dim[0].stride * size;
if (sstride0 == 0)
sstride0 = size;
sptr = vector->data + sstride0 * nelem;
n -= nelem;
while (n--)
{
memcpy (rptr, sptr, size);
rptr += rstride0;
sptr += sstride0;
}
}
}
}