Applies the <i>natural logarithm</i> function element-wise on this
matrix. Note that this is an in-place operation.
@see MatrixFunctions#log(DoubleMatrix)
@return this matrix
772562
public static DoubleMatrix logi(DoubleMatrix x) {
		/*# mapfct('Math.log') #*/
//RJPP-BEGIN------------------------------------------------------------
	   for (int i = 0; i < x.length; i++)
	      x.put(i, (double) Math.log(x.get(i)));
	   return x;
//RJPP-END--------------------------------------------------------------
	}
395984
public double[] getColumn(int col) {
    double[] column = new double[numRows];
    int offset = translate(0, col, numRows);
    for (int i = 0; i < column.length; i++) {
      column[i] = matrix[offset + i];
    }
    return column;
  }
1077736
public static double[][] transpose(double[][] matrix){

		//Get number of rows and columns of matrix
		int numberOfRows = matrix.length;
		int numberOfCols = matrix[0].length;

		//Instantiate a unitMatrix of dimension dim
		double[][] transpose = new double[numberOfCols][numberOfRows];

		//Create unit matrix
		for(int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {
			for(int colIndex = 0; colIndex < numberOfCols; colIndex++) {
				transpose[colIndex][rowIndex] = matrix[rowIndex][colIndex];
			}
		}
		return transpose;
	}
1003913
public Matrix getL () {
      Matrix X = MatrixFactory.createMatrix(m,n);
      for (int i = 0; i < m; i++) {
         for (int j = 0; j < n; j++) {
            if (i > j) {
					X.set(i, j, LU[i][j]);
            } else if (i == j) {
               X.set(i, j, 1);
            }
         }
      }
      return X;
   }
872773
public Object apply(Object pValue,
                        Object pContext,
                        Logger pLogger)
            throws ELException {
        if (pValue == null) {
            /*
            if (pLogger.isLoggingWarning ()) {
          pLogger.logWarning
            (Constants.ARITH_OP_NULL,
             getOperatorSymbol ());
            }
            */
            return PrimitiveObjects.getInteger(0);
        } else if (pValue instanceof String) {
            if (Coercions.isFloatingPointString(pValue)) {
                double dval =
                        ((Number)
                                (Coercions.coerceToPrimitiveNumber
                                        (pValue, Double.class, pLogger))).
                                doubleValue();
                return PrimitiveObjects.getDouble(-dval);
            } else {
                long lval =
                        ((Number)
                                (Coercions.coerceToPrimitiveNumber
                                        (pValue, Long.class, pLogger))).
                                longValue();
                return PrimitiveObjects.getLong(-lval);
            }
        } else if (pValue instanceof Byte) {
            return PrimitiveObjects.getByte
                    ((byte) -(((Byte) pValue).byteValue()));
        } else if (pValue instanceof Short) {
            return PrimitiveObjects.getShort
                    ((short) -(((Short) pValue).shortValue()));
        } else if (pValue instanceof Integer) {
            return PrimitiveObjects.getInteger
                    ((int) -(((Integer) pValue).intValue()));
        } else if (pValue instanceof Long) {
            return PrimitiveObjects.getLong
                    ((long) -(((Long) pValue).longValue()));
        } else if (pValue instanceof Float) {
            return PrimitiveObjects.getFloat
                    ((float) -(((Float) pValue).floatValue()));
        } else if (pValue instanceof Double) {
            return PrimitiveObjects.getDouble
                    ((double) -(((Double) pValue).doubleValue()));
        } else {
            if (pLogger.isLoggingError()) {
                pLogger.logError
                        (Constants.UNARY_OP_BAD_TYPE,
                                getOperatorSymbol(),
                                pValue.getClass().getName());
            }
            return PrimitiveObjects.getInteger(0);
        }
    }
1159906
public static MatrixFunction asModFunction(final double arg) {
        return new MatrixFunction() {
            @Override
            public double evaluate(int i, int j, double value) {
                return value % arg;
            }
        };
    }
155603
@Override
    public DoubleMatrix transpose()
    {
        int m = rows();
        int n = columns();
        ItemSupplier s = supplier;
        DoubleMatrix tr = getInstance(n, m);
        ItemConsumer c = tr.consumer;
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                c.set(j, i, s.get(i, j));
            }
        }
        return tr;
    }
1009577
public double valueSum() {

    // We want the exp(log-sum-exp), for stability
    // This rearranges to exp(a)*(sum-exp)

    double max = 0.0;
    for (int[] assignment : this) {
      double v = getAssignmentLogValue(assignment);
      if (v > max) {
        max = v;
      }
    }

    double sumExp = 0.0;
    for (int[] assignment : this) {
      double assigmentLogValue = getAssignmentLogValue(assignment);
      assert !Double.isNaN(assigmentLogValue);
      sumExp += Math.exp(getAssignmentLogValue(assignment) - max);
    }

    assert !Double.isNaN(sumExp);
    assert !Double.isNaN(max);
    return sumExp * Math.exp(max);
  }
778694
public Matrix transformColumn(int j, VectorFunction function) {
        Matrix result = copy();
        VectorIterator it = result.iteratorOfColumn(j);

        while (it.hasNext()) {
            double x = it.next();
            int i = it.index();
            it.set(function.evaluate(i, x));
        }

        return result;
    }
309994
private double logLikelihood(int[] contingencyTable) {
        // Rename for short-hand convenience
        int[] t = contingencyTable;
        int col1sum = t[0] + t[2];
        int col2sum = t[1] + t[3];
        int row1sum = t[0] + t[1];
        int row2sum = t[2] + t[3];
        double sum = row1sum + row2sum;
        
        // Calculate the expected values for a, b, c, d
        double aExp = (row1sum / sum) * col1sum;
        double bExp = (row1sum / sum) * col2sum;
        double cExp = (row2sum / sum) * col1sum;
        double dExp = (row2sum / sum) * col2sum;

        return 2 *
            ((t[0] * Math.log(t[0] - aExp))  +
             (t[1] * Math.log(t[1] - bExp))  +
             (t[2] * Math.log(t[2] - cExp))  +
             (t[3] * Math.log(t[3] - dExp)));
    }
662502
def log2(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_log2,
        (BigFloat._implicit_convert(x),),
        context,
    )
1071198
public static MatrixFunction asMulFunction(final double arg) {
        return new MatrixFunction() {
            @Override
            public double evaluate(int i, int j, double value) {
                return value * arg;
            }
        };
    }
1333119
public static double Log(double a, double b) {
        return Gamma.Log(a) + Gamma.Log(b) - Gamma.Log(a + b);
    }
11940
public static final DoubleMatrix2D fillSubdiagonalSymmetricMatrix(DoubleMatrix2D S){

		if(S.rows() != S.columns()){
			throw new IllegalArgumentException("Not square matrix");
		}

		boolean isSparse = S instanceof SparseDoubleMatrix2D;
		DoubleFactory2D F2D = (isSparse)? DoubleFactory2D.sparse: DoubleFactory2D.dense;
		final DoubleMatrix2D SFull = F2D.make(S.rows(), S.rows());

		if (isSparse) {
			S.forEachNonZero(new IntIntDoubleFunction() {
				@Override
				public double apply(int i, int j, double hij) {
					SFull.setQuick(i, j, hij);
					SFull.setQuick(j, i, hij);
					return hij;
				}
			});
		} else {
			for (int i = 0; i < S.rows(); i++) {
				for (int j = 0; j < i + 1; j++) {
					double sij = S.getQuick(i, j);
					SFull.setQuick(i, j, sij);
					SFull.setQuick(j, i, sij);
				}
			}
		}

		return SFull;
	}
952002
public T elementLog()
    {
        T c = createLike();
        ops.elementLog(mat,c.mat);
        return c;
    }
726495
private double getHalfLogDeterminant(CholeskyDecomposition chol) {
    double[][] l = chol.getL();
    double logdet = FastMath.log(l[0][0]);
    for(int i = 1; i < l.length; i++) {
      // We get half the log(det), because we did not square values here.
      logdet += FastMath.log(l[i][i]);
    }
    return logdet;
  }
1346026
public static MatrixFunction asDivFunction(final double arg) {
        return new MatrixFunction() {
            @Override
            public double evaluate(int i, int j, double value) {
                return value / arg;
            }
        };
    }