/* SCCS - @(#)NslUnaryOperator.java 1.3 - 09/01/99 - 00:18:24 */ // 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. //////////////////////////////////////////////////////////// // // Unary operator routines // // package nslj.src.math; import nslj.src.lang.*; /** Unary operator routines. There are two basic format for the evaluation method in this routine: 1, eval(a) -> c a is the parameter of the evaluation function to do operator(a) pointwise and the result is passed out as c 2. eval(dest, a) -> c a is the parameter of the evaluation function and dest is the temporary space to hold the result. The method returns the reference to dest. */ public abstract class NslUnaryOperator extends NslBase { public NslUnaryOperator() { super(); } public NslUnaryOperator(String label, NslHierarchy parent) { super(label,parent); } public abstract int value(int a); public abstract float value(float a); public abstract double value(double a); public boolean value(boolean a) { return false; } // 0d native ints public int eval(int a) { return value(a); } // 1d native ints public int[] eval(int[] a) { int[] dest = new int[a.length]; return eval(dest, a); } public int[] eval(int[] dest, int[] a) { int i; int len = dest.length; if (len != a.length) { len = a.length; dest = new int[len]; } for (i=0; i