mathlib-commitlog Mailing List for JMathLib - Octave, Matlab clone in java (Page 44)
Status: Beta
Brought to you by:
st_mueller
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(4) |
Aug
(150) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(233) |
Feb
(86) |
Mar
(32) |
Apr
(26) |
May
(73) |
Jun
(45) |
Jul
(23) |
Aug
(23) |
Sep
(5) |
Oct
(80) |
Nov
(11) |
Dec
(11) |
| 2008 |
Jan
|
Feb
|
Mar
(13) |
Apr
(3) |
May
(7) |
Jun
(30) |
Jul
(12) |
Aug
(12) |
Sep
|
Oct
|
Nov
(78) |
Dec
(78) |
| 2009 |
Jan
(214) |
Feb
(79) |
Mar
(20) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:57:23
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7910/Source/MathLib/Tokens Modified Files: NumberToken.java Log Message: moved internal functions to individual java-classes Index: NumberToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/NumberToken.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** NumberToken.java 12 Jan 2007 21:49:35 -0000 1.100 --- NumberToken.java 13 Jan 2007 10:57:18 -0000 1.101 *************** *** 1614,1630 **** } - /**@return true if this number token is an integral matrix, without an imaginary part*/ - public boolean isInteger() - { - // if at least one element has an imaginary part the matrix is not real, or is not integral - for (int n=0; n<noElem; n++) - { - if ((getValueIm(n) != 0 ) || - (getValueRe(n) != Math.floor(getValueRe(n)) ) ) - return false; - } - return true; - } - /**@return true if this number token is an imaginary matrix, without a real part*/ public boolean isImaginary() --- 1614,1617 ---- *************** *** 1662,1695 **** } ! public OperandToken degreesToRadians() ! { ! //convert from degrees to radians ! double[][] values = getReValues(); ! ! for(int yy = 0; yy < sizeY; yy++) ! { ! for(int xx = 0; xx < sizeX; xx++) ! { ! values[yy][xx] = values[yy][xx] * Math.PI / 180; ! } ! } ! ! return new NumberToken(values); ! } ! ! public OperandToken radiansToDegrees() ! { ! //convert from degrees to radians ! double[][] values = getReValues(); ! ! for(int yy = 0; yy < sizeY; yy++) ! { ! for(int xx = 0; xx < sizeX; xx++) ! { ! values[yy][xx] = values[yy][xx] * 180 / Math.PI; ! } ! } ! ! return new NumberToken(values); ! } ! } --- 1649,1651 ---- } ! } // end NumberToken |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:56:10
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7177/Source/MathLib/Functions Modified Files: FunctionManager.java Log Message: removed StandardFunctions.java and TrigonometricFunctions.java Index: FunctionManager.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/FunctionManager.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** FunctionManager.java 13 Jan 2007 10:23:02 -0000 1.50 --- FunctionManager.java 13 Jan 2007 10:56:05 -0000 1.51 *************** *** 15,20 **** public class FunctionManager { - /**A list of the standard functions*/ - Vector standardFunctions; /**A list of all the functions defined by the user*/ --- 15,18 ---- *************** *** 48,62 **** public FunctionManager(boolean _runningStandalone, Flags sysFlags) { - standardFunctions = new Vector(11); - standardFunctions.addElement(new InternalFunction("ABS")); - standardFunctions.addElement(new InternalFunction("EXP")); - standardFunctions.addElement(new InternalFunction("XXXLOG")); - standardFunctions.addElement(new InternalFunction("XXXLN")); - standardFunctions.addElement(new InternalFunction("XXXSQRT")); - standardFunctions.addElement(new InternalFunction("XXXFLOOR")); - standardFunctions.addElement(new InternalFunction("XXXCEIL")); - standardFunctions.addElement(new InternalFunction("XXXROUND")); - standardFunctions.addElement(new InternalFunction("PATH")); - userFunctions = new HashMap(); --- 46,49 ---- *************** *** 350,363 **** } - //finally check the lists of internal functions - //check standard functions - index = standardFunctions.indexOf(token); - if(index > -1) - { - MathLib.Interpreter.ErrorLogger.debugLine("Found standard function "+index); - func = new StandardFunction(index); - return func; - } - return func; } --- 337,340 ---- |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:55:10
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6610/Source/MathLib/Functions Modified Files: StandardFunction.java Log Message: Index: StandardFunction.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/StandardFunction.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StandardFunction.java 16 Dec 2006 13:21:01 -0000 1.12 --- StandardFunction.java 13 Jan 2007 10:55:02 -0000 1.13 *************** *** 1,98 **** ! package MathLib.Functions; ! ! import MathLib.Tokens.Token; ! import MathLib.Tokens.OperandToken; ! import MathLib.Tokens.CharToken; ! ! import java.util.Vector; ! ! /**Class implementing the standard mathematical functions*/ ! public class StandardFunction extends InternalFunction ! { ! /**Index number of the function within the vector of standard functions*/ ! private int index; ! ! /**constants for function indices*/ ! static private final int ABS = 0; ! static private final int EXP = 1; ! static private final int LOG = 2; ! static private final int LN = 3; ! static private final int SQRT = 4; ! static private final int FLOOR = 5; ! static private final int CEIL = 6; ! static private final int ROUND = 7; ! static private final int PATH = 8; ! ! ! /**function names*/ ! static private final String[] fun_names = {"abs", "exp", "log", "ln", "sqrt", "floor", "ceil", "round", "path"}; ! ! /**Creates a standard function with the index set to _index ! @param _index = the index of the function*/ ! public StandardFunction(int _index) ! { ! index = _index; ! } ! ! /**Executes the function - the code run is based on the index number ! @param operands - the array of parameters ! @return the result of the function as an OperandToken*/ ! public OperandToken evaluate(Token[] operands) ! { ! OperandToken result = null; ! ! if (operands.length!=1) ! throwMathLibException("too many input arguments"); ! ! ! //execute the function depending on the index ! switch(index) ! { ! case ABS: ! result = ((OperandToken)operands[0]).abs(); ! break; ! case EXP: ! result = ((OperandToken)operands[0]).exp(); ! break; ! case LOG: ! result = ((OperandToken)operands[0]).log(); ! break; ! case LN: ! result = ((OperandToken)operands[0]).ln(); ! break; ! case SQRT: ! result = ((OperandToken)operands[0]).sqrt(); ! break; ! case FLOOR: ! result = ((OperandToken)operands[0]).floor(); ! break; ! case CEIL: ! result = ((OperandToken)operands[0]).ceil(); ! break; ! case ROUND: ! result = ((OperandToken)operands[0]).round(); ! break; ! case PATH: ! StringBuffer temp = new StringBuffer(); ! ! Vector path = getFlags().getPath(); ! int size = path.size(); ! ! for(int index = 0; index < size; index++) ! { ! temp.append(((String)path.elementAt(index)) + "\n"); ! } ! ! result = new CharToken(new String(temp)); ! break; ! } ! return result; ! } ! ! public String getName() ! { ! return fun_names[index]; ! } ! ! } --- 1,3 ---- ! // ! // all standard functions have been moved to individual java-classes \ No newline at end of file |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:54:03
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/System In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6211/Source/MathLib/Functions/System Modified Files: Path.java Log Message: Index: Path.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/System/Path.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Path.java 25 Nov 2006 13:29:13 -0000 1.5 --- Path.java 13 Jan 2007 10:53:59 -0000 1.6 *************** *** 37,41 **** --- 37,43 ---- @NOTES @EXAMPLES + <programlisting> path() + </programlisting> @SEE addpath, rmpath |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:46:56
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3197/Source/MathLib/Functions/Matrix Modified Files: abs.java Log Message: Index: abs.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/abs.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** abs.java 12 Jan 2007 21:48:27 -0000 1.1 --- abs.java 13 Jan 2007 10:46:52 -0000 1.2 *************** *** 44,50 **** --- 44,53 ---- @NOTES @EXAMPLES + <programlisting> abs(-5) = 5 abs(2) = 2 abs(3 + 4I) = 5 + <programlisting> + @SEE */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:45:15
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Internal In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2408/Source/MathLib/Functions/Internal Removed Files: round.int sinh.int cosh.int log.int asinh.int atanh.int atan.int ln.int sqrt.int cos.int tan.int acosh.int ceil.int sin.int acos.int asin.int floor.int tanh.int Log Message: --- sin.int DELETED --- --- round.int DELETED --- --- tan.int DELETED --- --- ceil.int DELETED --- --- floor.int DELETED --- --- atan.int DELETED --- --- asin.int DELETED --- --- asinh.int DELETED --- --- acos.int DELETED --- --- tanh.int DELETED --- --- sqrt.int DELETED --- --- log.int DELETED --- --- cosh.int DELETED --- --- sinh.int DELETED --- --- acosh.int DELETED --- --- ln.int DELETED --- --- atanh.int DELETED --- --- cos.int DELETED --- |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:42:40
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1456/Source/MathLib/Functions/Trigonometric Added Files: cosh.java Log Message: --- NEW FILE: cosh.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; public class cosh extends ExternalElementWiseFunction { public cosh() { name = "cosh"; } /**Calculates the hyperbolic cosine of a complex number * @param arg = the angle as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; double scalar; double _re1, _im1; double _re2, _im2; // _1: z.exp() ... scalar = Math.exp(arg[REAL]); _re1 = scalar * Math.cos(arg[IMAG]); _im1 = scalar * Math.sin(arg[IMAG]); // _2: z.neg().exp() ... scalar = Math.exp(-arg[REAL]); _re2 = scalar * Math.cos(-arg[IMAG]); _im2 = scalar * Math.sin(-arg[IMAG]); // _1: _1.Plus(_2) ... _re1 = _re1 + _re2; // !!! _im1 = _im1 + _im2; // !!! // result: _1.scale(0.5) ... result[REAL] = 0.5 * _re1; result[IMAG] = 0.5 * _im1; return result; } } /* @GROUP trigonometric @SYNTAX cosh(angle) @DOC Returns the hyperbolic cosine of angle. @EXAMPLES <programlisting> cosh(0) = 1 cosh(1.5707963267948966) = 2.5091784786580567 </programlisting> @SEE cos, acosh, acos, sin, asin, asinh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:40:45
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv534/Source/MathLib/Functions/Trigonometric Added Files: atanh.java Log Message: --- NEW FILE: atanh.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; import MathLib.Functions.Matrix.log; public class atanh extends ExternalElementWiseFunction { public atanh() { name = "atanh"; } /**Calculates the inverse hyperbolic tangent of a complex number * @param arg = the angle as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; // atanh(z) = 1/2 * log( (1+z)/(1-z) ) // _1: one.Minus(z) ... double[] temp = new double[2]; temp[REAL] = 1 - arg[REAL]; temp[IMAG] = - arg[IMAG]; // result: one.Plus(z) ... result[REAL] = 1 + arg[REAL]; // result: result.Div(_1) ... NumberToken num = new NumberToken(); result = num.divide(result, temp); // _1: result.log() ... log logFunc = new log(); result = logFunc.evaluateValue(result); // result: _1.scale(0.5) ... result[REAL] = 0.5 * result[REAL]; result[IMAG] = 0.5 * result[IMAG]; return result; } } /* @GROUP trigonometric @SYNTAX atanh(value) @DOC Returns the arc hyperbolic tangent of the first value. @EXAMPLES <programlisting> atanh(1) = NaN atanh(0) = 0 </programlisting> @SEE tan, tanh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:35:01
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30397/Source/MathLib/Functions/Trigonometric Added Files: atan.java Log Message: --- NEW FILE: atan.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; import MathLib.Functions.Matrix.log; public class atan extends ExternalElementWiseFunction { public atan() { name = "atan"; } /**Calculates the arctangent of a complex number @param arg = the value as an array of double @return the result as an array of double*/ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; double[] temp = new double[2]; // atan(z) = -i/2 * log( (i-z)/(i+z) ) double _re1, _im1; // result: i.Minus(z) ... temp[REAL] = -arg[REAL]; temp[IMAG] = 1 - arg[IMAG]; // _1: i.Plus(z) ... result[REAL] = arg[REAL]; result[IMAG] = 1 + arg[IMAG]; // result: result.Div(_1) ... NumberToken num = new NumberToken(); result = num.divide(temp, result); // _1: result.log() ... log logFunc = new log(); result = logFunc.evaluateValue(result); // result: half_i.neg().Times(_2) ... double t = -0.5 * result[REAL]; result[REAL] = 0.5 * result[IMAG]; result[IMAG] = t; return result; } } /* @GROUP trigonometric @SYNTAX atan(angle) @DOC Calculates the inverse tangent of angle. @EXAMPLES <programlisting> atan(1) = 0.7853981633974483 atan(0) = 0 </programlisting> @SEE atan2, tan */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:32:33
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29411/Source/MathLib/Functions/Trigonometric Added Files: tanh.java Log Message: --- NEW FILE: tanh.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class tanh extends ExternalElementWiseFunction { public tanh() { name = "tanh"; } /**Calculates the hyperbolic tangent of a complex number * @param arg = the angle as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { sinh sinhF = new sinh(); cosh coshF = new cosh(); double[] temp1 = sinhF.evaluateValue(arg); double[] temp2 = coshF.evaluateValue(arg); NumberToken num= null; return num.divide(temp1, temp2); } } /* @GROUP trigonometric @SYNTAX tanh(angle) @DOC Returns the hyperbolic tangent of angle. @EXAMPLES <programlisting> tanh(0) = 0 tanh(1) = 0.76159 </programlisting> @SEE tan, atanh, cos, sin */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:30:57
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28574/Source/MathLib/Functions/Trigonometric Added Files: sinh.java Log Message: --- NEW FILE: sinh.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; public class sinh extends ExternalElementWiseFunction { public sinh() { name = "sinh"; } /**Calculates the hyperbolic sine of a complex number * @param arg = the angle as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; double scalar; double _re1, _im1; double _re2, _im2; // _1: z.exp() ... scalar = Math.exp(arg[REAL]); _re1 = scalar * Math.cos(arg[IMAG]); _im1 = scalar * Math.sin(arg[IMAG]); // _2: z.neg().exp() ... scalar = Math.exp(-arg[REAL]); _re2 = scalar * Math.cos(-arg[IMAG]); _im2 = scalar * Math.sin(-arg[IMAG]); // _1: _1.Minus(_2) ... _re1 = _re1 - _re2; // !!! _im1 = _im1 - _im2; // !!! // result: _1.scale(0.5) ... result[REAL] = 0.5 * _re1; result[IMAG] = 0.5 * _im1; return result; } } /* @GROUP trigonometric @SYNTAX sinh(angle) @DOC Returns the hyperbolic sine of angle. @EXAMPLES <programlisting> sinh(0) = 0 sinh(1) = 1.175201 </programlisting> @SEE sin, asinh, cos, cosh, acosh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:29:23
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28075/Source/MathLib/Functions/Trigonometric Added Files: asinh.java Log Message: --- NEW FILE: asinh.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Functions.Matrix.log; import MathLib.Functions.Matrix.sqrt; public class asinh extends ExternalElementWiseFunction { public asinh() { name = "asinh"; } /**Calculates the inverse hyperbolic sine of a complex number @param arg = the value as an array of double @return the result as an array of double*/ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; // asinh(z) = log(z + Sqrt(z*z + 1)) double re = arg[REAL]; double im = arg[IMAG]; // _1: z.Times(z).Plus(one) ... result[REAL] = ( (re*re) - (im*im) ) + 1.0; result[IMAG] = ( (re*im) + (im*re) ); // result: _1.Sqrt() ... sqrt sqrtFunc = new sqrt(); result = sqrtFunc.evaluateValue(result); // result: z.Plus(result) ... result[REAL] = re + result[REAL]; // ! result[IMAG] = im + result[IMAG]; // ! // _1: result.log() ... log logFunc = new log(); result = logFunc.evaluateValue(result); return result; } } /* @GROUP trigonometric @SYNTAX angle = asinh(value); @DOC Returns the arc hyperbolic sine @EXAMPLES <programlisting> asinh(1) = 0.8813735870195429 asinh(0) = 0 </programlisting> @SEE sinh, asin, cosh, acos */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:26:51
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26848/Source/MathLib/Functions/Trigonometric Added Files: asin.java Log Message: --- NEW FILE: asin.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Functions.Matrix.log; import MathLib.Functions.Matrix.sqrt; public class asin extends ExternalElementWiseFunction { public asin() { name = "asin"; } /**Calculates the arcsine of a complex number * @param arg = the value as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; // asin(z) = -i * log(i*z + Sqrt(1 - z*z)) double re = arg[REAL]; double im = arg[IMAG]; // _1: one.Minus(z.Times(z)) ... result[REAL] = 1.0 - ( (re*re) - (im*im) ); result[IMAG] = 0.0 - ( (re*im) + (im*re) ); // result: _1.Sqrt() ... sqrt s= new sqrt(); result = s.evaluateValue(result); // _1: z.Times(i) ... // result: _1.Plus(result) ... result[REAL] = result[REAL] - im; result[IMAG] = result[IMAG] + re; // _1: result.log() ... log logFunc = new log(); result = logFunc.evaluateValue(result); double temp = result[IMAG]; result[IMAG] = -result[REAL]; result[REAL] = temp; return result; } } /* @GROUP trigonometric @SYNTAX angle=ASIN(value) @DOC Returns the arc sine of the first operand. @EXAMPLES ASIN(1) = 1.5707963267948966 ASIN(0) = 0 @SEE sin, asinh, cos, acos, acosh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:25:26
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26386/Source/MathLib/Functions/Trigonometric Added Files: acos.java Log Message: --- NEW FILE: acos.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Functions.Matrix.log; import MathLib.Functions.Matrix.sqrt; public class acos extends ExternalElementWiseFunction { public acos() { name = "acos"; } /**Calculates the arccosine of a complex number * @param arg = the value as an array of double * @return the result as an array of double */ public double[] evaluateValue(double[] arg) { double result[] = new double[2]; double _re1, _im1; double re = arg[REAL]; double im = arg[IMAG]; // _1: one - z^2 ... result[REAL] = 1.0 - ( (re*re) - (im*im) ); result[IMAG] = 0.0 - ( (re*im) + (im*re) ); // result: _1.Sqrt() ... sqrt sqrtFunc = new sqrt(); result = sqrtFunc.evaluateValue(result); // _1: i * result ... _re1 = - result[IMAG]; _im1 = + result[REAL]; // result: z +_1 ... result[REAL] = re + _re1; result[IMAG] = im + _im1; // _1: result.log() log logFunc = new log(); result = logFunc.evaluateValue(result); // result: -i * _1 ... double temp = result[IMAG]; result[IMAG] = -result[REAL]; result[REAL] = temp; return result; } } /* @GROUP trigonometric @SYNTAX angle = ACOS(value) @DOC Returns the arc cosine of value. @EXAMPLES ACOS(1) = 0 ACOS(0) = 1.5707963267948966 @SEE cos, acosh, sin, asin, asinh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:23:07
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25092/Source/MathLib/Functions Modified Files: FunctionManager.java Log Message: removed all trigonometric functions Index: FunctionManager.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/FunctionManager.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** FunctionManager.java 2 Jan 2007 16:09:27 -0000 1.49 --- FunctionManager.java 13 Jan 2007 10:23:02 -0000 1.50 *************** *** 15,21 **** public class FunctionManager { - /**A list of the trigonometric functions*/ - Vector trigonometricFunctions; - /**A list of the standard functions*/ Vector standardFunctions; --- 15,18 ---- *************** *** 51,89 **** public FunctionManager(boolean _runningStandalone, Flags sysFlags) { - trigonometricFunctions = new Vector(24); - trigonometricFunctions.addElement(new InternalFunction("SIN")); - trigonometricFunctions.addElement(new InternalFunction("COS")); - trigonometricFunctions.addElement(new InternalFunction("TAN")); - trigonometricFunctions.addElement(new InternalFunction("SINH")); - trigonometricFunctions.addElement(new InternalFunction("COSH")); - trigonometricFunctions.addElement(new InternalFunction("TANH")); - trigonometricFunctions.addElement(new InternalFunction("CSC")); - trigonometricFunctions.addElement(new InternalFunction("SEC")); - trigonometricFunctions.addElement(new InternalFunction("COT")); - trigonometricFunctions.addElement(new InternalFunction("CSCH")); - trigonometricFunctions.addElement(new InternalFunction("SECH")); - trigonometricFunctions.addElement(new InternalFunction("COTH")); - trigonometricFunctions.addElement(new InternalFunction("ASIN")); - trigonometricFunctions.addElement(new InternalFunction("ACOS")); - trigonometricFunctions.addElement(new InternalFunction("ATAN")); - trigonometricFunctions.addElement(new InternalFunction("ASINH")); - trigonometricFunctions.addElement(new InternalFunction("ACOSH")); - trigonometricFunctions.addElement(new InternalFunction("ATANH")); - trigonometricFunctions.addElement(new InternalFunction("ACSC")); - trigonometricFunctions.addElement(new InternalFunction("ASEC")); - trigonometricFunctions.addElement(new InternalFunction("ACOT")); - trigonometricFunctions.addElement(new InternalFunction("ACSCH")); - trigonometricFunctions.addElement(new InternalFunction("ASECH")); - trigonometricFunctions.addElement(new InternalFunction("ACOTH")); - standardFunctions = new Vector(11); standardFunctions.addElement(new InternalFunction("ABS")); standardFunctions.addElement(new InternalFunction("EXP")); ! standardFunctions.addElement(new InternalFunction("LOG")); ! standardFunctions.addElement(new InternalFunction("LN")); ! standardFunctions.addElement(new InternalFunction("SQRT")); ! standardFunctions.addElement(new InternalFunction("FLOOR")); ! standardFunctions.addElement(new InternalFunction("CEIL")); ! standardFunctions.addElement(new InternalFunction("ROUND")); standardFunctions.addElement(new InternalFunction("PATH")); --- 48,60 ---- public FunctionManager(boolean _runningStandalone, Flags sysFlags) { standardFunctions = new Vector(11); standardFunctions.addElement(new InternalFunction("ABS")); standardFunctions.addElement(new InternalFunction("EXP")); ! standardFunctions.addElement(new InternalFunction("XXXLOG")); ! standardFunctions.addElement(new InternalFunction("XXXLN")); ! standardFunctions.addElement(new InternalFunction("XXXSQRT")); ! standardFunctions.addElement(new InternalFunction("XXXFLOOR")); ! standardFunctions.addElement(new InternalFunction("XXXCEIL")); ! standardFunctions.addElement(new InternalFunction("XXXROUND")); standardFunctions.addElement(new InternalFunction("PATH")); *************** *** 380,392 **** //finally check the lists of internal functions - //check trigonometric functions - index = trigonometricFunctions.indexOf(token); - if(index > -1) - { - MathLib.Interpreter.ErrorLogger.debugLine("Found trig function "+index); - func = new TrigonometricFunction(index); - return func; - } - //check standard functions index = standardFunctions.indexOf(token); --- 351,354 ---- |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:21:55
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24585/Source/MathLib/Functions Modified Files: TrigonometricFunction.java Log Message: removed all functions from internal NumberToken to individual java-classes Index: TrigonometricFunction.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/TrigonometricFunction.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** TrigonometricFunction.java 26 Aug 2006 17:27:06 -0000 1.15 --- TrigonometricFunction.java 13 Jan 2007 10:21:51 -0000 1.16 *************** *** 1,190 **** ! package MathLib.Functions; ! ! import MathLib.Tokens.Token; ! import MathLib.Tokens.OperandToken; ! import MathLib.Tokens.NumberToken; ! import MathLib.Tokens.MulDivOperatorToken; ! import MathLib.Tokens.Expression; ! import MathLib.Interpreter.*; ! ! /**Class implementing trigonometric functions*/ ! public class TrigonometricFunction extends Function ! { ! /**Index number of the function within the vector of standard functions*/ ! private int index; ! ! static private final String[] fun_names = {"sin", // 0 ! "cos", ! "tan", ! "sinh", // 3 ! "cosh", ! "tanh", ! "csc", // 6 ! "sec", ! "cot", ! "csch", // 9 ! "sech", ! "coth", ! "asin", //12 ! "acos", ! "atan", ! "asinh", //15 ! "acosh", ! "atanh", ! "acsc", //18 ! "asec", ! "acot", ! "acsch", //21 ! "asech", ! "acoth"}; ! ! /**function indices*/ ! static private final int SIN = 0; ! static private final int COS = 1; ! static private final int TAN = 2; ! static private final int SINH = 3; ! static private final int COSH = 4; ! static private final int TANH = 5; ! static private final int CSC = 6; ! static private final int SEC = 7; ! static private final int COT = 8; ! static private final int CSCH = 9; ! static private final int SECH = 10; ! static private final int COTH = 11; ! ! static private final int ASIN = 12; ! static private final int ACOS = 13; ! static private final int ATAN = 14; ! static private final int ASINH = 15; ! static private final int ACOSH = 16; ! static private final int ATANH = 17; ! static private final int ACSC = 18; ! static private final int ASEC = 19; ! static private final int ACOT = 20; ! static private final int ACSCH = 21; ! static private final int ASECH = 22; ! static private final int ACOTH = 23; ! ! /**Creates a trigonometric function with the index set to _index ! @param index = the index number of the function*/ ! public TrigonometricFunction(int _index) ! { ! index = _index; ! } ! ! /**Executes the function - the code run is based on the index number ! @param operands - the array of parameters ! @return the result of the function as an OperandToken*/ ! public OperandToken evaluate(Token[] operands) ! { ! OperandToken result = null; ! OperandToken temp = null; ! ! ErrorLogger.debugLine("Trignonometric func: "+index); ! ! OperandToken value = ((OperandToken)operands[0]); ! ! //if(index < ASIN) ! // value = value.degreesToRadians(); ! ! //execute the function depending on the index ! switch(index) ! { ! case SIN: ! result = value.sin(); ! break; ! case COS: ! result = value.cos(); ! break; ! case TAN: ! result = value.tan(); ! break; ! case ASIN: ! result = value.asin(); ! break; ! case ACOS: ! result = value.acos(); ! break; ! case ATAN: ! result = value.atan(); ! break; ! case SINH: ! result = value.sinh(); ! break; ! case COSH: ! result = value.cosh(); ! break; ! case TANH: ! result = value.tanh(); ! break; ! case ASINH: ! result = value.asinh(); ! break; ! case ACOSH: ! result = value.acosh(); ! break; ! case ATANH: ! result = value.atanh(); ! break; ! case CSC: ! temp = value.sin(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case SEC: ! temp = value.cos(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case COT: ! temp = value.tan(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case CSCH: ! temp = value.sinh(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case SECH: ! temp = value.cosh(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case COTH: ! temp = value.tanh(); ! result = new Expression(MulDivOperatorToken.divide, NumberToken.one, temp).evaluate(null); ! break; ! case ACSC: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.asin(); ! break; ! case ASEC: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.acos(); ! break; ! case ACOT: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.atan(); ! break; ! case ACSCH: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.asinh(); ! break; ! case ASECH: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.acosh(); ! break; ! case ACOTH: ! temp = new Expression(MulDivOperatorToken.divide, NumberToken.one, ((OperandToken)operands[0])).evaluate(null); ! result = temp.atanh(); ! break; ! } ! ! //if(index >= ASIN) ! // result = result.radiansToDegrees(); ! ! return result; ! } ! ! public String getName() ! { ! return fun_names[index]; ! } ! ! } --- 1,2 ---- ! // ! // all functions have been moved into individual java-classes \ No newline at end of file |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:20:42
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24131/Source/MathLib/Functions/Trigonometric Added Files: acoth.java Log Message: --- NEW FILE: acoth.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class acoth extends ExternalElementWiseFunction { public acoth() { name = "acoth"; } /**trigonometric functions -calculates the inverse hperbolic cotangent * @param double value array * @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); atanh atanhFunc = new atanh(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = atanhFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX acoth(value) @DOC calculates the inverse hperbolic cotangent @NOTES @EXAMPLES <programlisting> y = acoth(x) </progamlisting> @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:18:31
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23119/Source/MathLib/Functions/Trigonometric Added Files: asech.java Log Message: --- NEW FILE: asech.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class asech extends ExternalElementWiseFunction { public asech() { name = "asech"; } /**trigonometric functions -calculates the inverse hperbolic secant * @param double value array * @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); acosh acoshFunc = new acosh(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = acoshFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX asech(value) @DOC calculates the inverse hperbolic secant @NOTES @EXAMPLES <programlisting> y = asech(x) </progamlisting> @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:16:54
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22239/Source/MathLib/Functions/Trigonometric Added Files: acsch.java Log Message: --- NEW FILE: acsch.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class acsch extends ExternalElementWiseFunction { public acsch() { name = "acsch"; } /**trigonometric functions -calculates the inverse hperbolic cosecant * @param double value array * @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); asinh asinhFunc = new asinh(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = asinhFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX acsch(value) @DOC calculates the inverse hperbolic cosecant @NOTES @EXAMPLES <programlisting> y = acsch(x) </progamlisting> @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:14:39
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21169/Source/MathLib/Functions/Trigonometric Added Files: acot.java Log Message: --- NEW FILE: acot.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class acot extends ExternalElementWiseFunction { public acot() { name = "acot"; } /**trigonometric functions -calculates the inverse cotangent * @param double value array * @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); atan atanFunc = new atan(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = atanFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX acot(value) @DOC calculates the inverse cotangent @NOTES @EXAMPLES <programlisting> y = acot(x) </progamlisting> @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:12:21
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20240/Source/MathLib/Functions/Trigonometric Added Files: asec.java Log Message: --- NEW FILE: asec.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class asec extends ExternalElementWiseFunction { public asec() { name = "asec"; } /**trigonometric functions -calculates the inverse secant * @param double value array * @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); acos acosFunc = new acos(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = acosFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX asec(value) @DOC calculates the inverse secant @NOTES @EXAMPLES <programlisting> y = asec(x) </progamlisting> @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:03:20
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv16163/Source/MathLib/Functions/Trigonometric Added Files: acsc.java Log Message: --- NEW FILE: acsc.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class acsc extends ExternalElementWiseFunction { public acsc() { name = "acsc"; } /**trigonometric functions - calculates the inverse cosecans @param double value array @return the result as a double array */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); asin asinFunc = new asin(); double[] temp = num.divide(new double[]{1,0}, arg); double[] result = asinFunc.evaluateValue(temp); return result; } } /* @GROUP trigonometric @SYNTAX acsc(value) @DOC calculates the inverse cosecans @NOTES @EXAMPLES . @SEE sec, cot, csch, sech, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-13 10:00:26
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv14335/Source/MathLib/Functions/Trigonometric Added Files: sech.java Log Message: --- NEW FILE: sech.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class sech extends ExternalElementWiseFunction { public sech() { name = "sech"; } /**trigonometric functions - calculate the hyperbolic secant of this token @param double value @return the result as an OperandToken */ public double[] evaluateValue(double[] arg) { NumberToken num = new NumberToken(); cosh coshF = new cosh(); double[] temp = coshF.evaluateValue(arg); double[] result = num.divide(new double[]{1,0}, temp); return result; } } /* @GROUP trigonometric @SYNTAX sech(value) @DOC . @NOTES @EXAMPLES . @SEE csc, cot, csch, sec, coth */ |
|
From: Stefan M. <st_...@us...> - 2007-01-12 21:52:49
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Trigonometric In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2391/Source/MathLib/Functions/Trigonometric Added Files: tan.java Log Message: --- NEW FILE: tan.java --- package MathLib.Functions.Trigonometric; import MathLib.Functions.ExternalElementWiseFunction; import MathLib.Tokens.NumberToken; public class tan extends ExternalElementWiseFunction { public tan() { name = "tan"; } /**trigonometric functions - calculate the tangent of this token @return the result as an OperandToken*/ public double[] evaluateValue(double[] arg) { double[] temp1 = sin(arg); double[] temp2 = cos(arg); NumberToken t = new NumberToken(); double[] result = t.divide(temp1, temp2); return result; } public double[] sin(double[] arg) { double result[] = new double[2]; double scalar; double iz_re, iz_im; double _re1, _im1; double _re2, _im2; // iz: i.Times(z) ... iz_re = -arg[IMAG]; iz_im = arg[REAL]; // _1: iz.exp() ... scalar = Math.exp(iz_re); _re1 = scalar * Math.cos(iz_im); _im1 = scalar * Math.sin(iz_im); // _2: iz.neg().exp() ... scalar = Math.exp(-iz_re); _re2 = scalar * Math.cos(-iz_im); _im2 = scalar * Math.sin(-iz_im); // _1: _1.Minus(_2) ... _re1 = _re1 - _re2; // !!! _im1 = _im1 - _im2; // !!! // result: _1.Div(2*i) ... result[REAL] = 0.5*_im1; result[IMAG] = -0.5*_re1; return result; } public double[] cos(double[] arg) { double result[] = new double[2]; double scalar; double iz_re, iz_im; double _re1, _im1; double _re2, _im2; // iz: i.Times(z) ... iz_re = -arg[IMAG]; iz_im = arg[REAL]; // _1: iz.exp() ... scalar = Math.exp(iz_re); _re1 = scalar * Math.cos(iz_im); _im1 = scalar * Math.sin(iz_im); // _2: iz.neg().exp() ... scalar = Math.exp(-iz_re); _re2 = scalar * Math.cos(-iz_im); _im2 = scalar * Math.sin(-iz_im); // _1: _1.Plus(_2) ... _re1 = _re1 + _re2; // !!! _im1 = _im1 + _im2; // !!! // result: _1.scale(0.5) ... result[REAL] = 0.5*_re1; result[IMAG] = -0.5*_im1; return result; } } /* @GROUP trigonometric @SYNTAX answer = tan(angle) @DOC Returns the tangent of angle. @EXAMPLES tan(0) = 0 tan(1) = 1.55740772 @SEE atan, tanh */ |
|
From: Stefan M. <st_...@us...> - 2007-01-12 21:49:38
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1076/Source/MathLib/Tokens Modified Files: NumberToken.java Log Message: Index: NumberToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/NumberToken.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** NumberToken.java 9 Jan 2007 18:58:51 -0000 1.99 --- NumberToken.java 12 Jan 2007 21:49:35 -0000 1.100 *************** *** 701,704 **** --- 701,707 ---- public String toString(double _values[]) { + if (_values==null) + return "XXXXXX"; + double re = _values[REAL]; double im = _values[IMAG]; *************** *** 1497,2218 **** } - ///////////////////////////////////////Trigonometric functions///////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////////////////////// - /**trigonometric functions - calculate the sine of this token - @return the result as an OperandToken*/ - public OperandToken sin() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, sin(values[n]) ); - } - return result; - } - - /**Calculates the sine of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] sin(double[] arg) - { - double result[] = new double[2]; - double scalar; - double iz_re, iz_im; - double _re1, _im1; - double _re2, _im2; - - // iz: i.Times(z) ... - iz_re = -arg[IMAG]; - iz_im = arg[REAL]; - - // _1: iz.exp() ... - scalar = Math.exp(iz_re); - _re1 = scalar * Math.cos(iz_im); - _im1 = scalar * Math.sin(iz_im); - - // _2: iz.neg().exp() ... - scalar = Math.exp(-iz_re); - _re2 = scalar * Math.cos(-iz_im); - _im2 = scalar * Math.sin(-iz_im); - - // _1: _1.Minus(_2) ... - _re1 = _re1 - _re2; // !!! - _im1 = _im1 - _im2; // !!! - - // result: _1.Div(2*i) ... - result[REAL] = 0.5*_im1; - result[IMAG] = -0.5*_re1; - - return result; - } - - /**trigonometric functions - calculate the cosine of this token - @return the result as an OperandToken*/ - public OperandToken cos() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, cos(values[n]) ); - } - return result; - } - - /**Calculates the cosine of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] cos(double[] arg) - { - double result[] = new double[2]; - double scalar; - double iz_re, iz_im; - double _re1, _im1; - double _re2, _im2; - - // iz: i.Times(z) ... - iz_re = -arg[IMAG]; - iz_im = arg[REAL]; - - // _1: iz.exp() ... - scalar = Math.exp(iz_re); - _re1 = scalar * Math.cos(iz_im); - _im1 = scalar * Math.sin(iz_im); - - // _2: iz.neg().exp() ... - scalar = Math.exp(-iz_re); - _re2 = scalar * Math.cos(-iz_im); - _im2 = scalar * Math.sin(-iz_im); - - // _1: _1.Plus(_2) ... - _re1 = _re1 + _re2; // !!! - _im1 = _im1 + _im2; // !!! - - // result: _1.scale(0.5) ... - result[REAL] = 0.5*_re1; - result[IMAG] = -0.5*_im1; - - return result; - } - - /**trigonometric functions - calculate the tangent of this token - @return the result as an OperandToken*/ - public OperandToken tan() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, tan(values[n]) ); - } - return result; - } - - /**Calculates the tangent of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] tan(double[] arg) - { - double[] temp1 = new double[2]; - temp1[REAL] = arg[REAL]; - temp1[IMAG] = arg[IMAG]; - temp1 = sin(temp1); - double[] temp2 = cos(arg); - return divide(temp1, temp2); - } - - /**trigonometric functions - calculate the arc sine of this token - @return the result as an OperandToken*/ - public OperandToken asin() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, asin(values[n]) ); - } - return result; - } - - /**Calculates the arcsine of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] asin(double[] arg) - { - double result[] = new double[2]; - // asin(z) = -i * log(i*z + Sqrt(1 - z*z)) - double re = arg[REAL]; - double im = arg[IMAG]; - - // _1: one.Minus(z.Times(z)) ... - result[REAL] = 1.0 - ( (re*re) - (im*im) ); - result[IMAG] = 0.0 - ( (re*im) + (im*re) ); - - // result: _1.Sqrt() ... - result = sqrt(result); - - // _1: z.Times(i) ... - // result: _1.Plus(result) ... - result[REAL] = result[REAL] - im; - result[IMAG] = result[IMAG] + re; - - // _1: result.log() ... - result = log(result); - - double temp = result[IMAG]; - result[IMAG] = -result[REAL]; - result[REAL] = temp; - - return result; - } - - /**trigonometric functions - calculate the arc cosine of this token - @return the result as an OperandToken*/ - public OperandToken acos() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, acos(values[n]) ); - } - return result; - } - - /**Calculates the arccosine of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] acos(double[] arg) - { - double result[] = new double[2]; - double _re1, _im1; - - double re = arg[REAL]; - double im = arg[IMAG]; - - // _1: one - z^2 ... - result[REAL] = 1.0 - ( (re*re) - (im*im) ); - result[IMAG] = 0.0 - ( (re*im) + (im*re) ); - - // result: _1.Sqrt() ... - result = sqrt(result); - - // _1: i * result ... - _re1 = - result[IMAG]; - _im1 = + result[REAL]; - - // result: z +_1 ... - result[REAL] = re + _re1; - result[IMAG] = im + _im1; - - // _1: result.log() - result = log(result); - - // result: -i * _1 ... - double temp = result[IMAG]; - result[IMAG] = -result[REAL]; - result[REAL] = temp; - - return result; - } - - /**trigonometric functions - calculate the arc tangent of this token - @return the result as an OperandToken*/ - public OperandToken atan() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, atan(values[n]) ); - } - return result; - } - - /**Calculates the arctangent of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] atan(double[] arg) - { - double result[] = new double[2]; - double[] temp = new double[2]; - // atan(z) = -i/2 * log( (i-z)/(i+z) ) - - double _re1, _im1; - - // result: i.Minus(z) ... - temp[REAL] = -arg[REAL]; - temp[IMAG] = 1 - arg[IMAG]; - - // _1: i.Plus(z) ... - result[REAL] = arg[REAL]; - result[IMAG] = 1 + arg[IMAG]; - - // result: result.Div(_1) ... - result = divide(temp, result); - - // _1: result.log() ... - result = log(result); - - // result: half_i.neg().Times(_2) ... - double t = -0.5 * result[REAL]; - result[REAL] = 0.5 * result[IMAG]; - result[IMAG] = t; - return result; - } - - /**Trigonometric function - calculates the hyperbolic sine - @return the result as an OperandToken*/ - public OperandToken sinh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, sinh(values[n]) ); - } - return result; - } - - /**Calculates the hyperbolic sine of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] sinh(double[] arg) - { - double result[] = new double[2]; - double scalar; - double _re1, _im1; - double _re2, _im2; - - // _1: z.exp() ... - scalar = Math.exp(arg[REAL]); - _re1 = scalar * Math.cos(arg[IMAG]); - _im1 = scalar * Math.sin(arg[IMAG]); - - // _2: z.neg().exp() ... - scalar = Math.exp(-arg[REAL]); - _re2 = scalar * Math.cos(-arg[IMAG]); - _im2 = scalar * Math.sin(-arg[IMAG]); - - // _1: _1.Minus(_2) ... - _re1 = _re1 - _re2; // !!! - _im1 = _im1 - _im2; // !!! - - // result: _1.scale(0.5) ... - result[REAL] = 0.5 * _re1; - result[IMAG] = 0.5 * _im1; - - return result; - } - - /**Trigonometric function - calculates the hyperbolic cosine - @return the result as an OperandToken*/ - public OperandToken cosh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, cosh(values[n]) ); - } - return result; - } - - /**Calculates the hyperbolic cosine of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] cosh(double[] arg) - { - double result[] = new double[2]; - double scalar; - double _re1, _im1; - double _re2, _im2; - - // _1: z.exp() ... - scalar = Math.exp(arg[REAL]); - _re1 = scalar * Math.cos(arg[IMAG]); - _im1 = scalar * Math.sin(arg[IMAG]); - - // _2: z.neg().exp() ... - scalar = Math.exp(-arg[REAL]); - _re2 = scalar * Math.cos(-arg[IMAG]); - _im2 = scalar * Math.sin(-arg[IMAG]); - - // _1: _1.Plus(_2) ... - _re1 = _re1 + _re2; // !!! - _im1 = _im1 + _im2; // !!! - - // result: _1.scale(0.5) ... - result[REAL] = 0.5 * _re1; - result[IMAG] = 0.5 * _im1; - - return result; - } - - /**Trigonometric function - calculates the hyperbolic tan - @return the result as an OperandToken*/ - public OperandToken tanh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, tanh(values[n]) ); - } - return result; - } - - /**Calculates the hyperbolic tangent of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] tanh(double[] arg) - { - double[] temp1 = new double[2]; - temp1[REAL] = arg[REAL]; - temp1[IMAG] = arg[IMAG]; - - temp1 = sinh(temp1); - double[] temp2 = cosh(arg); - - return divide(temp1, temp2); - } - - /**Trigonometric function - calculates the inverse hyperbolic sine - @return the result as an OperandToken*/ - public OperandToken asinh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, asinh(values[n]) ); - } - return result; - } - - /**Calculates the inverse hyperbolic sine of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] asinh(double[] arg) - { - double result[] = new double[2]; - // asinh(z) = log(z + Sqrt(z*z + 1)) - double re = arg[REAL]; - double im = arg[IMAG]; - // _1: z.Times(z).Plus(one) ... - result[REAL] = ( (re*re) - (im*im) ) + 1.0; - result[IMAG] = ( (re*im) + (im*re) ); - - // result: _1.Sqrt() ... - result = sqrt(result); - - // result: z.Plus(result) ... - result[REAL] = re + result[REAL]; // ! - result[IMAG] = im + result[IMAG]; // ! - - // _1: result.log() ... - result = log(result); - - return result; - } - - /**Trigonometric function - calculates the inverse hyperbolic cosine - @return the result as an OperandToken*/ - public OperandToken acosh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, acosh(values[n]) ); - } - return result; - } - - /**Calculates the inverse hyperbolic cosine of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] acosh(double[] arg) - { - double result[] = new double[2]; - // acosh(z) = log(z + Sqrt(z*z - 1)) - double re = arg[REAL]; - double im = arg[IMAG]; - - // _1: z.Times(z).Minus(one) ... - result[REAL] = ( (re*re) - (im*im) ) - 1.0; - result[IMAG] = ( (re*im) + (im*re) ) - 0.0; - - // result: _1.Sqrt() ... - result = sqrt(result); - - // result: z.Plus(result) ... - result[REAL] = re + result[REAL]; // ! - result[IMAG] = im + result[IMAG]; // ! - - // _1: result.log() ... - result = log(result); - - // result: _1 ... - return result; - } - - /**Trigonometric function - calculates the inverse hyperbolic tangent - @return the result as an OperandToken*/ - public OperandToken atanh() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, atanh(values[n]) ); - } - return result; - } - - /**Calculates the inverse hyperbolic tangent of a complex number - @param arg = the angle as an array of double - @return the result as an array of double*/ - public double[] atanh(double[] arg) - { - double result[] = new double[2]; - // atanh(z) = 1/2 * log( (1+z)/(1-z) ) - - // _1: one.Minus(z) ... - double[] temp = new double[2]; - temp[REAL] = 1 - arg[REAL]; - temp[IMAG] = - arg[IMAG]; - - // result: one.Plus(z) ... - result[REAL] = 1 + arg[REAL]; - - // result: result.Div(_1) ... - result = divide(result, temp); - - // _1: result.log() ... - result = log(result); - - // result: _1.scale(0.5) ... - result[REAL] = 0.5 * result[REAL]; - result[IMAG] = 0.5 * result[IMAG]; - return result; - } - - ///////////////////////////////////////Exponential Functions//////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////// - /**Standard functions - calculates the exponent - @return the result as an OperandToken*/ - public OperandToken exp() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, exp(values[n]) ); - } - return result; - } - - /**Calculates the exponent of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] exp(double[] arg) - { - double[] result = new double[2]; - double scalar = Math.exp(arg[REAL]); // e^ix = cis x - result[REAL] = scalar * Math.cos(arg[IMAG]); - result[IMAG] = scalar * Math.sin(arg[IMAG]); - return result; - } - - /**Standard functions - calculates the natural logarythm - @return the result as an OperandToken*/ - public OperandToken ln() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, log(values[n]) ); - } - return result; - } - - /**Standard functions - calculates the logarythm - @return the result as an OperandToken*/ - public OperandToken log() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, log(values[n]) ); - } - return result; - } - - /**Calculates the logarythm of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] log(double[] arg) - { - double[] result = new double[2]; - - double temp = Math.pow(arg[REAL], 2) + Math.pow(arg[IMAG], 2); - temp = Math.sqrt(temp); - - result[REAL] = Math.log(temp); - result[IMAG] = Math.atan2(arg[IMAG], arg[REAL]); - return result; - } - - /**Standard functions - calculates the square root - @return the result as an OperandToken*/ - public OperandToken sqrt() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValueComplex(n, sqrt(values[n]) ); - } - return result; - } - - /**Calculates the sqrt of a complex number - @param arg = the value as an array of double - @return the result as an array of double*/ - public double[] sqrt(double[] arg) - { - // with thanks to Jim Shapiro <jn...@ar...> - // adapted from "Numerical Recipies in C" (ISBN 0-521-43108-5) - // by William H. Press et al - - double[] result = new double[2]; - double re = arg[REAL]; - double im = arg[IMAG]; - - double temp = Math.pow(re, 2) + Math.pow(im, 2); - double mag = Math.sqrt(temp); - - if (mag > 0.0) - { - if (re > 0.0) - { - temp = Math.sqrt(0.5 * (mag + re)); - - re = temp; - im = 0.5 * im / temp; - } - else - { - temp = Math.sqrt(0.5 * (mag - re)); - - if (im < 0.0) - { - temp = -temp; - } - - re = 0.5 * im / temp; - im = temp; - } - } - else - { - re = 0.0; - im = 0.0; - } - result[REAL] = re; - result[IMAG] = im; - - return result; - } ///////////////////////////////////////Standard Math Functions/////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// - /**Standard functions - absolute value - @return the result as an OperandToken*/ - public OperandToken abs() - { - double[][][] results = new double[sizeY][sizeX][2]; - if (isReal()) - { - // real numbers only - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValue(n, Math.abs(getValueRe(n)), 0 ); - } - return result; - } - else - { - // complex absolute value - double real = 0; - double imag = 0; - for (int yy=0; yy<sizeY; yy++) - { - for (int xx=0; xx<sizeX; xx++) - { - int n = yx2n(yy,xx); - real = values[n][REAL]; - imag = values[n][IMAG]; - results[yy][xx][REAL] = Math.sqrt( real*real + imag*imag ); - results[yy][xx][IMAG] = 0; - } - } - } - - return new NumberToken(results); - } - - /**Standard functions - rounds the value down - @return the result as an OperandToken*/ - public OperandToken floor() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValue(n, - Math.floor(getValueRe(n)) , - Math.floor(getValueIm(n)) ); - } - return result; - } - - /**Standard functions - rounds the value up - @return the result as an OperandToken*/ - public OperandToken ceil() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValue(n, - Math.ceil(getValueRe(n)) , - Math.ceil(getValueIm(n)) ); - } - return result; - } - - /**Standard functions - rounds the value to the nearest integer - @return the result as an OperandToken*/ - public OperandToken round() - { - NumberToken result = new NumberToken(sizeA, null, null); - - for(int n = 0; n < noElem; n++) - { - result.setValue(n, - Math.rint(getValueRe(n)) , - Math.rint(getValueIm(n)) ); - } - return result; - } - /**standard function - returns the negative of the number*/ public OperandToken negate() --- 1500,1507 ---- *************** *** 2227,2251 **** } - /**Standard functions - calculates the minimum of two values - @return the result as an OperandToken*/ - public OperandToken min(RootObject arg) - { - // !!! see matlab documentation for correct implementation - - double arg2 = ((NumberToken)arg).getValueRe(0); - double result = java.lang.Math.min(values[0][REAL], arg2); - return new NumberToken(result); - } - - /**Standard functions - calculates the maximum of two values - @return the result as an OperandToken*/ - public OperandToken max(RootObject arg) - { - // !!! see matlab documentation for correct implementation - - double arg2 = ((NumberToken)arg).getValueRe(0); - double result = Math.max(values[0][REAL], arg2); - return new NumberToken(result); - } /**Standard functions - calculates the factorial of the number --- 1516,1519 ---- |