/** * Constructs a function with specified sampling and values zero. * @param s the sampling. */ public Real1(Sampling s) { _s = s; _v = new float[s.getCount()]; }
/** * Gets the number of bins in this histogram. * @return the number of bins. */ public int getBinCount() { return _sbin.getCount(); }
private float[][][] pad(float[][][] f) { int nk1 = _sk1.getCount(); int nk2 = _sk2.getCount(); int nk3 = _sk3.getCount(); float[][][] fpad = new float[nk3][nk2][2*nk1]; if (_complex) { ccopy(f[0][0].length/2,f[0].length,f.length,f,fpad); } else { copy(f[0][0].length,f[0].length,f.length,f,fpad); } return fpad; }
/** * Gets the contour values. * @return array of contour values. */ public float[] getContours() { updateContourSampling(); float[] values = new float[_cs.getCount()]; for (int n=0; n<values.length; n++) values[n] = _cl.get(n).fc; return values; }
/** * Constructs a function with specified sampling and values. * @param s the sampling. * @param v array of function values; referenced, not copied. * The array length v.length must equal the number of samples in s. */ public Real1(Sampling s, float[] v) { Check.argument(s.getCount()==v.length, "v.length equals the number of samples in s"); _s = s; _v = v; }
/** * Returns a function with constant values. * @param ar the constant. * @param s the sampling. * @return the function. */ public static Real1 fill(double ar, Sampling s) { int n = s.getCount(); return new Real1(s, fillfloat((float)ar,n)); }
private float[] pad(float[] f) { int nk1 = _sk1.getCount(); float[] fpad = new float[2*nk1]; if (_complex) { ccopy(f.length/2,f,fpad); } else { copy(f.length,f,fpad); } return fpad; } private float[][] pad(float[][] f) {
private void ensureSamplingX1(float[] f) { Check.state(_sx1!=null,"sampling sx1 exists for 1st dimension"); int l1 = f.length; int n1 = _sx1.getCount(); if (_complex) n1 *= 2; Check.argument(n1==l1,"array length consistent with sampling sx1"); } private void ensureSamplingX2(float[][] f) {
private void ensureSamplingX3(float[][][] f) { Check.state(_sx3!=null,"sampling sx3 exists for 3rd dimension"); ensureSamplingX2(f[0]); int l3 = f.length; int n3 = _sx3.getCount(); Check.argument(n3==l3,"array length consistent with sampling sx3"); }
private void ensureSamplingK3(float[][][] f) { Check.state(_sk3!=null,"sampling sk3 exists for 3rd dimension"); ensureSamplingK2(f[0]); int l3 = f.length; int n3 = _sk3.getCount(); Check.argument(n3==l3,"array length consistent with sampling sk3"); }
private void ensureSamplingX2(float[][] f) { Check.state(_sx2!=null,"sampling sx2 exists for 2nd dimension"); ensureSamplingX1(f[0]); int l2 = f.length; int n2 = _sx2.getCount(); Check.argument(n2==l2,"array length consistent with sampling sx2"); } private void ensureSamplingX3(float[][][] f) {
private void ensureSamplingK2(float[][] f) { Check.state(_sk2!=null,"sampling sk2 exists for 2nd dimension"); ensureSamplingK1(f[0]); int l2 = f.length; int n2 = _sk2.getCount(); Check.argument(n2==l2,"array length consistent with sampling sk2"); } private void ensureSamplingK3(float[][][] f) {
private static int[] makeIndices(Sampling si, float[] xs) { int n = si.getCount(); int[] ki = new int[n]; ki[0] = index((float)si.getValue(0),xs,0); for (int i=1; i<n; ++i) ki[i] = index((float)si.getValue(i),xs,ki[i-1]); return ki; }
private static int[] makeIndices(Sampling si, float[] xs) { int n = si.getCount(); int[] ki = new int[n]; ki[0] = index((float)si.getValue(0),xs,0); for (int i=1; i<n; ++i) ki[i] = index((float)si.getValue(i),xs,ki[i-1]); return ki; }
private static int[] makeIndices(Sampling si, float[] xs) { int n = si.getCount(); int[] ki = new int[n]; ki[0] = index((float)si.getValue(0),xs,0); for (int i=1; i<n; ++i) ki[i] = index((float)si.getValue(i),xs,ki[i-1]); return ki; }
/** * Sets specified sampling and function values. * @param sx the sampling of the variable x. * @param f array of sampled function values f(x). */ public void set(Sampling sx, float[] f) { Check.argument(sx.getCount()==f.length,"sx count equals length of f"); _sx = sx; _f = copy(f); updateBestProjectors(); repaint(); }
/** * Interpolates one real value y(x). * @param sxu sampling of input samples. * @param yu input array of uniformly sampled values y(x). * @param xi value x at which to interpolate. * @return interpolated value y(x). */ public float interpolate(Sampling sxu, float[] yu, double xi) { Check.argument(sxu.isUniform(),"input sampling is uniform"); return interpolate(sxu.getCount(),sxu.getDelta(),sxu.getFirst(),yu,xi); }