1 9 package org.jscience.mathematics.functions; 10 11 import org.jscience.mathematics.structures.Ring; 12 13 19 public final class Constant<R extends Ring<R>> extends Polynomial<R> { 20 21 24 private Constant() { 25 } 26 27 33 @SuppressWarnings ("unchecked") 34 public static <R extends Ring<R>> Constant<R> valueOf(R value) { 35 Constant<R> cst = FACTORY.object(); 36 cst._termToCoef.put(Term.ONE, value); 37 return cst; 38 } 39 40 private static final Factory<Constant> FACTORY = new Factory<Constant>() { 41 protected Constant create() { 42 return new Constant(); 43 } 44 45 protected void cleanup(Constant cst) { 46 cst._termToCoef.reset(); 47 } 48 }; 49 50 55 public R getValue() { 56 return getCoefficient(Term.ONE); 57 } 58 59 private static final long serialVersionUID = 1L; 60 } | Popular Tags |