Index: src/main/random.c
===================================================================
--- src/main/random.c	(revision 44677)
+++ src/main/random.c	(working copy)
@@ -41,10 +41,19 @@
     double ai;
     int i;
     errno = 0;
-    for (i = 0; i < n; i++) {
+    if( na == 1 ){
+      ai = a[0];
+      for (i = 0; i < n; i++) {
+	x[i] = f(ai);
+	if (!R_FINITE(x[i])) naflag = 1;
+      }
+    }
+    else{
+      for (i = 0; i < n; i++) {
 	ai = a[i % na];
 	x[i] = f(ai);
 	if (!R_FINITE(x[i])) naflag = 1;
+      }
     }
     return(naflag);
 }
@@ -81,6 +90,7 @@
     if (na < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(CADR(args), REALSXP));
@@ -112,18 +122,28 @@
     double ai, bi; int i;
     Rboolean naflag = FALSE;
     errno = 0;
-    for (i = 0; i < n; i++) {
+    if( na == 1 && na == 1 ){
+      ai = a[0];
+      bi = b[0];
+      for (i = 0; i < n; i++) {
+	x[i] = f(ai, bi);
+	if (!R_FINITE(x[i])) naflag = 1;
+      }
+    }
+    else{
+      for (i = 0; i < n; i++) {
 	ai = a[i % na];
 	bi = b[i % nb];
 	x[i] = f(ai, bi);
 	if (!R_FINITE(x[i])) naflag = 1;
+      }
     }
     return(naflag);
 }
 
 #define RAND2(num,name) \
 	case num: \
-		random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
+		naflag = random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
 		break
 
 /* "do_random2" - random sampling from 2 parameter families. */
@@ -155,6 +175,7 @@
     if (na < 1 || nb < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(CADR(args), REALSXP));
@@ -195,19 +216,30 @@
     int i;
     Rboolean naflag = FALSE;
     errno = 0;
-    for (i = 0; i < n; i++) {
+    if( na == 1 && nb == 1 && nc == 1 ){
+      ai = a[0];
+      bi = b[0];
+      ci = c[0];
+      for (i = 0; i < n; i++) {
+	x[i] = f(ai, bi, ci);
+	if (!R_FINITE(x[i])) naflag = TRUE;
+      }
+    }
+    else{
+      for (i = 0; i < n; i++) {
 	ai = a[i % na];
 	bi = b[i % nb];
 	ci = c[i % nc];
 	x[i] = f(ai, bi, ci);
 	if (!R_FINITE(x[i])) naflag = TRUE;
+      }
     }
     return(naflag);
 }
 
 #define RAND3(num,name) \
 	case num: \
-		random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, REAL(x), n); \
+		naflag = random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, REAL(x), n); \
 		break
 
 
@@ -244,6 +276,7 @@
     if (na < 1 || nb < 1 || nc < 1) {
 	for (i = 0; i < n; i++)
 	    REAL(x)[i] = NA_REAL;
+        warning(_("NAs produced"));
     }
     else {
 	PROTECT(a = coerceVector(a, REALSXP));
