/** * Finds the k objects nearest to the specified point. * @param k the number of nearest objects to find. * @param point array of point coordinates. * @return the array of objects, ordered by increasing distance to the point. */ public Object[] findNearest(int k, float[] point) { Check.argument(point.length==_ndim,"point.length equals tree ndim"); Nearest nearest = new Nearest(k,point); _root.findNearest(nearest); return nearest.toArray(); }
private void initLags(int[] lag1) { Check.argument(lag1.length>0,"lag1.length>0"); Check.argument(lag1[0]==0,"lag1[0]==0"); for (int j=1; j<lag1.length; ++j) Check.argument(lag1[j]>0,"lag1["+j+"]>0"); _m = lag1.length; _lag1 = copy(lag1); _lag2 = zeroint(_m); _lag3 = zeroint(_m); _min1 = min(lag1); _max1 = max(lag1); }
public void testRandom() { int n1 = 10; int n2 = 11; int n3 = 12; float[][][] a = randfloat(n1,n2,n3); SimpleFloat3 sf3 = new SimpleFloat3(a); float[][][] c = copy(a); testRandom1(sf3,c); testRandom2(sf3,c); testRandom3(sf3,c); }
/** * Set the String values of a named parameter in this parameter set. * If this parameter set does not contain the named parameter, add * the parameter to this set before setting its values. * @param name name of the parameter. * @param values parameter values. */ public void setStrings(String name, String[] values) { Parameter par = getParameter(name); if (par==null) par = addParameter(name); par.setStrings(values); }
private void assertEquals(double e, double a) { double tiny = max(abs(e),abs(a))*100.0*DBL_EPSILON; assertEquals(e,a,tiny); } }
public static void dump(short[] rx) { ShortIterator li = new ShortIterator(rx); String[] s = format(li); dump(s); } public static void dump(short[][] rx) {
public static void dump(float[][] rx) { FloatIterator di = new FloatIterator(rx); String[] s = format(di); int n2 = rx.length; int[] n = new int[n2]; for (int i2=0; i2<n2; ++i2) n[i2] = rx[i2].length; dump(n,s); } public static void dump(float[][][] rx) {
public static void dump(double[] rx) { DoubleIterator di = new DoubleIterator(rx); String[] s = format(di); dump(s); } public static void dump(double[][] rx) {
public static Cdouble csum(double[][] cx) { int n2 = cx.length; Cdouble s = new Cdouble(); for (int i2=0; i2<n2; ++i2) s.plusEquals(csum(cx[i2])); return s; } public static Cdouble csum(double[][][] cx) {
public static void dump(int[][] rx) { IntIterator li = new IntIterator(rx); String[] s = format(li); int n2 = rx.length; int[] n = new int[n2]; for (int i2=0; i2<n2; ++i2) n[i2] = rx[i2].length; dump(n,s); } public static void dump(int[][][] rx) {
public static void cdump(double[] cx) { DoubleIterator di = new DoubleIterator(cx); String[] s = format(di); cdump(s); } public static void cdump(double[][] cx) {
private static void checkArrays(float[][][] x, float[][][] y) { Check.argument(x.length==y.length,"x.length==y.length"); Check.argument(x[0].length==y[0].length,"x[0].length==y[0].length"); Check.argument(x[0][0].length==y[0][0].length, "x[0][0].length==y[0][0].length"); Check.argument(isRegular(x),"x is regular"); Check.argument(isRegular(y),"y is regular"); }
/** * Returns the distance-squared from specified box to a point. */ float distanceSquared(Object box, float[] point) { if (box instanceof Node) { return ((Node)box).distanceSquared(point); } else { return _boxer.getDistanceSquared(box,point); } }
public static void cdump(double[][] cx) { DoubleIterator di = new DoubleIterator(cx); String[] s = format(di); int n2 = cx.length; int[] n = new int[n2]; for (int i2=0; i2<n2; ++i2) n[i2] = cx[i2].length/2; cdump(n,s); } public static void cdump(double[][][] cx) {