Compute the effective band size.

@param dim1 First dimensionality
@param dim2 Second dimensionality
@return Effective bandsize
509497
protected int effectiveBandSize(final int dim1, final int dim2) {
    if(bandSize == Double.POSITIVE_INFINITY) {
      return (dim1 > dim2) ? dim1 : dim2;
    }
    if(bandSize >= 1.) {
      return (int) bandSize;
    }
    // Max * bandSize:
    return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize);
  }
763001
public static AffineTransformation axisProjection(int dim, int ax1, int ax2) {
    // setup a projection to get the data into the interval -1:+1 in each
    // dimension with the intended-to-see dimensions first.
    AffineTransformation proj = AffineTransformation.reorderAxesTransformation(dim, ax1, ax2);
    // Assuming that the data was normalized on [0:1], center it:
    double[] trans = new double[dim];
    for(int i = 0; i < dim; i++) {
      trans[i] = -.5;
    }
    proj.addTranslation(trans);
    // mirror on the y axis, since the SVG coordinate system is screen
    // coordinates (y = down) and not mathematical coordinates (y = up)
    proj.addAxisReflection(2);
    // scale it up
    proj.addScaling(SCALE);

    return proj;
  }
660855
public static INDArray min(INDArray x, INDArray y, INDArray z, int... dimensions) {
        if(dimensions == null || dimensions.length == 0) {
            validateShapesNoDimCase(x,y,z);
            return Nd4j.getExecutioner().exec(new OldMin(x,y,z));
        }


        return Nd4j.getExecutioner().exec(new BroadcastMin(x,y,z,dimensions));
    }
586805
public static double calPairwiseVariance(long count1, double sum1,
            double variance1, long count2, double sum2, double variance2) {
        return (variance1 * (count1 - 1) + variance2 * (count2 - 1)
                + pow(sum2 / count2 - sum1 / count1, 2) * count1 * count2
                / (count1 + count2))
                / (count1 + count2 - 1);
    }
119805
public static double[] timesPlusTimes(final double[] v1, final double s1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] result = new double[v1.length];
    for(int i = 0; i < result.length; i++) {
      result[i] = v1[i] * s1 + v2[i] * s2;
    }
    return result;
  }
865646
def makeBands(inputlist, numberOfBands):
    
    if numberOfBands < 2:
        return inputlist
    vmin = np.min(inputlist)
    vmax = np.max(inputlist)
    bb = np.linspace(vmin, vmax, numberOfBands, endpoint=0)
    dr = bb[1] - bb[0]
    bb += dr / 2
    tol = dr / 2 * 1.001

    newlist = []
    for s in inputlist:
        for b in bb:
            if abs(s - b) < tol:
                newlist.append(b)
                break

    return np.array(newlist)
347580
public double[] getDimensions(){

		double[] dim = new double[3];

		dim[0] = xmax-xmin;
		dim[1] = ymax-ymin;
		dim[2] = zmax-zmin;

		return dim;

	}
1119698
def dims_intersect(self):
        
        return set.intersection(*map(
            set, (getattr(arr, 'dims_intersect', arr.dims) for arr in self)))
360081
public static double dotSparse(SparseNumberVector v1, SparseNumberVector v2) {
    double dot = 0.;
    int i1 = v1.iter(), i2 = v2.iter();
    while(v1.iterValid(i1) && v2.iterValid(i2)) {
      final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2);
      if(d1 < d2) {
        i1 = v1.iterAdvance(i1);
      }
      else if(d2 < d1) {
        i2 = v2.iterAdvance(i2);
      }
      else { // d1 == d2
        dot += v1.iterDoubleValue(i1) * v2.iterDoubleValue(i2);
        i1 = v1.iterAdvance(i1);
        i2 = v2.iterAdvance(i2);
      }
    }
    return dot;
  }
830383
public static double[] times(final double[][] m1, final double[] v2) {
    final int rowdim = m1.length, coldim = getColumnDimensionality(m1);
    assert v2.length == coldim : ERR_MATRIX_INNERDIM;
    final double[] re = new double[rowdim];
    // multiply it with each row from A
    for(int i = 0; i < rowdim; i++) {
      final double[] Arowi = m1[i];
      // assert Arowi.length == coldim : ERR_MATRIX_RAGGED;
      double s = 0;
      for(int k = 0; k < coldim; k++) {
        s += Arowi[k] * v2[k];
      }
      re[i] = s;
    }
    return re;
  }
1031887
public final static Sample mix(Sample sample1, double volAdj1,
                                   Sample sample2, double volAdj2) {
        double[] s1_ary = sample1.getInterleavedSamples();
        double[] s2_ary = sample2.getInterleavedSamples();

        //
        double[] mixed = mix(s1_ary, volAdj1, s2_ary, volAdj2);

        return buildSample(sample1.getSampleCount(), mixed);
    }
352017
public int size(final K1 firstKey, final K2 secondKey) {
		// existence check on inner map
		final HashMap<K2, HashMap<K3, V>> innerMap1 = map.get(firstKey);
		if( innerMap1 == null ) {
			return 0;
		}
		
		// existence check on inner map1
		final HashMap<K3, V> innerMap2 = innerMap1.get(secondKey);
		if( innerMap2 == null ) {
			return 0;
		}
		return innerMap2.size();
	}
815027
protected double sqDist(double[] v1, double[] v2) {
    assert (v1.length == v2.length) : "Lengths do not agree: " + v1.length + " " + v2.length;
    double sum = 0;
    for(int i = 0; i < v1.length; i++) {
      final double diff = v1[i] - v2[i];
      sum += diff * diff;
    }
    ++projectedDistances;
    return sum;
  }
80842
public int[] getDims() {
        int[] dims = new int[size()];
        for (int i = 0; i < size(); i++) {
            dims[i] = get(i).getNumStates();
        }
        return dims;
    }
373077
public static INDArray mul(INDArray x, INDArray y, INDArray z, int... dimensions) {
        if(dimensions == null || dimensions.length == 0) {
            validateShapesNoDimCase(x,y,z);
            return Nd4j.getExecutioner().exec(new OldMulOp(x,y,z));
        }

        return Nd4j.getExecutioner().exec(new BroadcastMulOp(x,y,z,dimensions));
    }
557752
public static final DoubleMatrix1D add(DoubleMatrix1D v1, DoubleMatrix1D v2, double c){
		if(v1.size()!=v2.size()){
			throw new IllegalArgumentException("wrong vectors dimensions");
		}
		DoubleMatrix1D ret = DoubleFactory1D.dense.make(v1.size());
		for(int i=0; i<ret.size(); i++){
			ret.setQuick(i, v1.getQuick(i) + c*v2.getQuick(i));
		}

		return ret;
	}
521795
public double distance(double[] v1, double[] v2) {
    final int dim1 = v1.length, dim2 = v2.length;
    final int mindim = dim1 < dim2 ? dim1 : dim2;
    double agg = preDistance(v1, v2, 0, mindim);
    if(dim1 > mindim) {
      agg += preNorm(v1, mindim, dim1);
    }
    else if(dim2 > mindim) {
      agg += preNorm(v2, mindim, dim2);
    }
    return agg;
  }