/* SCCS - @(#)NslRandom.java 1.6 - 09/01/99 - 00:18:23 */ // Copyright: Copyright (c) 1997 University of Southern California Brain Project. // Copyright: This software may be freely copied provided the toplevel // Copyright: COPYRIGHT file is included with each such copy. // Copyright: Email nsl@java.usc.edu. //////////////////////////////////////////////////////////// // // Random routines // // /** Random routines. There are two basic format for the evaluation method in this routine: 1, eval(a) -> c a is the input parameter to pass the threshold function: rand()*(b-a)+a 2. eval(dest, a) -> c a is the parameter of the threshold function and dest is the temporary space to hold the result. The method returns the reference to dest. */ //////////////////////////////////////////////////////////////////////////////// // step functions package nslj.src.math; import nslj.src.lang.*; public final class NslRandom { // doubles private static double value(double start, double end) { return Math.random()*(end-start)+start; } public static double eval() { return Math.random(); } public static double[] eval(double[] a) { return eval(a,0,1); } public static double[][] eval(double[][] a) { return eval(a,0,1); } public static double[][][] eval(double[][][] a) { return eval(a,0,1); } public static double[][][][] eval(double[][][][] a) { return eval(a,0,1); } public static double[] eval(double[] dest, double[] a) { return eval(dest,a,0,1); } public static double[][] eval(double[][] dest, double[][] a) { return eval(dest,a,0,1); } public static double[][][] eval(double[][][] dest, double[][][] a) { return eval(dest,a,0,1); } public static double[][][][] eval(double[][][][] dest, double[][][][] a) { return eval(dest,a,0,1); } public static double eval(double start, double end) { return value(start, end); } public static double[] eval (double[] a, double start, double end) { double[] dest = new double[a.length]; return eval(dest, a, start, end); } public static double[] eval (double[] dest, double[] a, double start, double end) { int i; if (dest.length!=a.length) { dest = new double[a.length]; } for (i=0; i