private float[][] lines23b() { if (_transpose23) { float xa2 = (float)_s2.getValue(0); float xk2 = (float)_s2.getValue(_k2); float xb2 = (float)_s2.getValue(_n2-1); return new float[][]{{xa2,xb2},{xk2,xk2}}; } else { float xa3 = (float)_s3.getValue(0); float xk3 = (float)_s3.getValue(_k3); float xb3 = (float)_s3.getValue(_n3-1); return new float[][]{{xa3,xb3},{xk3,xk3}}; } }
private float[][] lines23a() { if (_transpose23) { float xa3 = (float)_s3.getValue(0); float xk3 = (float)_s3.getValue(_k3); float xb3 = (float)_s3.getValue(_n3-1); return new float[][]{{xk3,xk3},{xa3,xb3}}; } else { float xa2 = (float)_s2.getValue(0); float xk2 = (float)_s2.getValue(_k2); float xb2 = (float)_s2.getValue(_n2-1); return new float[][]{{xk2,xk2},{xa2,xb2}}; } } private float[][] lines23b() {
/** * Removes this trend from the specified samples. * @param f array of sample values to be detrended. * @param s1 sampling of x1 coordinates. * @param s2 sampling of x2 coordinates. */ public void detrend(float[][] f, Sampling s1, Sampling s2) { int n2 = f.length; int n1 = f[0].length; for (int i2=0; i2<n2; ++i2) { float x2 = (float)s2.getValue(i2); for (int i1=0; i1<n1; ++i1) { float x1 = (float)s1.getValue(i1); f[i2][i1] = detrend(f[i2][i1],x1,x2); } } }
/** * Restores this trend to the specified samples. * @param f array of sample values to be restored. * @param s1 sampling of x1 coordinates. * @param s2 sampling of x2 coordinates. */ public void restore(float[][] f, Sampling s1, Sampling s2) { int n2 = f.length; int n1 = f[0].length; for (int i2=0; i2<n2; ++i2) { float x2 = (float)s2.getValue(i2); for (int i1=0; i1<n1; ++i1) { float x1 = (float)s1.getValue(i1); f[i2][i1] = restore(f[i2][i1],x1,x2); } } }
/** * Returns the value of the sample nearest to the specified value. * @param x the value. * @return the value of the nearest sample. */ public double valueOfNearest(double x) { return getValue(indexOfNearest(x)); }
/** * Updates the contours for this view. */ private void updateContours() { if (_cl==null) { int nc = _cs.getCount(); _cl = new ArrayList<Contour>(); for (int ic=0; ic<nc; ++ic) { float fc = (float)_cs.getValue(ic); Contour c = makeContour(fc,_s1,_s2,_f); _cl.add(c); } } }
/** * Sets (x1,x2) coordinates for a sampled function x2(x1). * @param s1 the sampling of x1 coordinates. * @param x2 array of x2 coordinates. */ public void set(Sampling s1, float[] x2) { Check.argument(s1.getCount()==x2.length,"s1 count equals x2 length"); int n1 = x2.length; float[] x1 = new float[n1]; for (int i1=0; i1<n1; ++i1) x1[i1] = (float)s1.getValue(i1); set(x1,x2); }
/** * Constructs a view of bars with multiple plot segments. * @param s1 the sampling of x1 coordinates. * @param x2 array of x2 values, containing x2.length plot segments. */ public BarsView(Sampling s1, float[][] x2) { Check.argument(s1.getCount()==x2[0].length,"s1 count equals x2 length"); int n1 = x2[0].length; int n2 = x2.length; float[][] x1 = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) x1[i2][i1] = (float)s1.getValue(i1); set(x1,x2); }
/** * Sets (x1,x2) coordinates for a sampled function x2(x1). * @param s1 the sampling of x1 coordinates. * @param x2 array of x2 coordinates. */ public void set(Sampling s1, float[] x2) { Check.argument(s1.getCount()==x2.length,"s1 count equals x2 length"); int n1 = x2.length; float[] x1 = new float[n1]; for (int i1=0; i1<n1; ++i1) x1[i1] = (float)s1.getValue(i1); set(x1,x2); }
public float[][] sampleUniform2(Sampling s1, Sampling s2) { int n1 = s1.getCount(); int n2 = s2.getCount(); float[][] f = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) { float x2 = (float)s2.getValue(i2); for (int i1=0; i1<n1; ++i1) { float x1 = (float)s1.getValue(i1); f[i2][i1] = f(x1,x2); } } return f; }
public float[][][] sampleUniform2(Sampling s1, Sampling s2, Sampling s3) { int n1 = s1.getCount(); int n2 = s2.getCount(); int n3 = s3.getCount(); float[][][] f = new float[n3][n2][n1]; for (int i3=0; i3<n3; ++i3) { float x3 = (float)s3.getValue(i3); for (int i2=0; i2<n2; ++i2) { float x2 = (float)s2.getValue(i2); for (int i1=0; i1<n1; ++i1) { float x1 = (float)s1.getValue(i1); f[i3][i2][i1] = f(x1,x2,x3); } } } return f; }
private void testLinear(SibsonInterpolator2.Method m) { TestFunction tf = TestFunction.makeLinear(); float[][] fx = tf.sampleUniform2(NS,XMIN,XMAX,XMIN,XMAX); float[] f = fx[0], x1 = fx[1], x2 = fx[2]; SibsonInterpolator2 si = new SibsonInterpolator2(m,f,x1,x2); si.setNullValue(999.0f); int n1 = NX, n2 = NX; Sampling s1 = SX, s2 = SX; float[][] g = si.interpolate(s1,s2); for (int i2=0; i2<n2; ++i2) { float x2i = (float)s2.getValue(i2); for (int i1=0; i1<n1; ++i1) { float x1i = (float)s1.getValue(i1); float fe = tf.f(x1i,x2i); assertEquals(fe,g[i2][i1]); } } }