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.entrywise.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 BasicEntrywiseDoubleCalculations { 031 032 /** 033 * Calculates the absolute values of all entries in a Matrix. Positive 034 * values stay the same, negative values change sign. 035 * 036 * @param returnType 037 * Select whether a new or a linked Matrix is returned, or if the 038 * operation is performed on the original Matrix 039 * @return A new Matrix with absolute values. 040 */ 041 public Matrix abs(Ret returnType) throws MatrixException; 042 043 /** 044 * Calculates the logarithm with basis 2 of all entries in the Matrix. 045 * 046 * @param returnType 047 * Select whether a new or a linked Matrix is returned, or if the 048 * operation is performed on the original Matrix 049 * @return Matrix with logarithm values. 050 */ 051 public Matrix log2(Ret returnType) throws MatrixException; 052 053 /** 054 * Calculates the logarithm with basis 10 of all entries in the Matrix. 055 * 056 * @param returnType 057 * Select whether a new or a linked Matrix is returned, or if the 058 * operation is performed on the original Matrix 059 * @return Matrix with logarithm values. 060 */ 061 public Matrix log10(Ret returnType) throws MatrixException; 062 063 /** 064 * Calculates the natural logarithm of all entries in the Matrix. 065 * 066 * @param returnType 067 * Select whether a new or a linked Matrix is returned, or if the 068 * operation is performed on the original Matrix 069 * @return Matrix with logarithm values. 070 */ 071 public Matrix log(Ret returnType) throws MatrixException; 072 073 /** 074 * Calculates the exponential function all entries in the Matrix. 075 * 076 * @param returnType 077 * Select whether a new or a linked Matrix is returned, or if the 078 * operation is performed on the original Matrix 079 * @return Matrix with exp values. 080 */ 081 public Matrix exp(Ret returnType) throws MatrixException; 082 083 /** 084 * Calculates the sign of the entries in a Matrix. For values greater than 085 * zero, 1.0 is returned. Negative values will give -1.0 as return value. 086 * 0.0 is returned for entries equal to zero. 087 * 088 * @param returnType 089 * Select whether a new or a linked Matrix is returned, or if the 090 * operation is performed on the original Matrix 091 * @return Matrix with signum values 092 */ 093 public Matrix sign(Ret returnType) throws MatrixException; 094 095 /** 096 * Calculates the square root of all the entries in a Matrix. 097 * 098 * @param returnType 099 * Select whether a new or a linked Matrix is returned, or if the 100 * operation is performed on the original Matrix 101 * @return Matrix containing the square roots of all entries 102 */ 103 public Matrix sqrt(Ret returnType) throws MatrixException; 104 105 /** 106 * Calculates this matrix to the power of the given matrix (entrywise). 107 * 108 * @param returnType 109 * Select whether a new or a linked Matrix is returned, or if the 110 * operation is performed on the original Matrix 111 * @param matrix 112 * the second matrix 113 * @return matrix with all entries to the power of the second matrix's 114 * entry. 115 */ 116 public Matrix power(Ret returnType, Matrix power) throws MatrixException; 117 118 /** 119 * Calculates this matrix to the power of the given value (entrywise). 120 * 121 * @param returnType 122 * Select whether a new or a linked Matrix is returned, or if the 123 * operation is performed on the original Matrix 124 * @param value 125 * power factor 126 * @return Matrix with all entries to the power of factor. 127 */ 128 public Matrix power(Ret returnType, double power) throws MatrixException; 129 130 }