001    /*
002     * Copyright (C) 2008-2010 by Holger Arndt
003     *
004     * This file is part of the Universal Java Matrix Package (UJMP).
005     * See the NOTICE file distributed with this work for additional
006     * information regarding copyright ownership and licensing.
007     *
008     * UJMP is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU Lesser General Public License as
010     * published by the Free Software Foundation; either version 2
011     * of the License, or (at your option) any later version.
012     *
013     * UJMP is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016     * GNU Lesser General Public License for more details.
017     *
018     * You should have received a copy of the GNU Lesser General Public
019     * License along with UJMP; if not, write to the
020     * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
021     * Boston, MA  02110-1301  USA
022     */
023    
024    package org.ujmp.core.doublematrix.calculation.basic;
025    
026    import org.ujmp.core.Matrix;
027    import org.ujmp.core.calculation.Calculation.Ret;
028    import org.ujmp.core.exceptions.MatrixException;
029    
030    public interface BasicDoubleCalculations {
031    
032            /**
033             * Adds a specified value to all entries in the matrix.
034             * 
035             * @param value
036             *            the value to add
037             * @return Matrix with the entries plus the value
038             */
039            public Matrix plus(double value) throws MatrixException;
040    
041            /**
042             * Calculates the sum of the entries in both matrices
043             * 
044             * @param matrix
045             *            The matrix to add
046             * @return matrix with sum values
047             */
048            public Matrix plus(Matrix matrix) throws MatrixException;
049    
050            /**
051             * Subtracts a specified value from all entries in the matrix.
052             * 
053             * @param value
054             *            the value to subtract
055             * @return Matrix with the entries minus the value
056             */
057            public Matrix minus(double value) throws MatrixException;
058    
059            /**
060             * Subtracts a specified value from all entries in the matrix.
061             * 
062             * @param returnType
063             *            Defines if a new Matrix or a link should be returned.
064             * @param ignoreNaN
065             *            should missing values be ignored
066             * @param value
067             *            the value to subtract
068             * @return Matrix with the entries minus the value
069             */
070            public Matrix minus(Ret returnType, boolean ignoreNaN, double value) throws MatrixException;
071    
072            /**
073             * Calculates the difference of the entries in both matrices
074             * 
075             * @param returnType
076             *            Defines if a new Matrix or a link should be returned.
077             * @param ignoreNaN
078             *            should missing values be ignored
079             * @param matrix
080             *            The matrix to subtract
081             * @return matrix with difference values
082             */
083            public Matrix minus(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException;
084    
085            /**
086             * Adds a specified value from all entries in the matrix.
087             * 
088             * @param returnType
089             *            Defines if a new Matrix or a link should be returned.
090             * @param ignoreNaN
091             *            should missing values be ignored
092             * @param value
093             *            the value to subtract
094             * @return Matrix with the entries plus the value
095             */
096            public Matrix plus(Ret returnType, boolean ignoreNaN, double value) throws MatrixException;
097    
098            /**
099             * Calculates the sum of the entries in both matrices
100             * 
101             * @param returnType
102             *            Defines if a new Matrix or a link should be returned.
103             * @param ignoreNaN
104             *            should missing values be ignored
105             * @param matrix
106             *            The matrix to subtract
107             * @return matrix with sum values
108             */
109            public Matrix plus(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException;
110    
111            /**
112             * Calculates the difference of the entries in both matrices
113             * 
114             * @param matrix
115             *            The matrix to subtract
116             * @return matrix with difference values
117             */
118            public Matrix minus(Matrix matrix) throws MatrixException;
119    
120            /**
121             * Calculates the entrywise product of the two matrices.
122             * 
123             * @param matrix
124             *            the second matrix
125             * @return matrix with product of all entries
126             */
127            public Matrix times(Matrix matrix) throws MatrixException;
128    
129            /**
130             * Multiplies every entry in the matrix with a scalar.
131             * 
132             * @param value
133             *            factor to multiply with
134             * @return Matrix with all entries multiplied by a factor.
135             */
136            public Matrix times(double value) throws MatrixException;
137    
138            /**
139             * Multiplies every entry in the matrix with a scalar.
140             * 
141             * @param returnType
142             *            Defines if a new Matrix or a link should be returned.
143             * @param ignoreNaN
144             *            should missing values be ignored
145             * @param value
146             *            factor to multiply with
147             * @return Matrix with all entries multiplied by a factor.
148             */
149            public Matrix times(Ret returnType, boolean ignoreNaN, double value) throws MatrixException;
150    
151            /**
152             * Multiplies every entry in the matrix with the entries of another Matrix.
153             * 
154             * @param returnType
155             *            Defines if a new Matrix or a link should be returned.
156             * @param ignoreNaN
157             *            should missing values be ignored
158             * @param value
159             *            factor to multiply with
160             * @return Matrix with all entries multiplied by a factor.
161             */
162            public Matrix times(Ret returnType, boolean ignoreNaN, Matrix value) throws MatrixException;
163    
164            /**
165             * Calculates an entrywise division of the two matrices.
166             * 
167             * @param matrix
168             *            the second matrix
169             * @return matrix with all entries divided by the second matrix's entry.
170             */
171            public Matrix divide(Matrix matrix) throws MatrixException;
172    
173            /**
174             * Divides every entry in the matrix by a scalar.
175             * 
176             * @param value
177             *            factor by which to divide
178             * @return Matrix with all entries divided by a factor.
179             */
180            public Matrix divide(double value) throws MatrixException;
181    
182            /**
183             * Divides every entry in the matrix by a scalar.
184             * 
185             * @param returnType
186             *            Defines if a new Matrix or a link should be returned.
187             * @param ignoreNaN
188             *            should missing values be ignored
189             * @param value
190             *            factor by which to divide
191             * 
192             * @return Matrix with all entries divided by a factor.
193             */
194            public Matrix divide(Ret returnType, boolean ignoreNaN, double value) throws MatrixException;
195    
196            /**
197             * Divides every entry in the matrix by the entries of another matrix.
198             * 
199             * @param returnType
200             *            Defines if a new Matrix or a link should be returned.
201             * @param ignoreNaN
202             *            should missing values be ignored
203             * @param value
204             *            factor by which to divide
205             * 
206             * @return Matrix with all entries divided by a factor.
207             */
208            public Matrix divide(Ret returnType, boolean ignoreNaN, Matrix value) throws MatrixException;
209    
210            /**
211             * Performs a matrix multiplication on the two matrices. The matrices must
212             * be 2-dimensional and have the correct size.
213             * 
214             * @param matrix
215             *            the second matrix
216             * @return Matrix product
217             */
218            public Matrix mtimes(Matrix matrix) throws MatrixException;
219    
220            /**
221             * Performs a matrix multiplication on the two matrices. The matrices must
222             * be 2-dimensional and have the correct size.
223             * 
224             * @param returnType
225             *            Defines if a new Matrix or a link should be returned.
226             * @param ignoreNaN
227             *            should missing values be ignored
228             * @param matrix
229             *            the second matrix
230             * @return Matrix product
231             */
232            public Matrix mtimes(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException;
233    
234            /**
235             * Equal to times()
236             * 
237             * @param value
238             *            the value
239             * @return Matrix product
240             */
241            public Matrix mtimes(double value) throws MatrixException;
242    
243            /**
244             * Equal to times()
245             * 
246             * @param returnType
247             *            Defines if a new Matrix or a link should be returned.
248             * @param ignoreNaN
249             *            should missing values be ignored
250             * @param value
251             *            the value to multiply
252             * @return Matrix product
253             */
254            public Matrix mtimes(Ret returnType, boolean ignoreNaN, double value) throws MatrixException;
255    
256            /**
257             * Performs an averaging matrix multiplication on the two matrices. The
258             * matrices must be 2-dimensional and have the correct size.
259             * 
260             * @param returnType
261             *            Defines if a new Matrix or a link should be returned.
262             * @param ignoreNaN
263             *            should missing values be ignored
264             * @param matrix
265             *            the second matrix
266             * @return Matrix product
267             */
268            public Matrix atimes(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException;
269    
270    }