001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.math; 018 019 020 /** 021 * Interface representing <a href="http://mathworld.wolfram.com/Field.html">field</a> elements. 022 * @param <T> the type of the field elements 023 * @see Field 024 * @version $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $ 025 * @since 2.0 026 */ 027 public interface FieldElement<T> { 028 029 /** Compute this + a. 030 * @param a element to add 031 * @return a new element representing this + a 032 */ 033 T add(T a); 034 035 /** Compute this - a. 036 * @param a element to subtract 037 * @return a new element representing this - a 038 */ 039 T subtract(T a); 040 041 /** Compute this × a. 042 * @param a element to multiply 043 * @return a new element representing this × a 044 */ 045 T multiply(T a); 046 047 /** Compute this ÷ a. 048 * @param a element to add 049 * @return a new element representing this ÷ a 050 * @exception ArithmeticException if a is the zero of the 051 * additive operation (i.e. additive identity) 052 */ 053 T divide(T a) throws ArithmeticException; 054 055 /** Get the {@link Field} to which the instance belongs. 056 * @return {@link Field} to which the instance belongs 057 */ 058 Field<T> getField(); 059 060 }