This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in dimensions->uniform-array?


Hi Everybody,

I've run across some strange behaviour in dimensions->uniform-array.
For most types, both of the following work and are equivalent.

(dimensions->uniform-array '(10) 1.0)
(dimensions->uniform-array 10 1.0)

However, for shorts I get:

   guile> (dimensions->uniform-array '(10) 's)
   #short(0 0 0 0 0 0 0 0 0 0)
   guile> (dimensions->uniform-array 10 's)
   ERROR: In procedure dimensions->uniform-array in expression 
		(dimensions->uniform-array 10 (quote s)):
   ERROR: array shape mismatch
   ABORT: (misc-error)

Assuming, that both ways should work the problem is in ramap.c.
Here's a patch to make it work.

Index: ramap.c
===================================================================
RCS file: /egcs/carton/cvsfiles/guile/guile-core/libguile/ramap.c,v
retrieving revision 1.13
diff -r1.13 ramap.c
167a168,171
>       case scm_tc7_svect:
> #ifdef LONGLONGS
>       case scm_tc7_llvect:
> #endif
200a205,208
> 	    case scm_tc7_svect:
> #ifdef LONGLONGS
> 	    case scm_tc7_llvect:
> #endif
501a510,527
>       case scm_tc7_svect:
> 	SCM_ASRTGO (SCM_INUMP (fill), badarg2);
> 	{
> 	  short f = SCM_INUM (fill), *ve = (short *) SCM_VELTS (ra);
> 	  for (i = base; n--; i += inc)
> 	    ve[i] = f;
> 	  break;
> 	}
> #ifdef LONGLONGS
>       case scm_tc7_svect:
> 	SCM_ASRTGO (SCM_INUMP (fill), badarg2);
> 	{
> 	  long long f = SCM_INUM (fill), *ve = (long long *) SCM_VELTS (ra);
> 	  for (i = base; n--; i += inc)
> 	    ve[i] = f;
> 	  break;
> 	}
> #endif
1843a1870,1873
>     case scm_tc7_svect:
> #ifdef LONGLONGS
>     case scm_tc7_llvect:
> #endif
1970a2001,2020
>       case scm_tc7_svect:
> 	{
> 	  short *v0 = (short *) SCM_VELTS (ra0) + i0;
> 	  short *v1 = (short *) SCM_VELTS (ra1) + i1;
> 	  for (; n--; v0 += inc0, v1 += inc1)
> 	    if (*v0 != *v1)
> 	      return 0;
> 	  return 1;
> 	}
> #ifdef LONGLONGS
>       case scm_tc7_llvect:
> 	{
> 	  long long *v0 = (long long *) SCM_VELTS (ra0) + i0;
> 	  long long *v1 = (long long *) SCM_VELTS (ra1) + i1;
> 	  for (; n--; v0 += inc0, v1 += inc1)
> 	    if (*v0 != *v1)
> 	      return 0;
> 	  return 1;
> 	}
> #endif