// Utils.java
//
// (c) 1999-2000 PAL Development Core Team
//
// This package may be distributed under the
// terms of the GNU General Public License (GPL)

package pal.misc;

/**
 * Provides some miscellaneous methods.
 *
 * @version $Id: Utils.java,v 1.1 2001/04/05 00:23:24 matt Exp $
 *
 * @author Matthew Goode
 */
public class Utils {

	/** Clones an array of doubles
  	* @return null if input is null, otherwise return complete copy.
		*/
	public static final double[] getCopy(double[] array) {
		if(array == null) {
			return null;
		}
		double[] copy = new double[array.length];
		for(int i = 0 ; i < copy.length ; i++) {
			copy[i] = array[i];
		}
		return copy;
	}

	/** A simple toString method for an array of doubles.
		* No fancy formating.
		* Puts spaces between each value
		*/
	public static final String toString(double[] array) {
		StringBuffer sb = new StringBuffer(array.length*7);
		for(int i = 0 ; i < array.length ; i++) {
			sb.append(array[i]);
			sb.append(' ');
		}
		return sb.toString();
	}
} 