/** * Constructs a function with specified sampling and values zero. * @param n the number (count) of samples. * @param d the sampling interval (delta). * @param f the value of the first sample. */ public Real1(int n, double d, double f) { this(new Sampling(n,d,f)); }
/** * Constructs an FFT with specified numbers of space samples. * Sampling intervals are 1.0 and first sample coordinates are 0.0. * @param nx1 number of samples in the 1st dimension. * @param nx2 number of samples in the 2nd dimension. * @param nx3 number of samples in the 3rd dimension. */ public Fft(int nx1, int nx2, int nx3) { this(new Sampling(nx1,1.0,0.0), new Sampling(nx2,1.0,0.0), new Sampling(nx3,1.0,0.0)); }
/** * Constructs a function with specified values and default sampling. * The default sampling has number (count) of samples = v.length, sampling * interval (delta) = 1.0 and first sample value (first) = 0.0. * @param v array of function values; referenced, not copied. */ public Real1(float[] v) { _s = new Sampling(v.length,1.0,0.0); _v = v; }
/** * Constructs a function with specified sampling and values. * @param n the number (count) of time samples. * @param d the sampling interval (delta). * @param f the value of the first sample. * @param v array of function values; referenced, not copied. * The array length v.length must equal n. */ public Real1(int n, double d, double f, float[] v) { this(new Sampling(n,d,f),v); }
/** * Constructs an FFT with specified numbers of space samples. * Sampling intervals are 1.0 and first sample coordinates are 0.0. * @param nx1 number of samples in the 1st dimension. * @param nx2 number of samples in the 2nd dimension. */ public Fft(int nx1, int nx2) { this(new Sampling(nx1,1.0,0.0), new Sampling(nx2,1.0,0.0)); }
/** * Constructs an FFT with specified number of space samples. * The sampling interval is 1.0 and the first sample coordinate is 0.0. * @param nx1 number of samples in the 1st dimension. */ public Fft(int nx1) { this(new Sampling(nx1,1.0,0.0)); }
/** * Constructs an image panel group for all three axes. * Assumes default unit sampling. * Both 3D arrays of floats must have consistent dimensions. * @param f1 1st 3D array of floats. * @param f2 2nd 3D array of floats. */ public ImagePanelGroup2(float[][][] f1, float[][][] f2) { this(new Sampling(f1[0][0].length), new Sampling(f1[0].length), new Sampling(f1.length), f1,f2); }
/** * Returns a sampled function with values zero. * @param n the number of samples. * @return the function. */ public static Real1 zero(int n) { return new Real1(new Sampling(n)); }
/** * Sets the sampled function f(x1,x2) for this view. * Assumes zero first sample values and unit sampling intervals. * @param f array[n2][n1] of sampled function values f(x1,x2), where * n1 = f[0].length and n2 = f.length. */ public void set(float[][] f) { set(new Sampling(f[0].length),new Sampling(f.length),f); }
/** * Returns a function with constant values. * @param ar the constant. * @param n the number of samples. * @return the function. */ public static Real1 fill(double ar, int n) { return Real1.fill(ar,new Sampling(n)); }
/** * Sets the contour values to those in the specified array. * If this method is called, then clips (or percentiles) are not used * to determine contour values, and readable contours are disabled. * @param c the array of contour values. */ public void setContours(float[] c) { double[] cd = new double[c.length]; for (int i=0; i<c.length; ++i) cd[i] = (double)c[i]; setContours(new Sampling(cd)); }
/** * Sets default sampling and specified function values f(x). * The default sampling is x = 0, 1, 2, .... * @param f array of sampled function values f(x). */ public void set(float[] f) { set(new Sampling(f.length),f); }
/** * Returns a sampled linear (ramp) function. * The function values are fv+iv*dv, for iv in [0:nv). * @param fv the first function value. * @param dv the function value delta. * @param nv the number of values. * @return the function. */ public static Real1 ramp(double fv, double dv, int nv) { return Real1.ramp(fv,dv,new Sampling(nv)); }
/** * Sets the sampled functions f(x1,x2) for this view. * If compatible samplings for x1 and x2 have already been specified, * then this method uses them. Otherwise, this method assumes zero * first sample values and unit sampling intervals. * Function values are converted to colors using a direct color model. * @param f array[nc][n2][n1] of sampled function values f(x1,x2), * where nc is the number (three or four) of color components. */ public void set(float[][][] f) { if (_s1!=null && _s1.getCount()==f[0][0].length && _s2!=null && _s2.getCount()==f[0].length) { set(_s1,_s2,f); } else { set(new Sampling(f[0][0].length),new Sampling(f[0].length),f); } }
private static void plot1() { int nx = 301; float dx = 0.1f; float fx = 0.0f; Sampling sx = new Sampling(nx,dx,fx); float[] x = rampfloat(fx,dx,nx); float[] f = sub(mul(x,sin(x)),1.0f); SimplePlot.asPoints(sx,f); } private static void plot2() {