<p>
Returns the result of scaling each element by 'val':<br>
b<sub>i,j</sub> = val*a<sub>i,j</sub>
</p>

@see CommonOps_DDRM#scale(double, DMatrixD1)

@param val The multiplication factor.
@return The scaled matrix.
345146
public T scale( double val ) {
        T ret = createLike();
        ops.scale(mat,val,ret.getMatrix());
        return ret;
    }
197081
def scale(val, src, dst):
    
    if val < src[0]:
        return dst[0]
    if val > src[1]:
        return dst[1]

    return ((val - src[0]) / (src[1] - src[0])) * (dst[1] - dst[0]) + dst[0]
1285072
@Override
	public DoubleMatrix1D[] getMatrixScalingFactors(DoubleMatrix2D A){
		DoubleFactory1D F1 = DoubleFactory1D.dense;
		Algebra ALG = Algebra.DEFAULT;
		int r = A.rows();
		int c = A.columns();
		DoubleMatrix1D D1 = F1.make(r, 1);
		DoubleMatrix1D D2 = F1.make(c, 1);
		DoubleMatrix2D AK = A.copy();
		DoubleMatrix1D DR = F1.make(r, 1);
		DoubleMatrix1D DC = F1.make(c, 1);
		DoubleMatrix1D DRInv = F1.make(r);
		DoubleMatrix1D DCInv = F1.make(c);
		log.debug("eps  : " + eps);
		int maxIteration = 50;
		for(int k=0; k<=maxIteration; k++){
			double normR = -Double.MAX_VALUE;
			double normC = -Double.MAX_VALUE;
			for(int i=0; i<r; i++){
				double dri = ALG.normInfinity(AK.viewRow(i));
				DR.setQuick(i, Math.sqrt(dri));
				DRInv.setQuick(i, 1./Math.sqrt(dri));
				normR = Math.max(normR, Math.abs(1-dri));
			}
			for(int j=0; j<c; j++){
				double dci = ALG.normInfinity(AK.viewColumn(j));
				DC.setQuick(j, Math.sqrt(dci));
				DCInv.setQuick(j, 1./Math.sqrt(dci));
				normC = Math.max(normC, Math.abs(1-dci));
			}
			
			log.debug("normR: " + normR);
			log.debug("normC: " + normC);
			if(normR < eps && normC < eps){
				break;
			}
			
			//D1 = ALG.mult(D1, DRInv);
			for(int i=0; i<r; i++){
				double prevD1I = D1.getQuick(i);
				double newD1I = prevD1I * DRInv.getQuick(i);
				D1.setQuick(i, newD1I);
			}
			//D2 = ALG.mult(D2, DCInv);
			for(int j=0; j<c; j++){
				double prevD2J = D2.getQuick(j);
				double newD2J = prevD2J * DCInv.getQuick(j);
				D2.setQuick(j, newD2J);
			}
			//log.debug("D1: " + ArrayUtils.toString(D1.toArray()));
			//log.debug("D2: " + ArrayUtils.toString(D2.toArray()));
			
			if(k==maxIteration){
				log.warn("max iteration reached");
			}
			
			//AK = ALG.mult(DRInv, ALG.mult(AK, DCInv));
			AK = ColtUtils.diagonalMatrixMult(DRInv, AK, DCInv);
		}
		
		return new DoubleMatrix1D[]{D1, D2};
	}
224198
public Matrix4f scale(Vector3fc xyz, Matrix4f dest) {
        return scale(xyz.x(), xyz.y(), xyz.z(), dest);
    }
876978
public Rational multiply(final int val) {
        BigInteger tmp = BigInteger.valueOf(val);
        return multiply(tmp);
    }
363907
public Rational divide(BigInteger val) {
        Rational val2 = new Rational(val, BigInteger.ONE);
        return (divide(val2));
    }
577061
public void multiplyValue(int idx, double val) {
        int c = get1dConfigIdx(idx);
        values.set(c, s.times(values.get(c), val));
    }
1306061
@Override
  public void put(double val, double weight) {
    if(weight <= 0) {
      return;
    }
    if(this.n == 0) {
      n = weight;
      min = max = val;
      sum = val * weight;
      m2 = m3 = m4 = 0;
      return;
    }
    final double nn = weight + this.n;
    final double deltan = val * this.n - this.sum;
    final double inc = deltan * weight;

    // Some factors used below:
    final double delta_nn = deltan / (this.n * nn);
    final double delta_nnw = delta_nn * weight;
    final double delta_nn2 = delta_nn * delta_nn;
    final double delta_nn3 = delta_nn2 * delta_nn;
    final double nb2 = weight * weight;

    final double tmp1 = this.n - weight;
    final double tmp2 = this.n * tmp1 + nb2;
    this.m4 += inc * delta_nn3 * tmp2 + 6. * nb2 * this.m2 * delta_nn2 - 4. * this.m3 * delta_nnw;
    this.m3 += inc * delta_nn2 * tmp1 - 3. * this.m2 * delta_nnw;
    this.m2 += inc * delta_nn;
    this.sum += weight * val;
    this.n = nn;

    min = val < min ? val : min;
    max = val > max ? val : max;
  }
1119921
public static double[] colMeans(double[][] data) {
        double[] x = data[0].clone();

        for (int i = 1; i < data.length; i++) {
            for (int j = 0; j < x.length; j++) {
                x[j] += data[i][j];
            }
        }

        scale(1.0 / data.length, x);

        return x;
    }
1159983
public void divide(double val) {
        for (int c = 0; c < this.values.length; c++) {
            divideValue(c, val);
        }
    }
368751
public static int safeMultiply(int val1, int val2) {
        long total = (long) val1 * (long) val2;
        if (total < Integer.MIN_VALUE || total > Integer.MAX_VALUE) {
          throw new ArithmeticException("Multiplication overflows an int: " + val1 + " * " + val2);
        }
        return (int) total;
    }
204589
public void put(double[] val) {
    assert (val.length == elements.length);
    wsum += 1.0;
    for(int i = 0; i < elements.length; i++) {
      final double delta = val[i] - elements[i];
      elements[i] += delta / wsum;
    }
  }
654382
public static double quantile(double val, double shape, double location, double scale) {
    return val < 0 || val > 1 ? Double.NaN : scale * FastMath.pow(val / (1. - val), 1. / shape) + location;
  }
170709
public byte[][] getScaledMatrix(int xScale, int yScale) {
    byte[][] matrixOut = new byte[height * yScale][width * xScale];
    int yMax = height * yScale;
    for (int i = 0; i < yMax; i++) {
      matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
    }
    return matrixOut;
  }
1224945
public Matrix3f scale(Vector3fc xyz, Matrix3f dest) {
        return scale(xyz.x(), xyz.y(), xyz.z(), dest);
    }
826238
public BigInteger toBigInteger(Object val) {
    if (val == null) {
      return BigInteger.ZERO;
    }
    else if (val instanceof BigInteger) {
      return (BigInteger) val;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return new BigInteger(val.toString());
      }
      else {
        return BigInteger.ZERO;
      }
    }
    else if (val instanceof Number) {
      return new BigInteger(val.toString());
    }
    else if (val instanceof String) {
      String string = (String) val;
      if ("".equals(string.trim())) {
        return BigInteger.ZERO;
      }
      else {
        return new BigInteger(string);
      }
    }
    else if (val instanceof Character) {
      int i = ((Character) val).charValue();
      return BigInteger.valueOf(i);
    }

    throw new ArithmeticException("BigInteger coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
20160
public static double logquantile(double val, double loc, double scale) {
    return loc + scale * (val - MathUtil.log1mexp(-val));
  }