private void computeMinorTics() { // the position out of 9 that the first tic should be before the first Major tic // e.g. 7 out of 9 double c = pow(10.0,(_expMin-ceil(_expMin)+1)); // the number of log-spaced tics that the last value is ahead of the // previous-to-first major tic int c2 = 9-(int)floor(c); // the number of log-spaced tics that the last value is behind the // next-after-last major tic double d = pow(10.0,(_expMax-floor(_expMax))); // the number of log-spaced tics that the last value is ahead of the last // major tic int d2 = (int)floor(d); _nticMinor = 9*(_ntic-1)+c2+d2; _dticMinor = 1; _fticMinor = pow(10,ceil(_expMin)-1)*(int)ceil(c); _ktic = c2+1; }
double eval(double x) { return (pow(x,2.0)-2.0)*x-5.0; } void checkRoot(double x) {
double eval(double x) { return (pow(x,2)-2.0)*x-5.0; } void checkMin(double x) {
/** * Randomly samples nodes to facilitate fast searches. Following * Mucke et al., 1996, the number of samples is proportional to * N^(1/3), where N equals the number of nodes. The factor of 0.45 * was used by Shewchuk, 1997. */ private void sampleNodes() { Random random = new Random(); _sampledNodes.clear(); int nsamp = (int)(pow(_nnode,0.33)/0.45); Node node = _nroot; while (_sampledNodes.size()<nsamp) { int nskip = 1+random.nextInt(_nnode/2); while (--nskip>0) node = node._next; _sampledNodes.add(node); } } }
/** * Randomly samples nodes to facilitate fast searches. Following * Mucke et al., 1996, the number of samples is proportional to * N^(1/4), where N equals the number of nodes. The factor of 2 * below corresponds to Mucke et al.'s scale factor 0.5. */ private void sampleNodes() { Random random = new Random(); _sampledNodes.clear(); int nsamp = 2*(int)pow(_nnode,0.25); Node node = _nroot; while (_sampledNodes.size()<nsamp) { int nskip = 1+random.nextInt(_nnode/2); while (--nskip>0) node = node._next; _sampledNodes.add(node); } } }
private KaiserWindow(double error, double width, double length) { _error = error; _width = width; _length = length; double a = -20.0*log10(_error); if (a<=21.0) { _alpha = 0.0; } else if (a<=50.0) { _alpha = 0.5842*pow(a-21.0,0.4)+0.07886*(a-21.0); } else { _alpha = 0.1102*(a-8.7); } _scale = 1.0/ino(_alpha); _xxmax = 0.25*_length*_length; }
/** * Constructs axis tics for a specified maximum number of major tics. * @param x1 the value at one end of the axis. * @param x2 the value at the other end of the axis. */ public LogAxisTics(double x1, double x2) { super(x1,x2,0); double xmin = min(x1,x2); double xmax = max(x1,x2); _expMin = log10(xmin); _expMax = log10(xmax); _dtic = 1; _ftic = pow(10,ceil(_expMin)); _ntic = (int)(floor(ArrayMath.log10(xmax))-ceil(ArrayMath.log10(xmin)))+1; computeMultiple(); computeMinorTics(); }
double eval(double x) { return pow(sin(x)-x,2)+1; } void checkMin(double x) {
double eval(double x) { return pow(cos(x)-x,2)-2; } void checkMin(double x) {
/** * Returns a Kaiser window with specified transition width and window length. * The product width*length cannot be less than one. * @param width the transition width * @param length the two-sided window length. * @return the window. */ public static KaiserWindow fromWidthAndLength(double width, double length) { Check.argument(width>0.0,"width>0.0"); Check.argument(length>0,"length>0"); Check.argument(width*length>=1.0,"width*length>=1.0"); double d = width*length; double a = 14.36*d+7.95; double error = pow(10.0,-a/20.0); return new KaiserWindow(error,width,length); }
protected void init(Cdouble[] poles, Cdouble[] zeros, double gain) { Check.argument(poles.length>0 || zeros.length>0, "at least one pole or zero is specified"); // Sort poles and zeros so that complex conjugate pairs are first. poles = sortPolesOrZeros(poles); zeros = sortPolesOrZeros(zeros); // Construct 2nd-order filters. int np = poles.length; int nz = zeros.length; _n1 = max((np+1)/2,(nz+1)/2); _f1 = new Recursive2ndOrderFilter[_n1]; gain = pow(gain,1.0/_n1); Cdouble c0 = new Cdouble(0.0,0.0); for (int i1=0,ip=0,iz=0; i1<_n1; ++i1) { Cdouble pole1 = (ip<np)?poles[ip++]:c0; Cdouble pole2 = (ip<np)?poles[ip++]:c0; Cdouble zero1 = (iz<nz)?zeros[iz++]:c0; Cdouble zero2 = (iz<nz)?zeros[iz++]:c0; _f1[i1] = new Recursive2ndOrderFilter(pole1,pole2,zero1,zero2,gain); } }
float[] f2 = new float[n]; for (int i = 0; i < n; ++i) { f1[i] = pow(1.5f * x1[i],1); f2[i] = 100 * (float) sin(0.1 * x2[i]);
public static void main(String args[]) { System.out.println("LogAxisPlotDemo2"); int n = 1000; float X = 300; float[] x = ArrayMath.rampfloat(0.0f,X / n,n); float[] f = new float[n]; for (int i = 0; i < n; ++i) { f[i] = pow(1.5f * x[i],2); } // new plot PlotPanel plot = new PlotPanel(2,2); pv1 = plot.addPoints(0,0,x,f); pv2 = plot.addPoints(0,1,x,f); pv3 = plot.addPoints(1,0,x,f); pv4 = plot.addPoints(1,1,x,f); // frame setup plot.setVisible(true); PlotFrame frame = new PlotFrame(plot); frame.setSize(800,500); frame.add(makeScaleOptionPanel(),BorderLayout.EAST); frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
int m = _mult[imult]; int l = (int)floor(log10(dmax/m)); double d = m*pow(10.0,l); double f = ceil(xmin/d)*d; int n = 1+(int)((xmax-f)/d);
if (al>=ah) { int np = (int)ceil(0.5*log((pl*(1-ph))/(ph*(1-pl)))/log(xh/xl)); double xc = xl*pow(pl/(1-pl),0.5/np); double wc = 2.0*atan(xc/2.0); double fc = 0.5*wc/DBL_PI; } else { int np = (int)ceil(0.5*log((ph*(1-pl))/(pl*(1-ph)))/log(xh/xl)); double xc = xh*pow((1-ph)/ph,0.5/np); double wc = 2.0*atan(xc/2.0); double fc = 0.5*wc/DBL_PI;