/*
 * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
 * Copyright (C) 2006 - JScience (http://jscience.org/)
 * All rights reserved.
 * 
 * Permission to use, copy, modify, and distribute this software is
 * freely granted, provided that this notice is preserved.
 */
package org.jscience.mathematics.function;

import javolution.context.ObjectFactory;

import org.jscience.mathematics.structure.Ring;

/**
 * 

This class represents a constant function (polynomial of degree 0).

* * @author Jean-Marie Dautelle * @version 3.1, April 1, 2006 */ public final class Constant> extends Polynomial { /** * Default constructor. */ private Constant() { } /** * Returns a constant function of specified value. * * @param value the value returned by this function. * @return the corresponding constant function. */ @SuppressWarnings("unchecked") public static > Constant valueOf(R value) { Constant cst = FACTORY.object(); cst._termToCoef.put(Term.ONE, value); return cst; } @SuppressWarnings("unchecked") private static final ObjectFactory FACTORY = new ObjectFactory() { protected Constant create() { return new Constant(); } protected void cleanup(Constant cst) { cst._termToCoef.reset(); } }; /** * Returns the constant value for this function. * * @return getCoefficient(Term.CONSTANT) */ public R getValue() { return getCoefficient(Term.ONE); } private static final long serialVersionUID = 1L; }

Ads help maintain this website.