Class JxnUtilities
- java.lang.Object
-
- JxnUtilities
-
public class JxnUtilities extends Object
Collection of methods in the following sections:
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void__1_fileDialog()protected void__2_plot_and_curve()protected void__3_formatting_to_String()protected void__4_hex_formatting()Adds to hex formatting and parsing methods.protected void__5_ClassExplorer()protected void__6_extensions_to_Math()Collection of methods adding tojava.lang.Math.protected void__7_setField()Set public fields of an object or a class.protected void__8_array_operations()protected void__9_boolean_operators()protected void_10_bitwise_operators()protected void_11_relational_operators()protected void_12_formula_switching()static doubleabs(double x, double y)Returnssqrt( x * x + y * y ).static doubleabs(double x, double y, double z)Returnssqrt( x * x + y * y + z * z ).static doubleacosD(double a)CallsMath.acos(double)and converts the result from radians to degrees.static doubleacosh(double x)Returns the inverse ofMath.cosh(double).static Objectadd(byte[] array, int i, byte value)Addsvaluetoarray[i]with overflow, if the result does not fit into byte.static Objectadd(double[] array, int i, double value)Addsvaluetoarray[i].static Objectadd(int[] array, int i, int value)Addsvaluetoarray[i].static Objectadd(long[] array, int i, long value)Addsvaluetoarray[i].static StringaddLeadingBlanks(String text, int n)Prefixestextwith blanks so that the result contains at leastncharacters.static StringaddLeadingChars(String text, int n, char ch)Prefixestextwithchso that the result contains at leastncharacters.static StringaddLeadingZeros(String text, int n)Prefixestextwith'0'so that the result contains at leastncharacters.static StringaddTrailingChars(String text, int n, char ch)Appendstextwithchso that the result contains at leastncharacters.static booleanall(boolean[] array)Returns true, if all values inarrayare true.static booleanand(boolean x, boolean y)Represents the Java boolean operator.static intand(int x, int y)Represents the Java bitwise operator (for int).static longand(long x, long y)Represents the Java bitwise operator (for long).static booleanany(boolean[] array)Returns true, if at least one value inarrayis true.static doubleasinD(double a)CallsMath.asin(double)and converts the result from radians to degrees.static doubleasinh(double x)Returns the inverse ofMath.sinh(double).static doubleatan2D(double y, double x)CallsMath.atan2(double, double)and converts the result from radians to degrees.static doubleatanD(double a)CallsMath.atan(double)and converts the result from radians to degrees.static doubleatanh(double x)Returns the inverse ofMath.tanh(double).static ObjectbooleanArray(int length, boolean initial)Creates a new boolean array with the specified length, initialized withinitial.static ObjectbyteArray(int length)Creates a new byte array with the specified length.static ObjectbyteArray(int length, byte initial)Creates a new byte array with the specified length, initialized withinitial.static doubleclip(double x, double lower, double upper)Returnsxlimitted bylowerandupper.static Objectconcat(Object... arrays)Returns a new array containing the elements of all arrays passed as arguments.static Objectconcat(Object arr1, Object arr2)Returns a new array containing the elements of arrayarr1followed by the elements of arrayarr2.static booleancontains(String chars, char ch)Returns true ifcharscontainsch.static doublecosD(double a)CallsMath.cos(double)after converting argumentafrom degrees to radians.static double[]cumulated(double[] array)Returns a new array containing the partial (cumulated) sums of the values ofarray.static int[]cumulated(int[] array)Returns a new array containing the partial (cumulated) sums of the values ofarray.static long[]cumulated(long[] array)Returns a new array containing the partial (cumulated) sums of the values ofarray.static JxnRealArrayCurvecurve(double[] x, double[] y, double[] z, IKmg3DProjection p3d)Deprecated.Useplot(p3d).add( x, y, z ).static JxnRealArrayCurvecurve(double[] x, double[] y, double[] z, IKmg3DProjection p3d, Color color)Deprecated.static JxnRealArrayCurvecurve(double[] x, double[] y, double[] z, IKmg3DProjection p3d, Color color, int lineType)Deprecated.static JxnRealArrayCurvecurve(double[] x, double[] y, Color color)Returns a curve representation ofxandy( xi = x[i], yi = y[i] ).static JxnRealArrayCurvecurve(double[] x, double[] y, Color color, int lineType)Seecurve.static JxnRealArrayCurvecurve(double[] y, Color color)Returns a curve representation ofy( xi = i, yi = y[i] ).static JxnRealArrayCurvecurve(double[] y, Color color, int lineType)Seecurve.static double[]differences(double[] array)Returns a new array containing the differences of subsequent values ofarray.static int[]differences(int[] array)Returns a new array containing the differences of subsequent values ofarray.static long[]differences(long[] array)Returns a new array containing the differences of subsequent values ofarray.static ObjectdoubleArray(int length)Creates a new double array with the specified length.static ObjectdoubleArray(int length, double initial)Creates a new double array with the specified length, initialized withinitial.static double[]doubleArray(String csvList)Deprecated.In JXN prefer{ 2., 3., 5., 7. }.static booleaneq(boolean x, boolean y)Represents the Java relational operator.static booleaneq(double x, double y)Represents the Java relational operator.static booleaneq(long x, long y)Represents the Java relational operator.static booleanequals(Object o1, Object o2)Deprecated.No more needed: Simply callo1.equals(o2).static booleanexor(boolean x, boolean y)Represents the Java boolean operator.static intexor(int x, int y)Represents the Java bitwise operator (for int).static longexor(long x, long y)Represents the Java bitwise operator (for long).static StringfileDialog()CallsfileDialog( String defaultFilename, int mode )withdefaultFilename = "*"andmode =FileDialog.LOAD.static StringfileDialog(String defaultFilename)static StringfileDialog(String defaultFilename, int mode)Displaysjava.awt.FileDialogand returns the filename selected by the user.static intfind(boolean[] array, boolean value)Searcharrayforvalue.static intfind(boolean[] array, int fromIndex, boolean value)Searcharrayforvaluestarting fromfromIndex.static intfind(byte[] array, byte value)Searcharrayforvalue.static intfind(byte[] array, int fromIndex, byte value)Searcharrayforvaluestarting fromfromIndex.static intfind(char[] array, char value)Searcharrayforvalue.static intfind(char[] array, int fromIndex, char value)Searcharrayforvaluestarting fromfromIndex.static intfind(int[] array, int value)Searcharrayforvalue.static intfind(int[] array, int fromIndex, int value)Searcharrayforvaluestarting fromfromIndex.static intfind(long[] array, int fromIndex, long value)Searcharrayforvaluestarting fromfromIndex.static intfind(long[] array, long value)Searcharrayforvalue.static intfind(Object[] array, int fromIndex, Object o)Searcharrayforostarting fromfromIndex.static intfind(Object[] array, Object o)Searcharrayforo.static Objectflip(boolean[] array, int i)Togglesarray[i].static Stringformat(double value, int nDec)Formatsvalueas String with a fixed number ofnDecdecimals.static Stringformat(double value, int nDec, int minLength)Formatsvalueas String with a fixed number ofnDecdecimals and minimum lengthminLength.static Stringformat(Object o)Formatsofor JXN-output.static Stringformat(Object o, boolean recursive)Formatsofor JXN-output.static Stringformat(String text)Formats special characters intext.static String[]formatClass(Object o)Formats information of the class of o (like menu: View > Class… in JxnSession window).static String[]formatMethods(Object o)Formats information of the methods of o (like menu: View > Methods… in JxnSession window).static String[]formatMethods(Object o, String name)Formats information of the methods of o.static booleange(double x, double y)Represents the Java relational operator.static booleange(long x, long y)Represents the Java relational operator.static Objectget(Object ao, double x)Returnsao[round(x)]with array index limitted to0 <= index < ao.length.static Objectget(Object ao, int i)In JXN preferao[i].static ClassgetClass(Object ao)Deprecated.No more needed: Simply callao.getClass().static StringgetClassName(Object o)Formats the class name of o as String.static StringgetHeadTrail(String delimString, int nHead, String separator, int nTrail, String text)Extracts the firstnHeadand the lastnTrailtokens delimited bydelimStringfromtext.static JxnRealArrayAlgebragetZ(KmgParallelProjection p3d, JxnRealArrayAlgebra[] rxyz)Returns the z-component of the projection (direction out of the projection plane towards the viewer).static Stringgroup(String text, int m)Groupstextinto sections ofmcharacters by inserting blanks.static Stringgroup(String text, int m, String separator)Groupstextinto sections ofmcharacters by inserting the Stringseparator.static booleangt(double x, double y)Represents the Java relational operator.static booleangt(long x, long y)Represents the Java relational operator.static inthashCode(Object ao)Deprecated.No more needed: Simply callao.hashCode().static StringhexString(byte by)Formats a byte as hexString.static StringhexString(byte[] by)Formats a byte array as hexString.static StringhexString(char ch)Formats a char as hexString.static StringhexString(char[] ch)Formats a char array as hexString.static StringhexString(double d)Formats a double as hexString.static StringhexString(float f)Formats a float as hexString.static StringhexString(int i)Formats an int as hexString.static StringhexString(long l)Formats a long as hexString.static StringhexString(short sh)Formats a short as hexString.static StringhexString(String text)Formatstextas hexString.static StringhexString(BigInteger bi)Formats a BigInteger as hexString.static doublehexStringToDouble(String hexString)Parses hexString to double usingparseHex(String hexString)andDouble.longBitsToDouble(long).static floathexStringToFloat(String hexString)Parses hexString to float usingparseHex(String hexString)andFloat.intBitsToFloat(int).static ObjectintArray(int length)Creates a new int array with the specified length.static ObjectintArray(int length, int initial)Creates a new int array with the specified length, initialized withinitial.static int[]intArray(String csvList)Deprecated.In JXN prefer{ 123, 456, 789 }.static booleanisArray(Object o)Returns true if o is an array (null returns false).static booleanisNull(double x)Allows the generic check of arbitrary variables (e.g.arguments passed to jxn files).static booleanisNull(Object o)Returns true if o == null.static booleanisPrimitiveOrJavaWrapper(double x)Used in jxn files to check the type ofx.static booleanisPrimitiveOrJavaWrapper(Object x)Used in jxn files to check the type ofx.static booleanisSame(Object x, Object y)Returns true if x == y (references to the same (identical) instance).static Stringjoin(Object array)Formatsarrayas string.static Stringjoin(String separator, Object array)Formatsarrayas string.static booleanle(double x, double y)Represents the Java relational operator.static booleanle(long x, long y)Represents the Java relational operator.static intleft(int x, int i)Represents the Java bit shift operator (for int).static longleft(long x, int i)Represents the Java bit shift operator (for long).static intlength(Object ao)Returns the length of the specified array object.static doublelimit(double x, double xmin, double xmax)Keepsxwithinxminandxmax.static intlimit(int x, int xmin, int xmax)Keepsxwithinxminandxmax.static longlimit(long x, long xmin, long xmax)Keepsxwithinxminandxmax.static doublelog(double b, double x)Returns the baseblogarithm ofx.static doublelog2(double x)Returns the base 2 logarithm ofx.static ObjectlongArray(int length, long initial)Creates a new long array with the specified length, initialized withinitial.static booleanlt(double x, double y)Represents the Java relational operator.static booleanlt(long x, long y)Represents the Java relational operator.static intmodPow(int base, int exp, int m)Returnsbaseexp mod m.static doublemodulo(double x, double y)Preferx % yifx > 0andy > 0.
Example:static intmodulo(int x, int y)Preferx % yifx > 0andy > 0.static longmodulo(long x, long y)Preferx % yifx > 0andy > 0.static booleanne(boolean x, boolean y)Represents the Java relational operator.static booleanne(double x, double y)Represents the Java relational operator.static booleanne(long x, long y)Represents the Java relational operator.static ObjectnewArray(int length, Object initial)Creates a new array with the specified length, initialized withinitial.static ObjectnewArray(Class<?> componentType, int length)Creates a new array with the specified component type and length.static ObjectnewArray(Class<?> componentType, int... dimensions)Creates a new array with the specified component type and dimensions.static ObjectnewArray(Class<?> componentType, int length, Object initial)Creates a new array with the specified component type and length, initialized withinitial.static bytenop(double sliderDependentVariable)Forces the repetition of a statement by inserting an artificial dependency onsliderDependentVariable.static bytenop(Object sliderDependentObject)Deprecated.Not needed.static Objectnop(Object obj, double sliderDependentVariable)Forces the repetition of a statement by inserting an artificial dependency onsliderDependentVariable.static Objectnop(Object obj, Object sliderDependentObject)Deprecated.Not needed.static booleannot(boolean x)Represents the Java boolean operator.static intnot(int x)Represents the Java bitwise operator (for int).static longnot(long x)Represents the Java bitwise operator (for long).static booleanor(boolean x, boolean y)Represents the Java boolean operator.static intor(int x, int y)Represents the Java bitwise operator (for int).static longor(long x, long y)Represents the Java bitwise operator (for long).static NumberparseHex(String hexString)ParseshexStringto appropriateNumber.static JxnRealArrayPlotFrameplot(double[] y)Creates a newJxnRealArrayPlotFrameand visualizes the values ofyas a curve:
xi = i, yi = y[i], i = 0 ... y.length - 1.static JxnRealArrayPlotFrameplot(double[] x, double[] y)Creates a newJxnRealArrayPlotFrameand visualizes the values ofxandyas a curve:
xi = x[i], yi = y[i], i = 0 ... min( x.length, y.length ) - 1.static JxnRealArrayPlotFrameplot(double[] x, double[] y, double vyx)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y1, double[] y2)static JxnRealArrayPlotFrameplot(double[] x, double[] y1, double[] y2, double[] y3)static JxnRealArrayPlotFrameplot(double[] x, double[] y, int logScales)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, float lineWidth)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, int lineType)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, int lineType, double vyx)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, int lineType, float lineWidth, double vyx)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, int lineType, float lineWidth, int logScales)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, int lineType, int logScales)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, Stroke stroke, double vyx)Seeplot.static JxnRealArrayPlotFrameplot(double[] x, double[] y, Color color, Stroke stroke, int logScales)Seeplot.static JxnRealArrayPlotFrameplot(double[] y, Color color, int lineType)Seeplot.static JxnPerspectivePlotFrameplot(IKmg3DProjection p3d)Creates aJxnPerspectivePlotFramefor the three-dimensional display of vectors and curves.static JxnPerspectivePlotFrameplot(IKmg3DProjection p3d, double size)Creates aJxnPerspectivePlotFramefor the three-dimensional display of vectors and curves.static Frameplot(KmgXYPainter painter)Deprecated....static doublepqRoot(double p, double q)Returns solution ofx^2 + p x + q = 0.static String[]print(PrintStream ps, String[] lines)Writeslinesline by line tops.static Stringrepeat(String text, int n)Returns a String which containstextrepeatedntimes.static intright(int x, int i)Represents the Java bit shift operator (for int).static longright(long x, int i)Represents the Java bit shift operator (for long).static intright0(int x, int i)Represents the Java bit shift operator (for int).static longright0(long x, int i)Represents the Java bit shift operator (for long).static longround_half_away_from_zero(double x)Returns result of commercial rounding ofx.static Objectset(boolean[] array, int i, boolean value)Shortcut forjava.lang.reflect.Array.setBoolean( Object array, int i, boolean value ).static Objectset(byte[] array, int i, byte value)Shortcut forjava.lang.reflect.Array.setByte( Object array, int i, byte value ).static Objectset(char[] array, int i, char value)Shortcut forjava.lang.reflect.Array.setChar( Object array, int i, char value ).static Objectset(double[] array, int i, double value)Shortcut forjava.lang.reflect.Array.setDouble( Object array, int i, double value ).static Objectset(float[] array, int i, float value)Shortcut forjava.lang.reflect.Array.setFloat( Object array, int i, float value ).static Objectset(int[] array, int i, int value)Shortcut forjava.lang.reflect.Array.setInt( Object array, int i, int value ).static Objectset(long[] array, int i, long value)Shortcut forjava.lang.reflect.Array.setLong( Object array, int i, long value ).static Objectset(short[] array, int i, short value)Shortcut forjava.lang.reflect.Array.setShort( Object array, int i, short value ).static Objectset(Object[] array, int i, Object value)Sets the value of thei-th component ofarrayto the specified newvalue.static Objectset(Object o, String fieldName, boolean value)Sets a boolean field of an object or a class.static Objectset(Object o, String fieldName, byte value)Sets a byte field of an object or a class.static Objectset(Object o, String fieldName, char value)Sets a char field of an object or a class.static Objectset(Object o, String fieldName, double value)Sets a double field of an object or a class.static Objectset(Object o, String fieldName, float value)Sets a float field of an object or a class.static Objectset(Object o, String fieldName, int value)Sets a int field of an object or a class.static Objectset(Object o, String fieldName, long value)Sets a long field of an object or a class.static Objectset(Object o, String fieldName, short value)Sets a short field of an object or a class.static Objectset(Object o, String fieldName, Object value)Sets a public field specified byfieldNameof an object or a class to the givenvalue.static booleansetArrayReturnOldValue(boolean returnOldValue)Controls if the set array methods return the old (overwriten) array value.static StringsetHexStringSeparator(String separator)Sets the group separator for hexString.static StringshowClass(Object o)Deprecated.Use#editformatClass(o)or Menu: View > Class...static StringshowMethods(Object o)Deprecated.Use#editformatMethods(o)or Menu: View > Methods...static StringshowMethods(Object o, String name)Deprecated.Use#editformatMethods( o, name )or Menu: View > Methods...static doublesinD(double a)CallsMath.sin(double)after converting argumentafrom degrees to radians.static String[]split(String delimString, String text)Splitstextinto parts delimited by the delimiter stringdelimString.static Stringsqueeze(String text)Removes blanks fromtext.static Stringsqueeze(String text, char chRemove)Removes all occurrences ofchRemovefromtext.static Stringsqueeze(String text, String removeChars)Removes all occurrences of the characters contained inremoveCharsfromtext.static String[]stringArray(String csvList)Deprecated.In JXN prefer{ "abc", "xyz" }.static String[]stringArray(String csvList, String delimChars)Returns array of tokens fromStringTokenizer.nextToken().static doublesw(boolean b, double yTrue, double yFalse)ReturnsyTrue, ifbis true elseyFalse.static intsw(boolean b, int yTrue, int yFalse)ReturnsyTrue, ifbis true elseyFalse.static longsw(boolean b, long yTrue, long yFalse)ReturnsyTrue, ifbis true elseyFalse.static Objectsw(boolean b, Object oTrue, Object oFalse)ReturnsoTrue, ifbis true elseoFalse.static doublesw(double x, double yLT, double yGE)ReturnsyLT, ifx < 0.elseyGE.static doublesw(double x, double yLT, double yEQ, double yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.static doublesw(double x, double eps, double yLower, double yInner, double yUpper)ReturnsyLower, ifx < -epselseyUpper, ifx > epselseyInner.static doublesw(double x, double xLower, double xUpper, double yLower, double yInner, double yUpper)ReturnsyLower, ifx < xLowerelseyUpper, ifx > xUpperelseyInner.static Objectsw(double x, double xLower, double xUpper, Object oLower, Object oInner, Object oUpper)ReturnsoLower, ifx < xLowerelseoUpper, ifx > xUpperelseoInner.static Objectsw(double x, double eps, Object oLower, Object oInner, Object oUpper)ReturnsoLower, ifx < -epselseoUpper, ifx > epselseoInner.static intsw(double x, int yLT, int yGE)ReturnsyLT, ifx < 0.elseyGE.static intsw(double x, int yLT, int yEQ, int yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.static longsw(double x, long yLT, long yGE)ReturnsyLT, ifx < 0.elseyGE.static longsw(double x, long yLT, long yEQ, long yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.static Objectsw(double x, Object[] oa)static Objectsw(double x, Object oLT, Object oGE)ReturnsoLT, ifx < 0elseoGE.static Objectsw(double x, Object oLT, Object oEQ, Object oGT)ReturnsoLT, ifx < 0elseoGT, ifx > 0elseoEQ.static intsw(int ivar, double slider_switch)Returns1ifivar-0.5 <= slider_switch < ivar+0.5else0.static doubletanD(double a)CallsMath.tan(double)after converting argumentafrom degrees to radians.static ObjecttoArray(Object ao)CallstoArray( ao, 0 ).static ObjecttoArray(Object ao, int mode)Check, ifaois an array or try to callao.toArray().static StringtoRawString(Object o)Formatsoto the string which would be returned by thetoString()method, if the same had not been overwriten for the class ofo.static StringtoString(Object o)Formats o as String.static StringtoString(Object o, boolean showHashCode)Formats o as String.static StringtoString(Object o, int verboseLevel)Formats o as String.static String[]toStringArray(Object o)Formatsoas aStringarray.static String[]toTableRows(double[][] colArrays)Formats a set of column arrays as a String array of the rows using'\t'to separate the array elements of a row.static String[]toTableRows(Object[] colArrays)Formats a set of column arrays as a String array of the rows using'\t'to separate the array elements of a row.static String[]toTableRows(String separator, double[][] colArrays)Formats a set of column arrays as a String array of the rows usingseparatorto separate the array elements of a row.static String[]toTableRows(String separator, Object[] colArrays)Formats a set of column arrays as a String array of the rows usingseparatorto separate the array elements of a row.static inttotal(boolean[] array)Returns the number oftruevalues inarray.static inttotal(byte[] array)Returns theintsum of the values ofarray.static doubletotal(double[] array)Returns the sum of the values ofarray.static inttotal(int[] array)Returns the sum of the values ofarray.static longtotal(long[] array)Returns the sum of the values ofarray.static StringwhatIs(Object o)Deprecated.replaced byJxnParameterCheck.whatIs(Object).
-
-
-
Method Detail
-
__1_fileDialog
protected void __1_fileDialog()
-
fileDialog
public static String fileDialog(String defaultFilename, int mode)
Displaysjava.awt.FileDialogand returns the filename selected by the user.- Parameters:
defaultFilename- narrows down the files displayed in the FileDialogmode- eitherjava.awt.FileDialog.LOADorjava.awt.FileDialog.SAVE- Returns:
- name of the file selected by the user
-
fileDialog
public static String fileDialog(String defaultFilename)
- Returns:
- name of the file selected by the user
-
fileDialog
public static String fileDialog()
CallsfileDialog( String defaultFilename, int mode )withdefaultFilename = "*"andmode =FileDialog.LOAD.- Returns:
- name of the file selected by the user
-
__2_plot_and_curve
protected void __2_plot_and_curve()
-
plot
public static Frame plot(KmgXYPainter painter)
Deprecated....
-
plot
public static JxnPerspectivePlotFrame plot(IKmg3DProjection p3d)
Creates aJxnPerspectivePlotFramefor the three-dimensional display of vectors and curves. Callsplot( p3d, 1. ).
-
plot
public static JxnPerspectivePlotFrame plot(IKmg3DProjection p3d, double size)
Creates aJxnPerspectivePlotFramefor the three-dimensional display of vectors and curves.
-
getZ
public static JxnRealArrayAlgebra getZ(KmgParallelProjection p3d, JxnRealArrayAlgebra[] rxyz)
Returns the z-component of the projection (direction out of the projection plane towards the viewer).
Can be used to hide invisible lines.
Example: JxnPortable/docs/plot_examples/PlotFrameDemo.html plot 2c: u, v -> x, y, z
-
plot
public static JxnRealArrayPlotFrame plot(double[] y)
Creates a newJxnRealArrayPlotFrameand visualizes the values ofyas a curve:
xi = i, yi = y[i], i = 0 ... y.length - 1.- Returns:
PlotFrameinstance can be used to add furthercurvesandphasors.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra ry)
-
plot
public static JxnRealArrayPlotFrame plot(double[] y, Color color, int lineType)
Seeplot.- Parameters:
lineType- seeJxnRealArrayCurve- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra ry, Color color, int lineType)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y)
Creates a newJxnRealArrayPlotFrameand visualizes the values ofxandyas a curve:
xi = x[i], yi = y[i], i = 0 ... min( x.length, y.length ) - 1.- Returns:
PlotFrameinstance can be used to add furthercurvesandphasors.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y1, double[] y2)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y1, double[] y2, double[] y3)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, double vyx)
Seeplot.- Parameters:
vyx- fixed ratio of the scaling: 1.0 for equally scaled x- and y-axis.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, double vyx)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, int logScales)
Seeplot.
Note: logarithmic scaling requires that all values are positive. The scale switches to linear if rx or ry include any value(s) <= 0.- Parameters:
logScales- determines which axis should be scaled logarithmiclogScales x-axis y-axis 0 lin lin 1 lin log 2 log lin 3 log log 4 time lin 5 time log - See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, int logScales)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color)
Seeplot.
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, int lineType)
Seeplot.- Parameters:
lineType- seeJxnRealArrayCurve- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, int lineType)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, float lineWidth)
Seeplot.
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, int lineType, double vyx)
Seeplot.- Parameters:
vyx- fixed ratio of the scaling: 1.0 for equally scaled x- and y-axis.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, int lineType, double vyx)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, int lineType, int logScales)
Seeplot.
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, int lineType, float lineWidth, double vyx)
Seeplot.- Parameters:
lineWidth- seejava.awt.BasicStrokevyx- fixed ratio of the scaling: 1.0 for equally scaled x- and y-axis.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, int lineType, float lineWidth, double vyx)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, int lineType, float lineWidth, int logScales)
Seeplot.- Parameters:
lineWidth- seejava.awt.BasicStroke- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, int lineType, float lineWidth, int logScales)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, Stroke stroke, double vyx)
Seeplot.- Parameters:
stroke- seejava.awt.BasicStrokevyx- fixed ratio of the scaling: 1.0 for equally scaled x- and y-axis.- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, Stroke stroke, double vyx)
-
plot
public static JxnRealArrayPlotFrame plot(double[] x, double[] y, Color color, Stroke stroke, int logScales)
Seeplot.- Parameters:
stroke- seejava.awt.BasicStroke- See Also:
JxnRealArrayAlgebra.plot(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, Stroke stroke, int logScales)
-
curve
public static JxnRealArrayCurve curve(double[] x, double[] y, Color color)
Returns a curve representation ofxandy( xi = x[i], yi = y[i] ). Call theaddmethod on aPlotFrameinstance to display the curve in the PlotFrame. Allows e.g. to show a curve in aJxnComplexPlotFrame.
Example for given arraysxandy:pf = plot( 3 + j 4 ).add( curve( x, y, Color.BLUE ) )
-
curve
public static JxnRealArrayCurve curve(double[] x, double[] y, Color color, int lineType)
Seecurve.- Parameters:
lineType- seeJxnRealArrayCurve- See Also:
JxnRealArrayAlgebra.curve(JxnRealArrayAlgebra rx, JxnRealArrayAlgebra ry, Color color, int lineType)
-
curve
public static JxnRealArrayCurve curve(double[] y, Color color)
-
curve
public static JxnRealArrayCurve curve(double[] y, Color color, int lineType)
Seecurve.- Parameters:
lineType- seeJxnRealArrayCurve- See Also:
JxnRealArrayAlgebra.curve(JxnRealArrayAlgebra ry, Color color, int lineType)
-
curve
public static JxnRealArrayCurve curve(double[] x, double[] y, double[] z, IKmg3DProjection p3d)
Deprecated.Useplot(p3d).add( x, y, z ).
-
curve
public static JxnRealArrayCurve curve(double[] x, double[] y, double[] z, IKmg3DProjection p3d, Color color)
Deprecated.
-
curve
public static JxnRealArrayCurve curve(double[] x, double[] y, double[] z, IKmg3DProjection p3d, Color color, int lineType)
Deprecated.
-
nop
public static byte nop(double sliderDependentVariable)
Forces the repetition of a statement by inserting an artificial dependency onsliderDependentVariable.
A slider animatedPlotFramerequires the repetition of all statements which depend on the slider variables. All statements which contain a slider variable or a variable which is dependent on a slider variable are repeated automatically on the change of any of the slider dependent variables. Therefore in most cases it is not necessary to explicitly control the repetition. Only if a statement does not contain any slider dependent variable but must be repeated, thenopmethods can be used to artificially create a dependency and thus force the repetition.
Usage: Addnop(sliderVar)to an arbitrary Java primitive of the statement. Asnop(double)returns0the result is not changed. If the statement does not contain any Java primitive usenop(java.lang.Object, double).
Example:slider = @JxnSliderPanel(this) sliderVar = slider.add( "var", 0., -5., 5. ) countRepaint = 0 ! statement is not slider dependent => not repeated countRepaint = countRepaint + 1 + nop(sliderVar) ! nop forces repetition on change of sliderVar plot( @JxnComplexAlgebra( 1., sliderVar, false ) ).add( @JxnTextPainter( countRepaint, 0., 0. ) )- Parameters:
sliderDependentVariable- any of the slider variablessliderVarfrom:sliderVar=slider.add(...)- Returns:
0(byte) does not change the result if added to a primitive expression- See Also:
- SliderRepeatNopDemo.html
-
nop
public static byte nop(Object sliderDependentObject)
Deprecated.Not needed.
-
nop
public static Object nop(Object obj, double sliderDependentVariable)
Forces the repetition of a statement by inserting an artificial dependency onsliderDependentVariable.
Usage:nop( obj, sliderVar ).fn() ! instead of obj.fn() obj = nop( fn(), sliderVar ) ! instead of obj = fn() fn( nop( obj, sliderVar ) ) ! instead of fn( obj )- Parameters:
sliderDependentVariable- any of the slider variablessliderVarfrom:sliderVar=slider.add(...)- Returns:
objwithout change- See Also:
nop(double)
-
__3_formatting_to_String
protected void __3_formatting_to_String()
-
join
public static String join(Object array)
Formatsarrayas string. Array elements are formatted using thetoString()method of the elements and separated by ", ".- Parameters:
array- array or object of a class which implements atoArray()method.
-
join
public static String join(String separator, Object array)
Formatsarrayas string. Array elements are formatted using thetoString()method of the elements and separated byseparator.- Parameters:
separator- zero or more characters separating the array elements.array- array or object of a class which implements atoArray()method.
-
split
public static String[] split(String delimString, String text)
Splitstextinto parts delimited by the delimiter stringdelimString. The parts are returned as array elements. The delimiter string is not included in the result. A pair of consecutive occurrences ofdelimStringresults in an array element containing an empty string "".- Parameters:
delimString- sequence of one or more chars- See Also:
KmgStringTokenizer,String.split(java.lang.String, int)
-
toTableRows
public static String[] toTableRows(Object[] colArrays)
Formats a set of column arrays as a String array of the rows using'\t'to separate the array elements of a row.- Parameters:
colArrays- seetoTableRows(String, Object[])
-
toTableRows
public static String[] toTableRows(String separator, Object[] colArrays)
Formats a set of column arrays as a String array of the rows usingseparatorto separate the array elements of a row.- Parameters:
separator- zero or more characters separating the array elements of a rowcolArrays- array containing an arbitrary nummer of columns. The columns may be given as arrays of primitive, arrays of objects or single objects of a class which implements atoArray()method.
-
toTableRows
public static String[] toTableRows(double[][] colArrays)
Formats a set of column arrays as a String array of the rows using'\t'to separate the array elements of a row.- Parameters:
colArrays- array of column arrays of double
-
toTableRows
public static String[] toTableRows(String separator, double[][] colArrays)
Formats a set of column arrays as a String array of the rows usingseparatorto separate the array elements of a row.- Parameters:
separator- zero or more characters separating the array elements of a rowcolArrays- array of column arrays of double
-
print
public static String[] print(PrintStream ps, String[] lines)
Writeslinesline by line tops.
Example:ps = @PrintStreamfileDialog()print( ps,toTableRows{ t, sin 2 PI t, cos 2 PI t } )ps.close()- Returns:
lines(the argument passed to the method)
-
format
public static String format(Object o)
Formatsofor JXN-output. Ifois an array it is unrolled recursively.- Returns:
format( o, true )- See Also:
Arrays.toString(Object[]),Arrays.deepToString(java.lang.Object[])
-
format
public static String format(Object o, boolean recursive)
Formatsofor JXN-output.- Parameters:
recursive- iftrueandois an array it is unrolled recursively.
-
format
public static String format(String text)
Formats special characters intext.- Returns:
KmgStaticUtilities.format(String)
-
format
public static String format(double value, int nDec)
Formatsvalueas String with a fixed number ofnDecdecimals.- Parameters:
nDec- IfnDec <= 0the sign ofvalueis formatted as "+ value" or "- value".- See Also:
java.text.DecimalFormat
-
format
public static String format(double value, int nDec, int minLength)
Formatsvalueas String with a fixed number ofnDecdecimals and minimum lengthminLength.
Callsformat(double, int)- Parameters:
minLength- minimum length of the result
if > 0 right justified: callsaddLeadingBlanks( ..., minLength )
if < 0 left justified: callsaddTrailingChars( ..., -minLength, ' ' )
-
whatIs
public static String whatIs(Object o)
Deprecated.replaced byJxnParameterCheck.whatIs(Object). Returns description of o as String.
-
toRawString
public static String toRawString(Object o)
Formatsoto the string which would be returned by thetoString()method, if the same had not been overwriten for the class ofo.- Returns:
KmgStaticUtilities.toRawString(java.lang.Object)- See Also:
Object.toString()
-
toStringArray
public static String[] toStringArray(Object o)
Formatsoas aStringarray.- Parameters:
o- may be an array, aCollectionor an instance of a class with atoStringmethod- Returns:
KmgStaticUtilities.toStringArray(java.lang.Object)
-
repeat
public static String repeat(String text, int n)
Returns a String which containstextrepeatedntimes.
-
squeeze
public static String squeeze(String text, char chRemove)
Removes all occurrences ofchRemovefromtext.
-
squeeze
public static String squeeze(String text, String removeChars)
Removes all occurrences of the characters contained inremoveCharsfromtext.
-
group
public static String group(String text, int m)
Groupstextinto sections ofmcharacters by inserting blanks.- Parameters:
m- seegroup(java.lang.String, int, java.lang.String)
-
group
public static String group(String text, int m, String separator)
Groupstextinto sections ofmcharacters by inserting the Stringseparator.- Parameters:
m- determines the number of characters of a section.
if m > 0, grouping start at the left end of text:group( "1234567890", 4, "~~" ) => 1234~~5678~~90
if m < 0, grouping start at the right end of text:group( "1234567890", -3, "_" ) => 1_234_567_890
-
addLeadingZeros
public static String addLeadingZeros(String text, int n)
Prefixestextwith'0'so that the result contains at leastncharacters.
-
addLeadingBlanks
public static String addLeadingBlanks(String text, int n)
Prefixestextwith blanks so that the result contains at leastncharacters.
-
addLeadingChars
public static String addLeadingChars(String text, int n, char ch)
Prefixestextwithchso that the result contains at leastncharacters.
-
addTrailingChars
public static String addTrailingChars(String text, int n, char ch)
Appendstextwithchso that the result contains at leastncharacters.
-
getHeadTrail
public static String getHeadTrail(String delimString, int nHead, String separator, int nTrail, String text)
Extracts the firstnHeadand the lastnTrailtokens delimited bydelimStringfromtext. The removed tokens are replaced byseparator. The delimiters are included in the result.
Example:getHeadTrail( "/", 3, "...", 2, "C:/Users/Default/AppData/Roaming/Microsoft/Windows/SendTo" )
returns:C:/Users/Default/.../Windows/SendTo
-
__4_hex_formatting
protected void __4_hex_formatting()
Adds to hex formatting and parsing methods.- See Also:
Double.longBitsToDouble(long),Double.doubleToRawLongBits(double),Double.toHexString(double),Double.parseDouble(java.lang.String),Float.intBitsToFloat(int),Float.floatToRawIntBits(float),Float.toHexString(float),Float.parseFloat(java.lang.String),Long.parseUnsignedLong( String s, int radix ),Long.toUnsignedString( long value, int radix ),Long.toHexString(long),Integer.parseUnsignedInt( String s, int radix ),Integer.toUnsignedString( int value, int radix ),Integer.toHexString(int),java.math.BigInteger( String s, int radix ),java.math.BigInteger.toString( int radix )
-
hexStringToDouble
public static double hexStringToDouble(String hexString)
Parses hexString to double usingparseHex(String hexString)andDouble.longBitsToDouble(long).- See Also:
Double.valueOf(java.lang.String)
-
hexStringToFloat
public static float hexStringToFloat(String hexString)
Parses hexString to float usingparseHex(String hexString)andFloat.intBitsToFloat(int).- See Also:
Float.valueOf(java.lang.String)
-
setHexStringSeparator
public static String setHexStringSeparator(String separator)
Sets the group separator for hexString.- Returns:
- the old separator
-
hexString
public static String hexString(double d)
Formats a double as hexString.
-
hexString
public static String hexString(float f)
Formats a float as hexString.
-
hexString
public static String hexString(BigInteger bi)
Formats a BigInteger as hexString.
-
hexString
public static String hexString(long l)
Formats a long as hexString.
-
hexString
public static String hexString(int i)
Formats an int as hexString.
-
hexString
public static String hexString(short sh)
Formats a short as hexString.
-
hexString
public static String hexString(byte by)
Formats a byte as hexString.
-
hexString
public static String hexString(byte[] by)
Formats a byte array as hexString.
-
hexString
public static String hexString(char ch)
Formats a char as hexString.
-
hexString
public static String hexString(char[] ch)
Formats a char array as hexString.
-
__5_ClassExplorer
protected void __5_ClassExplorer()
-
formatClass
public static String[] formatClass(Object o)
Formats information of the class of o (like menu: View > Class… in JxnSession window).
Example:#edit formatClass j! shows info of class JxnComplexAlgebra- Parameters:
o- object, class or "class name as String"
-
formatMethods
public static String[] formatMethods(Object o)
Formats information of the methods of o (like menu: View > Methods… in JxnSession window).- Parameters:
o- object, class or "class name as String"
-
formatMethods
public static String[] formatMethods(Object o, String name)
Formats information of the methods of o.- Parameters:
o- object, class or "class name as String"name- selects only methods starting withname
-
showClass
public static String showClass(Object o)
Deprecated.Use#editformatClass(o)or Menu: View > Class...
-
showMethods
public static String showMethods(Object o)
Deprecated.Use#editformatMethods(o)or Menu: View > Methods...
-
showMethods
public static String showMethods(Object o, String name)
Deprecated.Use#editformatMethods( o, name )or Menu: View > Methods...
-
__6_extensions_to_Math
protected void __6_extensions_to_Math()
Collection of methods adding tojava.lang.Math.
-
sinD
public static double sinD(double a)
CallsMath.sin(double)after converting argumentafrom degrees to radians.
-
cosD
public static double cosD(double a)
CallsMath.cos(double)after converting argumentafrom degrees to radians.
-
tanD
public static double tanD(double a)
CallsMath.tan(double)after converting argumentafrom degrees to radians.
-
asinD
public static double asinD(double a)
CallsMath.asin(double)and converts the result from radians to degrees.
-
acosD
public static double acosD(double a)
CallsMath.acos(double)and converts the result from radians to degrees.
-
atanD
public static double atanD(double a)
CallsMath.atan(double)and converts the result from radians to degrees.
-
atan2D
public static double atan2D(double y, double x)CallsMath.atan2(double, double)and converts the result from radians to degrees.
-
log2
public static double log2(double x)
Returns the base 2 logarithm ofx.
-
log
public static double log(double b, double x)Returns the baseblogarithm ofx.
-
asinh
public static double asinh(double x)
-
acosh
public static double acosh(double x)
-
atanh
public static double atanh(double x)
-
abs
public static double abs(double x, double y)
-
abs
public static double abs(double x, double y, double z)Returnssqrt( x * x + y * y + z * z ).
-
pqRoot
public static double pqRoot(double p, double q)Returns solution ofx^2 + p x + q = 0.- Returns:
- the bigger magnitude solution
x1. Get the 2nd solution asx2 = q / x1.
ReturnsDouble.NaN, if there are no real roots.
-
round_half_away_from_zero
public static long round_half_away_from_zero(double x)
Returns result of commercial rounding ofx.
See → Wikipedia for a discussion of different rounding methods.- See Also:
Math.round(double),Math.rint(double)
-
modPow
public static int modPow(int base, int exp, int m)Returnsbaseexp mod m.
-
modulo
public static double modulo(double x, double y)Preferx % yifx > 0andy > 0.
Example:eps = 0.1 ! move curves by eps to make superimposed curves visible x = { -200 : 200 } / 20 plot( x, x % 3 - eps, modulo( x, 3 ) + eps, IEEEremainder( x, 3 ) ).setXYLabels( "x", "y" ) $.setHeadline( "red: y = x % 3 | blue: y = modulo( x, 3 ) | green: y = IEEEremainder( x, 3 )" ) plot( x, x % -3 + eps, modulo( x, -3 ) - eps, IEEEremainder( x, -3 ) ).setXYLabels( "x", "y" ) $.setHeadline( "red: y = x % -3 | blue: y = modulo( x, -3 ) | green: y = IEEEremainder( x, -3 )" )- Returns:
x % y + yifx < 0 exor y < 0elsex % y- See Also:
Math.IEEEremainder(double, double)
-
modulo
public static long modulo(long x, long y)Preferx % yifx > 0andy > 0.- Returns:
x % y + yifx < 0 exor y < 0elsex % y
-
modulo
public static int modulo(int x, int y)Preferx % yifx > 0andy > 0.
Example:modulo( 7, 3 ) ! Note: 7 % 3 == 1 = 1 (int) modulo( -7, 3 ) ! Note: -7 % 3 == -1 = 2 (int) modulo( 7, -3 ) ! Note: 7 % -3 == 1 = -2 (int) modulo( -7, -3 ) ! Note: -7 % -3 == -1 = -1 (int)- Returns:
x % y + yifx < 0 exor y < 0elsex % y
-
__7_setField
protected void __7_setField()
Set public fields of an object or a class. (To be used, if the class does not provide setter methods for the fields).
-
set
public static Object set(Object o, String fieldName, Object value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a public field specified byfieldNameof an object or a class to the givenvalue.
set( o, "fieldName", value )is used in JXN instead ofo.fieldName = value.
set( "ClassName", "fieldName", value )is used instead ofClassName.fieldName = value(static field).- Parameters:
o- object for which the field is to be changed or in case of a static field the class object or the classname as StringfieldName- name of the field to be changedvalue- new value of the field- Returns:
- old value of the field
- Throws:
ClassNotFoundExceptionNoSuchFieldExceptionIllegalAccessException
-
set
public static Object set(Object o, String fieldName, double value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a double field of an object or a class.
-
set
public static Object set(Object o, String fieldName, float value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a float field of an object or a class.
-
set
public static Object set(Object o, String fieldName, long value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a long field of an object or a class.
-
set
public static Object set(Object o, String fieldName, int value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a int field of an object or a class.
-
set
public static Object set(Object o, String fieldName, short value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a short field of an object or a class.
-
set
public static Object set(Object o, String fieldName, byte value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a byte field of an object or a class.
-
set
public static Object set(Object o, String fieldName, boolean value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a boolean field of an object or a class.
-
set
public static Object set(Object o, String fieldName, char value) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException
Sets a char field of an object or a class.
-
__8_array_operations
protected void __8_array_operations()
-
length
public static int length(Object ao)
Returns the length of the specified array object.
Shortcut forjava.lang.reflect.Array.getLength(java.lang.Object)
-
get
public static Object get(Object ao, double x)
Returnsao[round(x)]with array index limitted to0 <= index < ao.length.
-
setArrayReturnOldValue
public static boolean setArrayReturnOldValue(boolean returnOldValue)
Controls if the set array methods return the old (overwriten) array value. By default the set methods return the array argument.
-
newArray
public static Object newArray(Class<?> componentType, int length)
Creates a new array with the specified component type and length.
Shortcut forjava.lang.reflect.Array.newInstance( componentType, length ).
-
newArray
public static Object newArray(Class<?> componentType, int length, Object initial)
Creates a new array with the specified component type and length, initialized withinitial.
-
newArray
public static Object newArray(int length, Object initial)
Creates a new array with the specified length, initialized withinitial.- Returns:
newArray( initial.getClass(), length, initial )
-
newArray
public static Object newArray(Class<?> componentType, int... dimensions)
Creates a new array with the specified component type and dimensions.
Shortcut forjava.lang.reflect.Array.newInstance( componentType, dimension... ).
Example:da3x5 = newArray( Double.TYPE, { 3, 5 } )
-
set
public static Object set(Object[] array, int i, Object value)
Sets the value of thei-th component ofarrayto the specified newvalue.
In JXNset( array, i, value )is used instead ofarray[i] = value.
-
find
public static int find(Object[] array, Object o)
Searcharrayforo.- Returns:
- first index
iwherearray[i].equals(o)or-1if not found
-
find
public static int find(Object[] array, int fromIndex, Object o)
Searcharrayforostarting fromfromIndex.- Returns:
- first index
iwherearray[i].equals(o)or-1if not found
-
doubleArray
public static Object doubleArray(int length)
Creates a new double array with the specified length. In JXN usedoubleArray(length)instead ofnew double[length].
Shortcut fornewArray( Double.TYPE, length ).
-
doubleArray
public static Object doubleArray(int length, double initial)
Creates a new double array with the specified length, initialized withinitial.
-
set
public static Object set(double[] array, int i, double value)
Shortcut forjava.lang.reflect.Array.setDouble( Object array, int i, double value ).
-
add
public static Object add(double[] array, int i, double value)
Addsvaluetoarray[i].
-
total
public static double total(double[] array)
Returns the sum of the values ofarray.
-
cumulated
public static double[] cumulated(double[] array)
Returns a new array containing the partial (cumulated) sums of the values ofarray.- Returns:
result[0] = array[0]; result[i] = result[i-1] + array[i]fori = 1 ... n-1
-
differences
public static double[] differences(double[] array)
Returns a new array containing the differences of subsequent values ofarray.- Returns:
result[i] = array[i+1] - array[i]fori = 0 ... n-2
-
set
public static Object set(float[] array, int i, float value)
Shortcut forjava.lang.reflect.Array.setFloat( Object array, int i, float value ).
-
longArray
public static Object longArray(int length, long initial)
Creates a new long array with the specified length, initialized withinitial.
-
set
public static Object set(long[] array, int i, long value)
Shortcut forjava.lang.reflect.Array.setLong( Object array, int i, long value ).
-
add
public static Object add(long[] array, int i, long value)
Addsvaluetoarray[i].
-
find
public static int find(long[] array, long value)Searcharrayforvalue.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
find
public static int find(long[] array, int fromIndex, long value)Searcharrayforvaluestarting fromfromIndex.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
total
public static long total(long[] array)
Returns the sum of the values ofarray.
-
cumulated
public static long[] cumulated(long[] array)
Returns a new array containing the partial (cumulated) sums of the values ofarray.- Returns:
result[0] = array[0]; result[i] = result[i-1] + array[i]fori = 1 ... n-1
-
differences
public static long[] differences(long[] array)
Returns a new array containing the differences of subsequent values ofarray.- Returns:
result[i] = array[i+1] - array[i]fori = 0 ... n-2
-
intArray
public static Object intArray(int length)
Creates a new int array with the specified length. In JXN useintArray(length)instead ofnew int[length].
Shortcut fornewArray( Integer.TYPE, length ).
-
intArray
public static Object intArray(int length, int initial)
Creates a new int array with the specified length, initialized withinitial.
-
set
public static Object set(int[] array, int i, int value)
Shortcut forjava.lang.reflect.Array.setInt( Object array, int i, int value ).
-
add
public static Object add(int[] array, int i, int value)
Addsvaluetoarray[i].
-
find
public static int find(int[] array, int value)Searcharrayforvalue.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
find
public static int find(int[] array, int fromIndex, int value)Searcharrayforvaluestarting fromfromIndex.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
total
public static int total(int[] array)
Returns the sum of the values ofarray.
-
cumulated
public static int[] cumulated(int[] array)
Returns a new array containing the partial (cumulated) sums of the values ofarray.- Returns:
result[0] = array[0]; result[i] = result[i-1] + array[i]fori = 1 ... n-1
-
differences
public static int[] differences(int[] array)
Returns a new array containing the differences of subsequent values ofarray.- Returns:
result[i] = array[i+1] - array[i]fori = 0 ... n-2
-
set
public static Object set(short[] array, int i, short value)
Shortcut forjava.lang.reflect.Array.setShort( Object array, int i, short value ).
-
byteArray
public static Object byteArray(int length)
Creates a new byte array with the specified length. In JXN usebyteArray(length)instead ofnew byte[length].
Shortcut fornewArray( Byte.TYPE, length ).
-
byteArray
public static Object byteArray(int length, byte initial)
Creates a new byte array with the specified length, initialized withinitial.
-
set
public static Object set(byte[] array, int i, byte value)
Shortcut forjava.lang.reflect.Array.setByte( Object array, int i, byte value ).
-
add
public static Object add(byte[] array, int i, byte value)
Addsvaluetoarray[i]with overflow, if the result does not fit into byte.
-
find
public static int find(byte[] array, byte value)Searcharrayforvalue.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
find
public static int find(byte[] array, int fromIndex, byte value)Searcharrayforvaluestarting fromfromIndex.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
total
public static int total(byte[] array)
Returns theintsum of the values ofarray.
-
booleanArray
public static Object booleanArray(int length, boolean initial)
Creates a new boolean array with the specified length, initialized withinitial.
-
set
public static Object set(boolean[] array, int i, boolean value)
Shortcut forjava.lang.reflect.Array.setBoolean( Object array, int i, boolean value ).
-
flip
public static Object flip(boolean[] array, int i)
Togglesarray[i].
-
find
public static int find(boolean[] array, boolean value)Searcharrayforvalue.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
find
public static int find(boolean[] array, int fromIndex, boolean value)Searcharrayforvaluestarting fromfromIndex.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
total
public static int total(boolean[] array)
Returns the number oftruevalues inarray.
-
any
public static boolean any(boolean[] array)
Returns true, if at least one value inarrayis true.
-
all
public static boolean all(boolean[] array)
Returns true, if all values inarrayare true.
-
set
public static Object set(char[] array, int i, char value)
Shortcut forjava.lang.reflect.Array.setChar( Object array, int i, char value ).
-
find
public static int find(char[] array, char value)Searcharrayforvalue.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
find
public static int find(char[] array, int fromIndex, char value)Searcharrayforvaluestarting fromfromIndex.- Returns:
- first index
iwherearray[i] == valueor-1if not found
-
concat
public static Object concat(Object arr1, Object arr2)
Returns a new array containing the elements of arrayarr1followed by the elements of arrayarr2.
arr1andarr2may be primitive or object arrays but must be of compatible type.
Usesjava.lang.System.arraycopy.
-
concat
public static Object concat(Object... arrays)
Returns a new array containing the elements of all arrays passed as arguments.
arraysmay be primitive or object arrays but must be of compatible type.
Usesjava.lang.System.arraycopy.
Usage in jxn:concat( { arr1, arr2, arr3 } )
-
toArray
public static Object toArray(Object ao)
CallstoArray( ao, 0 ).
-
toArray
public static Object toArray(Object ao, int mode)
Check, ifaois an array or try to callao.toArray().
In addition toKmgStaticUtilities.toArray(java.lang.Object)narrows the result type.- Parameters:
ao- array or instance of a class that implements atoArray()methodmode- controlls what to do, if ao is not an array and atoArray()method is not available for ao
-1 : throws Exception
0 : returnsnull
1 : returns array withaoas the single element
2 : returnsao- Returns:
ao, ifaois an array else
ao.toArray(), iftoArray()method is available else
see parametermode
-
stringArray
public static String[] stringArray(String csvList, String delimChars)
Returns array of tokens fromStringTokenizer.nextToken().- Parameters:
delimChars- passed to ajava.util.StringTokenizer( csvList, delimChars )- See Also:
split(java.lang.String, java.lang.String),KmgStringTokenizer
-
stringArray
public static String[] stringArray(String csvList)
Deprecated.In JXN prefer{ "abc", "xyz" }.
-
doubleArray
public static double[] doubleArray(String csvList)
Deprecated.In JXN prefer{ 2., 3., 5., 7. }.
-
intArray
public static int[] intArray(String csvList)
Deprecated.In JXN prefer{ 123, 456, 789 }.
-
getClass
public static Class getClass(Object ao)
Deprecated.No more needed: Simply callao.getClass(). To calljava.lang.Object.getClass()on the array elements ofaouseJxnObject.getClassArray(ao).Returns the class of an objectao(workaround for array objects in JXN). The automatic array feature of JXN calls methods on the component objects of an array rather than on the array object itself. This inhibits the call of methods ofjava.lang.ObjectespeciallygetClass()on an array object. In JXNao.getClass()(other than in Java) returns ajava.lang.Class[]array containing the component types. As a workaround to get the class of an array objectgetClass(ao)is used instead ofao.getClass().- Returns:
ao.getClass()(java.lang.Object)
-
hashCode
public static int hashCode(Object ao)
Deprecated.No more needed: Simply callao.hashCode(). To calljava.lang.Object.hashCode()on the array elements ofaouseJxnObject.hashCode( @JxnUnroll ao ).Returns the hash code value ofao(workaround for array objects in JXN). As described for thegetClassmethod forao.hashCode()in JXN in case of an arrayaothehashCodemethod is called on the array components ofaorather than on the array object itself. As a workaroundhashCode(ao)is used instead ofao.hashCode().- Returns:
ao.hashCode()(java.lang.Object)
-
equals
public static boolean equals(Object o1, Object o2)
Deprecated.No more needed: Simply callo1.equals(o2). To calljava.lang.Object.equals(Object)on the array elements ofarr1with argument arrayarr2useJxnObject.equals( @JxnUnroll arr1, @JxnUnroll arr2 ).Checks if two objects are equal(workaround for array objects in JXN). As described for the.getClassmethod foro1.equals(o2)in JXN in case of an arrayo1theequalsmethod is called on the array components ofo1rather than on the array object itself. As a workaroundequals(o1,o2)is used instead ofo1.equals(o2)to compare an array objecto1to another objecto2(for array objectsequals(o1,o2)is true, ifo1 == o2(both variableso1ando2refering to the same object))
-
__9_boolean_operators
protected void __9_boolean_operators()
-
not
public static boolean not(boolean x)
Represents the Java boolean operator. For a booleanxin JXN-xcan be used instead ofnot(x).- Returns:
- ! x
-
and
public static boolean and(boolean x, boolean y)Represents the Java boolean operator. For booleansxandyin JXNx*ycan be used instead ofand(x,y).- Returns:
- x
&&y
-
or
public static boolean or(boolean x, boolean y)Represents the Java boolean operator. For booleansxandyin JXNx+ycan be used instead ofor(x,y).- Returns:
- x
||y
-
exor
public static boolean exor(boolean x, boolean y)Represents the Java boolean operator. For booleansxandyin JXNx^ycan be used instead ofexor(x,y).- Returns:
- x ^ y (using the Java boolean exor operator !!)
-
_10_bitwise_operators
protected void _10_bitwise_operators()
-
not
public static long not(long x)
Represents the Java bitwise operator (for long).- Returns:
- ~x
-
not
public static int not(int x)
Represents the Java bitwise operator (for int).- Returns:
- ~x
-
and
public static long and(long x, long y)Represents the Java bitwise operator (for long).- Returns:
- x & y
-
and
public static int and(int x, int y)Represents the Java bitwise operator (for int).- Returns:
- x & y
-
or
public static long or(long x, long y)Represents the Java bitwise operator (for long).- Returns:
- x | y
-
or
public static int or(int x, int y)Represents the Java bitwise operator (for int).- Returns:
- x | y
-
exor
public static long exor(long x, long y)Represents the Java bitwise operator (for long). Note: in jxn the ^ operator ist used to representpow(x,y).- Returns:
- x ^ y (using the Java bitwise exor operator !!)
-
exor
public static int exor(int x, int y)Represents the Java bitwise operator (for int). Note: in jxn the ^ operator ist used to representpow(x,y).- Returns:
- x ^ y (using the Java bitwise exor operator !!)
-
left
public static long left(long x, int i)Represents the Java bit shift operator (for long).- Returns:
- x << i
-
left
public static int left(int x, int i)Represents the Java bit shift operator (for int).- Returns:
- x << i
-
right
public static long right(long x, int i)Represents the Java bit shift operator (for long).- Returns:
- x >> i
-
right
public static int right(int x, int i)Represents the Java bit shift operator (for int).- Returns:
- x >> i
-
right0
public static long right0(long x, int i)Represents the Java bit shift operator (for long).- Returns:
- x >>> i
-
right0
public static int right0(int x, int i)Represents the Java bit shift operator (for int).- Returns:
- x >>> i
-
_11_relational_operators
protected void _11_relational_operators()
-
eq
public static boolean eq(double x, double y)Represents the Java relational operator.- Returns:
- x == y
-
eq
public static boolean eq(long x, long y)Represents the Java relational operator.- Returns:
- x == y
-
eq
public static boolean eq(boolean x, boolean y)Represents the Java relational operator.- Returns:
- x == y
-
ne
public static boolean ne(double x, double y)Represents the Java relational operator.- Returns:
- x != y
-
ne
public static boolean ne(long x, long y)Represents the Java relational operator.- Returns:
- x != y
-
ne
public static boolean ne(boolean x, boolean y)Represents the Java relational operator.- Returns:
- x != y
-
lt
public static boolean lt(double x, double y)Represents the Java relational operator.- Returns:
- x < y
-
lt
public static boolean lt(long x, long y)Represents the Java relational operator.- Returns:
- x < y
-
le
public static boolean le(double x, double y)Represents the Java relational operator.- Returns:
- x <= y
-
le
public static boolean le(long x, long y)Represents the Java relational operator.- Returns:
- x <= y
-
gt
public static boolean gt(double x, double y)Represents the Java relational operator.- Returns:
- x > y
-
gt
public static boolean gt(long x, long y)Represents the Java relational operator.- Returns:
- x > y
-
ge
public static boolean ge(double x, double y)Represents the Java relational operator.- Returns:
x >= y
-
ge
public static boolean ge(long x, long y)Represents the Java relational operator.- Returns:
- x >= y
-
isSame
public static boolean isSame(Object x, Object y)
Returns true if x == y (references to the same (identical) instance).- Returns:
- x == y
- See Also:
Object.equals(java.lang.Object)
-
isNull
public static boolean isNull(Object o)
Returns true if o == null.- Returns:
- o == null.
-
isNull
public static boolean isNull(double x)
Allows the generic check of arbitrary variables (e.g.arguments passed to jxn files). A variable may be an object or a Java primitve. In case of a primitive theisNull(Object)method does not match. Instead this method is called and always returns false;- Returns:
- always returns false
-
isPrimitiveOrJavaWrapper
public static boolean isPrimitiveOrJavaWrapper(Object x)
Used in jxn files to check the type ofx. Called in jxn files forisPrimitiveOrJavaWrapper(x)ifxis an object reference (except Java primitive wrapper). Also consider:JxnObject.getClass(x).isPrimitive()(returnsfalsefor Java primitive wrapper).- Returns:
- false
-
isPrimitiveOrJavaWrapper
public static boolean isPrimitiveOrJavaWrapper(double x)
Used in jxn files to check the type ofx. Called in jxn files forisPrimitiveOrJavaWrapper(x)ifxis a primitive or Java primitive wrapper. Also consider:JxnObject.getClass(x).isPrimitive()(returnsfalsefor Java primitive wrapper).- Returns:
- true
-
isArray
public static boolean isArray(Object o)
Returns true if o is an array (null returns false).
-
contains
public static boolean contains(String chars, char ch)
Returns true ifcharscontainsch.
-
_12_formula_switching
protected void _12_formula_switching()
-
sw
public static int sw(int ivar, double slider_switch)Returns1ifivar-0.5 <= slider_switch < ivar+0.5else0.
-
sw
public static double sw(boolean b, double yTrue, double yFalse)ReturnsyTrue, ifbis true elseyFalse.
-
sw
public static long sw(boolean b, long yTrue, long yFalse)ReturnsyTrue, ifbis true elseyFalse.
-
sw
public static int sw(boolean b, int yTrue, int yFalse)ReturnsyTrue, ifbis true elseyFalse.
-
sw
public static Object sw(boolean b, Object oTrue, Object oFalse)
ReturnsoTrue, ifbis true elseoFalse.
-
sw
public static double sw(double x, double yLT, double yGE)ReturnsyLT, ifx < 0.elseyGE.
-
sw
public static long sw(double x, long yLT, long yGE)ReturnsyLT, ifx < 0.elseyGE.
-
sw
public static int sw(double x, int yLT, int yGE)ReturnsyLT, ifx < 0.elseyGE.
-
sw
public static double sw(double x, double yLT, double yEQ, double yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.
-
sw
public static long sw(double x, long yLT, long yEQ, long yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.
-
sw
public static int sw(double x, int yLT, int yEQ, int yGT)ReturnsyLT, ifx < 0.elseyGT, ifx > 0.elseyEQ.
-
sw
public static Object sw(double x, Object oLT, Object oEQ, Object oGT)
ReturnsoLT, ifx < 0elseoGT, ifx > 0elseoEQ.
-
sw
public static double sw(double x, double eps, double yLower, double yInner, double yUpper)ReturnsyLower, ifx < -epselseyUpper, ifx > epselseyInner.
-
sw
public static Object sw(double x, double eps, Object oLower, Object oInner, Object oUpper)
ReturnsoLower, ifx < -epselseoUpper, ifx > epselseoInner.
-
sw
public static double sw(double x, double xLower, double xUpper, double yLower, double yInner, double yUpper)ReturnsyLower, ifx < xLowerelseyUpper, ifx > xUpperelseyInner.
-
sw
public static Object sw(double x, double xLower, double xUpper, Object oLower, Object oInner, Object oUpper)
ReturnsoLower, ifx < xLowerelseoUpper, ifx > xUpperelseoInner.
-
limit
public static double limit(double x, double xmin, double xmax)Keepsxwithinxminandxmax.- Returns:
xmin, ifx < xminelsexmax, ifx > xmaxelsex.
-
limit
public static long limit(long x, long xmin, long xmax)Keepsxwithinxminandxmax.- Returns:
xmin, ifx < xminelsexmax, ifx > xmaxelsex.
-
limit
public static int limit(int x, int xmin, int xmax)Keepsxwithinxminandxmax.- Returns:
xmin, ifx < xminelsexmax, ifx > xmaxelsex.
-
clip
public static double clip(double x, double lower, double upper)- Returns:
if( lower < upper ) x if lower <= x <= upper Double.NaN else else if( lower > upper ) Double.NaN if upper < x < lower x else else // lower == upper Double.NaN if lower == x == upper x else- See Also:
JxnRealArrayAlgebra.clip(JxnRealArrayAlgebra, double, double)
-
-