📄 utils.html
字号:
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="log2"><!-- --></A><H3>
log2</H3>
<PRE>
public static double <B>log2</B></PRE>
<DL>
<DD>The natural logarithm of 2.
<P>
<DL>
</DL>
</DL>
<HR>
<A NAME="SMALL"><!-- --></A><H3>
SMALL</H3>
<PRE>
public static double <B>SMALL</B></PRE>
<DL>
<DD>The small deviation allowed in double comparisons
<P>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Utils()"><!-- --></A><H3>
Utils</H3>
<PRE>
public <B>Utils</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="readProperties(java.lang.String)"><!-- --></A><H3>
readProperties</H3>
<PRE>
public static java.util.Properties <B>readProperties</B>(java.lang.String resourceName)
throws java.lang.Exception</PRE>
<DL>
<DD>Reads properties that inherit from three locations. Properties are first defined in the system resource location (i.e. in the CLASSPATH). These default properties must exist. Properties defined in the users home directory (optional) override default settings. Properties defined in the current directory (optional) override all these settings.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>resourceName</CODE> - the location of the resource that should be loaded. e.g.: "weka/core/Utils.props". (The use of hardcoded forward slashes here is OK - see jdk1.1/docs/guide/misc/resources.html) This routine will also look for the file (in this case) "Utils.props" in the users home directory and the current directory.
<DT><B>Returns:</B><DD>the Properties
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE> - if no default properties are defined, or if an error occurs reading the properties files.</DL>
</DD>
</DL>
<HR>
<A NAME="correlation(double[], double[], int)"><!-- --></A><H3>
correlation</H3>
<PRE>
public static final double <B>correlation</B>(double[] y1,
double[] y2,
int n)</PRE>
<DL>
<DD>Returns the correlation coefficient of two double vectors.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>y1</CODE> - double vector 1<DD><CODE>y2</CODE> - double vector 2<DD><CODE>n</CODE> - the length of two double vectors
<DT><B>Returns:</B><DD>the correlation coefficient</DL>
</DD>
</DL>
<HR>
<A NAME="removeSubstring(java.lang.String, java.lang.String)"><!-- --></A><H3>
removeSubstring</H3>
<PRE>
public static java.lang.String <B>removeSubstring</B>(java.lang.String inString,
java.lang.String substring)</PRE>
<DL>
<DD>Removes all occurrences of a string from another string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>inString</CODE> - the string to remove substrings from.<DD><CODE>substring</CODE> - the substring to remove.
<DT><B>Returns:</B><DD>the input string with occurrences of substring removed.</DL>
</DD>
</DL>
<HR>
<A NAME="replaceSubstring(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
replaceSubstring</H3>
<PRE>
public static java.lang.String <B>replaceSubstring</B>(java.lang.String inString,
java.lang.String subString,
java.lang.String replaceString)</PRE>
<DL>
<DD>Replaces with a new string, all occurrences of a string from another string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>inString</CODE> - the string to replace substrings in.<DD><CODE>subString</CODE> - the substring to replace.<DD><CODE>replaceString</CODE> - the replacement substring
<DT><B>Returns:</B><DD>the input string with occurrences of substring replaced.</DL>
</DD>
</DL>
<HR>
<A NAME="padLeft(java.lang.String, int)"><!-- --></A><H3>
padLeft</H3>
<PRE>
public static java.lang.String <B>padLeft</B>(java.lang.String inString,
int length)</PRE>
<DL>
<DD>Pads a string to a specified length, inserting spaces on the left as required. If the string is too long, characters are removed (from the right).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>inString</CODE> - the input string<DD><CODE>length</CODE> - the desired length of the output string
<DT><B>Returns:</B><DD>the output string</DL>
</DD>
</DL>
<HR>
<A NAME="padRight(java.lang.String, int)"><!-- --></A><H3>
padRight</H3>
<PRE>
public static java.lang.String <B>padRight</B>(java.lang.String inString,
int length)</PRE>
<DL>
<DD>Pads a string to a specified length, inserting spaces on the right as required. If the string is too long, characters are removed (from the right).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>inString</CODE> - the input string<DD><CODE>length</CODE> - the desired length of the output string
<DT><B>Returns:</B><DD>the output string</DL>
</DD>
</DL>
<HR>
<A NAME="doubleToString(double, int)"><!-- --></A><H3>
doubleToString</H3>
<PRE>
public static java.lang.String <B>doubleToString</B>(double value,
int afterDecimalPoint)</PRE>
<DL>
<DD>Rounds a double and converts it into String.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>value</CODE> - the double value<DD><CODE>afterDecimalPoint</CODE> - the (maximum) number of digits permitted after the decimal point
<DT><B>Returns:</B><DD>the double as a formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="doubleToString(double, int, int)"><!-- --></A><H3>
doubleToString</H3>
<PRE>
public static java.lang.String <B>doubleToString</B>(double value,
int width,
int afterDecimalPoint)</PRE>
<DL>
<DD>Rounds a double and converts it into a formatted decimal-justified String. Trailing 0's are replaced with spaces.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>value</CODE> - the double value<DD><CODE>width</CODE> - the width of the string<DD><CODE>afterDecimalPoint</CODE> - the number of digits after the decimal point
<DT><B>Returns:</B><DD>the double as a formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="getArrayClass(java.lang.Class)"><!-- --></A><H3>
getArrayClass</H3>
<PRE>
public static java.lang.Class <B>getArrayClass</B>(java.lang.Class c)</PRE>
<DL>
<DD>Returns the basic class of an array class (handles multi-dimensional arrays).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>c</CODE> - the array to inspect
<DT><B>Returns:</B><DD>the class of the innermost elements</DL>
</DD>
</DL>
<HR>
<A NAME="getArrayDimensions(java.lang.Class)"><!-- --></A><H3>
getArrayDimensions</H3>
<PRE>
public static int <B>getArrayDimensions</B>(java.lang.Class array)</PRE>
<DL>
<DD>Returns the dimensions of the given array. Even though the parameter is of type "Object" one can hand over primitve arrays, e.g. int[3] or double[2][4].
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - the array to determine the dimensions for
<DT><B>Returns:</B><DD>the dimensions of the array</DL>
</DD>
</DL>
<HR>
<A NAME="getArrayDimensions(java.lang.Object)"><!-- --></A><H3>
getArrayDimensions</H3>
<PRE>
public static int <B>getArrayDimensions</B>(java.lang.Object array)</PRE>
<DL>
<DD>Returns the dimensions of the given array. Even though the parameter is of type "Object" one can hand over primitve arrays, e.g. int[3] or double[2][4].
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - the array to determine the dimensions for
<DT><B>Returns:</B><DD>the dimensions of the array</DL>
</DD>
</DL>
<HR>
<A NAME="arrayToString(java.lang.Object)"><!-- --></A><H3>
arrayToString</H3>
<PRE>
public static java.lang.String <B>arrayToString</B>(java.lang.Object array)</PRE>
<DL>
<DD>Returns the given Array in a string representation. Even though the parameter is of type "Object" one can hand over primitve arrays, e.g. int[3] or double[2][4].
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>array</CODE> - the array to return in a string representation
<DT><B>Returns:</B><DD>the array as string</DL>
</DD>
</DL>
<HR>
<A NAME="eq(double, double)"><!-- --></A><H3>
eq</H3>
<PRE>
public static boolean <B>eq</B>(double a,
double b)</PRE>
<DL>
<DD>Tests if a is equal to b.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL>
</DD>
</DL>
<HR>
<A NAME="checkForRemainingOptions(java.lang.String[])"><!-- --></A><H3>
checkForRemainingOptions</H3>
<PRE>
public static void <B>checkForRemainingOptions</B>(java.lang.String[] options)
throws java.lang.Exception</PRE>
<DL>
<DD>Checks if the given array contains any non-empty options.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>options</CODE> - an array of strings
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE> - if there are any non-empty options</DL>
</DD>
</DL>
<HR>
<A NAME="getFlag(char, java.lang.String[])"><!-- --></A><H3>
getFlag</H3>
<PRE>
public static boolean <B>getFlag</B>(char flag,
java.lang.String[] options)
throws java.lang.Exception</PRE>
<DL>
<DD>Checks if the given array contains the flag "-Char". Stops searching at the first marker "--". If the flag is found, it is replaced with the empty string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>flag</CODE> - the character indicating the flag.<DD><CODE>options</CODE> - the array of strings containing all the options.
<DT><B>Returns:</B><DD>true if the flag was found
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE> - if an illegal option was found</DL>
</DD>
</DL>
<HR>
<A NAME="getFlag(java.lang.String, java.lang.String[])"><!-- --></A><H3>
getFlag</H3>
<PRE>
public static boolean <B>getFlag</B>(java.lang.String flag,
java.lang.String[] options)
throws java.lang.Exception</PRE>
<DL>
<DD>Checks if the given array contains the flag "-String". Stops searching at the first marker "--". If the flag is found, it is replaced with the empty string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>flag</CODE> - the String indicating the flag.<DD><CODE>options</CODE> - the array of strings containing all the options.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -