Class Elib

java.lang.Object
  |
  +--Elib

class Elib
extends java.lang.Object

Author:
Erhan Oztop, 2001-2002

Source code by Erhan Oztop (erhan@atr.co.jp)
Copyright August 2002 via
University of Southern California Ph.D. publication copyright
This class file is a collection of purpose utility methods.

Constructor Summary
(package private) Elib()
           
 
Method Summary
static int abs(int x)
          Returns (int) absolute value of x
(package private) static boolean array2file(double[][] A, int N, int M, java.lang.String fn)
          Writes an 2darray to a file
(package private) static boolean array2file(double[][] A, java.lang.String fn, java.lang.String comment)
          Writes an 2darray to a file
(package private) static boolean array2file(double[] A, int N, java.lang.String fn)
          Writes an array to a file
(package private) static java.lang.String arrayInfo(double[][] A)
           
static double cube(double x)
          Returns x*x*x
static double dist(double x0, double y0, double x1, double y1)
          Returns the distance between (x0,y0), (x1,y1)
 boolean easy_num(java.lang.String u)
          makes a dirty and fast number check based on 1st char.
static java.awt.Color Ecolor(int i)
          returns a Color corresponding to i.
(package private) static double[][] file2array(java.lang.String fn)
          Reads a 2darray from a file
(package private) static double logscale(double x, double xmax, double base)
           
static double negsqrt(double x)
          Returns x*x*SGN(x).
static double nice(double x, double scale)
          Returns a truncated vecsion of x so that it will have less decimal points.
static double nice(java.lang.String s, double scale)
          Returns a truncated vecsion of the double given in the string so that it will have less decimal points.
static java.io.DataInputStream openfileREAD(java.lang.String fn)
          open file for read.
static java.io.DataOutputStream openfileWRITE(java.lang.String fn)
          open file for write.
static java.io.DataInputStream openURLfile(java.net.URL base, java.lang.String name)
           
(package private) static boolean point3d2file(Point3d[] A, int N, java.lang.String fn)
          Writes a point3d array to a file
static double sgn(double x)
          Return 0 for x=0, -1 for x<0 and +1 else
static java.lang.String snice(double x, double scale, int pos)
          Returns a truncated version of the double given so that it will have less decimal points as a string.
static java.lang.String snice(java.lang.String s, double scale, int pos)
          Returns a truncated version of the double given in the string so that it will have less decimal points as a string.
static double sqr(double x)
          Returns x*x
(package private) static double[] str2array(java.lang.String s, java.lang.String ch)
          input us a ch delimited string.
static double toDouble(java.lang.String s)
          Returns the double value in the given string
static int toInt(java.lang.String s)
          Returns the int value in the given string
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

Elib

Elib()
Method Detail

Ecolor

public static java.awt.Color Ecolor(int i)
returns a Color corresponding to i. -limited use check code-

toDouble

public static double toDouble(java.lang.String s)
Returns the double value in the given string

toInt

public static int toInt(java.lang.String s)
Returns the int value in the given string

nice

public static double nice(double x,
                          double scale)
Returns a truncated vecsion of x so that it will have less decimal points. If scale=1e3, it should return a number with less than or equal to 3 decimal digits. -limited use- -may be buggy-

nice

public static double nice(java.lang.String s,
                          double scale)
Returns a truncated vecsion of the double given in the string so that it will have less decimal points. If scale=1e3, it should return a number with less than or equal to 3 decimal digits. -limited use- -may be buggy-

snice

public static java.lang.String snice(double x,
                                     double scale,
                                     int pos)
Returns a truncated version of the double given so that it will have less decimal points as a string. If scale=1e3, it should return a number with less than or equal to 3 decimal digits. The last argument specifies the box length that the number should span -limited use- -may be buggy-

snice

public static java.lang.String snice(java.lang.String s,
                                     double scale,
                                     int pos)
Returns a truncated version of the double given in the string so that it will have less decimal points as a string. If scale=1e3, it should return a number with less than or equal to 3 decimal digits. The last argument specifies the box length that the number should span -limited use- -may be buggy-

sqr

public static double sqr(double x)
Returns x*x

cube

public static double cube(double x)
Returns x*x*x

negsqrt

public static double negsqrt(double x)
Returns x*x*SGN(x). Where SGN(x)=0 at 0, -1 for x<0 and +1 else.

sgn

public static double sgn(double x)
Return 0 for x=0, -1 for x<0 and +1 else

abs

public static int abs(int x)
Returns (int) absolute value of x

dist

public static double dist(double x0,
                          double y0,
                          double x1,
                          double y1)
Returns the distance between (x0,y0), (x1,y1)

easy_num

public boolean easy_num(java.lang.String u)
makes a dirty and fast number check based on 1st char. If it returns false it is a non-number for sure but contrary is not true.

openURLfile

public static java.io.DataInputStream openURLfile(java.net.URL base,
                                                  java.lang.String name)

openfileREAD

public static java.io.DataInputStream openfileREAD(java.lang.String fn)
                                            throws java.io.IOException
open file for read. Should be moved to Elib.

openfileWRITE

public static java.io.DataOutputStream openfileWRITE(java.lang.String fn)
                                              throws java.io.IOException
open file for write. Should be moved to Elib.

point3d2file

static boolean point3d2file(Point3d[] A,
                            int N,
                            java.lang.String fn)
Writes a point3d array to a file

array2file

static boolean array2file(double[] A,
                          int N,
                          java.lang.String fn)
Writes an array to a file

array2file

static boolean array2file(double[][] A,
                          int N,
                          int M,
                          java.lang.String fn)
Writes an 2darray to a file

array2file

static boolean array2file(double[][] A,
                          java.lang.String fn,
                          java.lang.String comment)
Writes an 2darray to a file

file2array

static double[][] file2array(java.lang.String fn)
Reads a 2darray from a file

logscale

static double logscale(double x,
                       double xmax,
                       double base)

str2array

static double[] str2array(java.lang.String s,
                          java.lang.String ch)
input us a ch delimited string. The output is the double[] representation

arrayInfo

static java.lang.String arrayInfo(double[][] A)