/* SCCS @(#)NslConvZero.java 1.5 --- 09/01/99 -- 00:18:05 */ // 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. /* * $Log: NslConvZero.java,v $ * Revision 1.1 1997/11/06 03:19:31 erhan * NSL3.0.b * * Revision 1.1 1997/07/30 21:19:29 erhan * nsl3.0 * * Revision 1.1.1.1 1997/03/12 22:52:20 nsl * new dir structure * * Revision 1.1.1.1 1997/02/08 00:40:40 nsl * Imported the Source directory * */ //////////////////////////////////////////////////////////// // // Standard convolution routines // // /** Standard convolution routines. There are two basic format for the evaluation method in this routine: 1, eval(a, b) -> c a, b are the parameter of the evaluation function to do a convolutes b and the result is passed out as c 2. eval(dest, a, b) -> c a, b are the parameter of the evaluation function and dest is the temporary space to hold the result. The method returns the reference to dest. */ package nslj.src.math; import nslj.src.lang.*; public final class NslConvZero { public static int eval(int a, int b) { return a*b; } public static float eval(float a, float b) { return a*b; } public static double eval(double a, double b) { return a*b; } public static int[] eval(int a, int[] b) { int[] tmp = new int[1]; tmp[0] = a; return eval(tmp, b); } public static float[] eval(float a, float[] b) { float[] tmp = new float[1]; tmp[0] = a; return eval(tmp, b); } public static double[] eval(double a, double[] b) { double[] tmp = new double[1]; tmp[0] = a; return eval(tmp, b); } public static int[] eval(int[] a, int b) { int[] tmp = new int[1]; tmp[0] = b; return eval(b, tmp); } public static float[] eval(float[] a, float b) { float[] tmp = new float[1]; tmp[0] = b; return eval(b, tmp); } public static double[] eval(double[] a, double b) { double[] tmp = new double[1]; tmp[0] = b; return eval(b, tmp); } public static int[] eval(int[] a, int[] b) { int[] dest; dest = new int[b.length]; return eval(dest, a, b); } public static int[] eval(int[] dest, int[] a, int[] b) { int sa = a.length; // size of a int sb = b.length; int i; int j; int[] tmp = new int[sa+sb-1]; int sum = 0; if (dest.length != sb) dest = new int[sb]; j=sa/2; for (i=0; i