/* SCCS @(#)NslSumRows.java 1.7 ---09/01/99 --00:18:13 */
// 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.
////////////////////////////////////////////////////////////
//
// Summation routines
//
//
/**
Summation routines.
There are two basic format for the evaluation method in
this routine:
1, eval(a) -> c
a is the parameter to evaluate the summation of
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.
NslSumRows always returns a double.
*/
package nslj.src.math;
//import java.util.Arrays;
import nslj.src.lang.*;
public final class NslSumRows {
//native 0d double
public static double eval(double a) {
return a;
}
//native 1d double
public static double eval(double dest, double[]_data) {
int i;
dest=(double)0.0;
for (i=0; i<_data.length; i++) {
dest=dest+_data[i];
}
return dest;
}
public static double eval(double[] _data) {
double dest=(double)0.0;
return (eval(dest,_data));
}
//native 2d double
public static double[] eval(double[] dest, double[][] _data) {
int i, j;
int size1 = _data.length;
int size2 = _data[0].length;
if (dest.length != size1 ) {
dest = new double[size1];
}
for (i=0; i