mathlib-commitlog Mailing List for JMathLib - Octave, Matlab clone in java (Page 47)
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-06 09:34:47
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Time In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13148/Source/MathLib/Functions/Time Modified Files: toc.java Log Message: getValue() replaced by getValueRe() Index: toc.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Time/toc.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** toc.java 30 Dec 2006 17:58:20 -0000 1.6 --- toc.java 6 Jan 2007 09:34:45 -0000 1.7 *************** *** 33,37 **** if (ticTok instanceof NumberToken) { ! double start = ((NumberToken)ticTok).getValue(); return new NumberToken( (stop - start)/1000 ); } --- 33,37 ---- if (ticTok instanceof NumberToken) { ! double start = ((NumberToken)ticTok).getValueRe(); return new NumberToken( (stop - start)/1000 ); } |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:34:34
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/String In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13134/Source/MathLib/Functions/String Modified Files: SubString.java Blanks.java Log Message: getValue() replaced by getValueRe() Index: Blanks.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/String/Blanks.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Blanks.java 30 Dec 2006 18:04:42 -0000 1.6 --- Blanks.java 6 Jan 2007 09:34:32 -0000 1.7 *************** *** 18,22 **** if(operands[0] instanceof NumberToken) { ! int length = (new Double(((NumberToken)operands[0]).getValue())).intValue(); StringBuffer buffer = new StringBuffer(length); --- 18,22 ---- if(operands[0] instanceof NumberToken) { ! int length = (new Double(((NumberToken)operands[0]).getValueRe())).intValue(); StringBuffer buffer = new StringBuffer(length); Index: SubString.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/String/SubString.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SubString.java 19 Nov 2006 16:15:52 -0000 1.5 --- SubString.java 6 Jan 2007 09:34:32 -0000 1.6 *************** *** 25,35 **** if(operands.length < 3 || operands[2] == null) { ! int pos = ((int)((NumberToken)operands[1]).getValue()); substring = argString.substring(pos); } else { ! int pos = ((int)((NumberToken)operands[1]).getValue()); ! int pos2 = ((int)((NumberToken)operands[2]).getValue()); substring = argString.substring(pos, pos2); } --- 25,35 ---- if(operands.length < 3 || operands[2] == null) { ! int pos = ((int)((NumberToken)operands[1]).getValueRe()); substring = argString.substring(pos); } else { ! int pos = ((int)((NumberToken)operands[1]).getValueRe()); ! int pos2 = ((int)((NumberToken)operands[2]).getValueRe()); substring = argString.substring(pos, pos2); } |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:34:01
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Polynomial In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12750/Source/MathLib/Functions/Polynomial Modified Files: Binomial.java Log Message: getValue() replaced by getValueRe() Index: Binomial.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Polynomial/Binomial.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Binomial.java 30 Dec 2006 18:05:04 -0000 1.5 --- Binomial.java 6 Jan 2007 09:33:58 -0000 1.6 *************** *** 19,23 **** if(operands.length >= 1 && operands[0] instanceof NumberToken) { ! double val = ((NumberToken)operands[0]).getValue(); int order = (new Double(val)).intValue(); --- 19,23 ---- if(operands.length >= 1 && operands[0] instanceof NumberToken) { ! double val = ((NumberToken)operands[0]).getValueRe(); int order = (new Double(val)).intValue(); *************** *** 48,52 **** temp2 = temp2.divide(temp); ! results[0][count] = ((NumberToken)temp2).getValue(); } result = new NumberToken(results); --- 48,52 ---- temp2 = temp2.divide(temp); ! results[0][count] = ((NumberToken)temp2).getValueRe(); } result = new NumberToken(results); |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:33:29
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/IO In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12716/Source/MathLib/Functions/IO Modified Files: CSVRead.java Log Message: getValue() replaced by getValueRe() Index: CSVRead.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/IO/CSVRead.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CSVRead.java 30 Dec 2006 17:47:25 -0000 1.9 --- CSVRead.java 6 Jan 2007 09:33:26 -0000 1.10 *************** *** 147,151 **** if(temp != null) { ! val = ((NumberToken)temp).getValue(); values[xx] = val; ErrorLogger.debugLine("4"); --- 147,151 ---- if(temp != null) { ! val = ((NumberToken)temp).getValueRe(); values[xx] = val; ErrorLogger.debugLine("4"); |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:33:12
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12663/Source/MathLib/Functions/General Modified Files: Fibonacci.java Primes.java Harmonic.java setPFileCaching.java Factor.java Log Message: getValue() replaced by getValueRe() Index: Primes.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General/Primes.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Primes.java 4 Jul 2004 19:10:46 -0000 1.7 --- Primes.java 6 Jan 2007 09:33:09 -0000 1.8 *************** *** 23,27 **** if(operands[0] instanceof NumberToken) { ! double maxValue = ((NumberToken)operands[0]).getValue(); if(maxValue < 2) --- 23,27 ---- if(operands[0] instanceof NumberToken) { ! double maxValue = ((NumberToken)operands[0]).getValueRe(); if(maxValue < 2) Index: Harmonic.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General/Harmonic.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Harmonic.java 30 Dec 2006 18:06:26 -0000 1.6 --- Harmonic.java 6 Jan 2007 09:33:09 -0000 1.7 *************** *** 19,23 **** { //harmonic(n) = 1 + 1/2 + 1/3 + ... + 1/n ! double index = ((NumberToken)operands[0]).getValue(); double total = 0; --- 19,23 ---- { //harmonic(n) = 1 + 1/2 + 1/3 + ... + 1/n ! double index = ((NumberToken)operands[0]).getValueRe(); double total = 0; Index: setPFileCaching.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General/setPFileCaching.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** setPFileCaching.java 30 Dec 2006 17:39:59 -0000 1.5 --- setPFileCaching.java 6 Jan 2007 09:33:09 -0000 1.6 *************** *** 21,25 **** if (operands[0] instanceof NumberToken) { ! if ( ((NumberToken)operands[0]).getValue()==0) getFunctionManager().getMFileLoader().setPFileCaching(false); else --- 21,25 ---- if (operands[0] instanceof NumberToken) { ! if ( ((NumberToken)operands[0]).getValueRe()==0) getFunctionManager().getMFileLoader().setPFileCaching(false); else Index: Factor.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General/Factor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Factor.java 30 Dec 2006 18:06:26 -0000 1.8 --- Factor.java 6 Jan 2007 09:33:09 -0000 1.9 *************** *** 22,26 **** throwMathLibException("factor: first argument must be a number"); ! double maxValue = ((NumberToken)operands[0]).getValue(); int temp = (new Double(maxValue/2)).intValue(); --- 22,26 ---- throwMathLibException("factor: first argument must be a number"); ! double maxValue = ((NumberToken)operands[0]).getValueRe(); int temp = (new Double(maxValue/2)).intValue(); Index: Fibonacci.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General/Fibonacci.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Fibonacci.java 30 Dec 2006 18:06:26 -0000 1.7 --- Fibonacci.java 6 Jan 2007 09:33:09 -0000 1.8 *************** *** 22,26 **** //harmonic(n) = 1 + 1/2 + 1/3 + ... + 1/n ! double index = ((NumberToken)operands[0]).getValue(); double total1 = 0; --- 22,26 ---- //harmonic(n) = 1 + 1/2 + 1/3 + ... + 1/n ! double index = ((NumberToken)operands[0]).getValueRe(); double total1 = 0; |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:32:39
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/FunFun In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12297/Source/MathLib/Functions/FunFun Modified Files: euler.java Log Message: getValue() replaced by getValueRe() Index: euler.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/FunFun/euler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** euler.java 26 Dec 2006 12:22:45 -0000 1.5 --- euler.java 6 Jan 2007 09:32:36 -0000 1.6 *************** *** 55,59 **** // get step size ! double dt = ((NumberToken)operands[3]).getValue(); // calculate number of integration steps --- 55,59 ---- // get step size ! double dt = ((NumberToken)operands[3]).getValueRe(); // calculate number of integration steps |
|
From: Stefan M. <st_...@us...> - 2007-01-06 09:32:19
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12240/Source/MathLib/Functions/Matrix Modified Files: InverseMatrix.java magic.java ElementAt.java Sum.java Adjoint.java find.java Log Message: getValue() replaced by getValueRe() Index: magic.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/magic.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** magic.java 22 May 2004 07:17:50 -0000 1.2 --- magic.java 6 Jan 2007 09:32:14 -0000 1.3 *************** *** 21,25 **** // dimension of matrix ! int n = (int)((NumberToken)operands[0]).getValue(); double[][] M = magic_calculation(n); --- 21,25 ---- // dimension of matrix ! int n = (int)((NumberToken)operands[0]).getValueRe(); double[][] M = magic_calculation(n); Index: Adjoint.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/Adjoint.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Adjoint.java 30 Dec 2006 18:07:11 -0000 1.11 --- Adjoint.java 6 Jan 2007 09:32:14 -0000 1.12 *************** *** 68,72 **** ! double minor = ((NumberToken)function.evaluate(operands)).getValue(); int modifier = -1; --- 68,72 ---- ! double minor = ((NumberToken)function.evaluate(operands)).getValueRe(); int modifier = -1; Index: Sum.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/Sum.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Sum.java 11 Dec 2006 19:46:13 -0000 1.11 --- Sum.java 6 Jan 2007 09:32:14 -0000 1.12 *************** *** 40,44 **** // get dimension to sum ! dim = (int)((NumberToken)operands[1]).getValue(); } --- 40,44 ---- // get dimension to sum ! dim = (int)((NumberToken)operands[1]).getValueRe(); } Index: InverseMatrix.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/InverseMatrix.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** InverseMatrix.java 26 Dec 2006 12:24:16 -0000 1.10 --- InverseMatrix.java 6 Jan 2007 09:32:14 -0000 1.11 *************** *** 51,55 **** {} ! double matrixDeterminant = ((NumberToken)determinant.evaluate(operands)).getValue(); if(matrixDeterminant != 0) --- 51,55 ---- {} ! double matrixDeterminant = ((NumberToken)determinant.evaluate(operands)).getValueRe(); if(matrixDeterminant != 0) Index: ElementAt.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/ElementAt.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ElementAt.java 26 Dec 2006 12:24:17 -0000 1.8 --- ElementAt.java 6 Jan 2007 09:32:14 -0000 1.9 *************** *** 22,27 **** throwMathLibException("ElementAt: number of arguments != 3"); ! int rowNo = ((int)((NumberToken)operands[1]).getValue()); ! int colNo = ((int)((NumberToken)operands[2]).getValue()); if(operands[0] instanceof NumberToken) --- 22,27 ---- throwMathLibException("ElementAt: number of arguments != 3"); ! int rowNo = ((int)((NumberToken)operands[1]).getValueRe()); ! int colNo = ((int)((NumberToken)operands[2]).getValueRe()); if(operands[0] instanceof NumberToken) Index: find.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/find.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** find.java 26 Dec 2006 12:24:18 -0000 1.8 --- find.java 6 Jan 2007 09:32:14 -0000 1.9 *************** *** 47,51 **** throwMathLibException("find: second argument must be a number"); ! n = (int)((NumberToken)operands[1]).getValue(); } debugLine("find "+n); --- 47,51 ---- throwMathLibException("find: second argument must be a number"); ! n = (int)((NumberToken)operands[1]).getValueRe(); } debugLine("find "+n); |
|
From: Stefan M. <st_...@us...> - 2007-01-05 17:22:23
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4708 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** ChangeLog.txt 5 Jan 2007 14:29:50 -0000 1.139 --- ChangeLog.txt 5 Jan 2007 17:22:15 -0000 1.140 *************** *** 15,22 **** ge.m, gray2ind.m, gray.m, gt.m, hankel.m, inf.java, inv.m, isdefinite.m, isdirectory.java, isfile.java, isfinite.java, ishidden.java, isnan.java, ! isinf.java, issymmetric.m, lastmodified.java, le.m, lookup.m, mkdir.java, nan.java, ne.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, pmt.m, polyval.m, polyreduce.m, poly.m, pv.m, pvl.m, qtransvmat.m, rehash.java, ! repmat.java, rmdir.java, roots.m, size_equal.m, sort.java, stril.m, sylvester_matrix.m, toeplitz.m, triangle_lw.m, triangle_sw.m, triu.m, vech.m, wilkinson.m, --- 15,24 ---- ge.m, gray2ind.m, gray.m, gt.m, hankel.m, inf.java, inv.m, isdefinite.m, isdirectory.java, isfile.java, isfinite.java, ishidden.java, isnan.java, ! isinf.java, issymmetric.m, lastmodified.java, le.m, ! loadvariables.java, lookup.m, mkdir.java, nan.java, ne.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, pmt.m, polyval.m, polyreduce.m, poly.m, pv.m, pvl.m, qtransvmat.m, rehash.java, ! repmat.java, rmdir.java, roots.m, save_variables.java, size_equal.m, sort.java, ! stril.m, sylvester_matrix.m, toeplitz.m, triangle_lw.m, triangle_sw.m, triu.m, vech.m, wilkinson.m, *************** *** 30,33 **** --- 32,41 ---- stefan * + 2007/01/05 + stefan + MathLib/Functions/IO/loadvariables.java + stefan + MathLib/Functions/IO/savevariables.java Moved loading and saving of + variable into two external functions. Variables are not loaded/saved + automotically at the start/end of JMathLib any more. + 2007/01/05 stefan * MathLib/Functions/UserFunction.java added handling of "varargin" |
|
From: Stefan M. <st_...@us...> - 2007-01-05 17:18:23
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3046/Source/MathLib/Interpreter Modified Files: Interpreter.java VariableList.java Log Message: moved loading and saving of variable into to external functions. Variables are not loaded/saved automotically at the start of JMathLib any more. Index: Interpreter.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter/Interpreter.java,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** Interpreter.java 2 Jan 2007 16:21:07 -0000 1.64 --- Interpreter.java 5 Jan 2007 17:18:19 -0000 1.65 *************** *** 53,58 **** if(runningStandalone) { ! getVariables().loadVariables("." + File.separator + "variables.mlf"); ! String classPath=System.getProperty("java.class.path"); boolean end = false; --- 53,57 ---- if(runningStandalone) { ! String classPath=System.getProperty("java.class.path"); boolean end = false; *************** *** 145,151 **** executeExpression("finish"); - ErrorLogger.debugLine("Interpreter: saving variables"); - getVariables().saveVariables("." + File.separator + "variables.mlf"); - // store current properties to file prefs.storeLocalPropertiesToFile(); --- 144,147 ---- Index: VariableList.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter/VariableList.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** VariableList.java 3 Aug 2006 20:25:51 -0000 1.18 --- VariableList.java 5 Jan 2007 17:18:19 -0000 1.19 *************** *** 137,141 **** catch(java.io.IOException except) { ! ErrorLogger.debugLine("IO exception"); ErrorLogger.debugLine(except.getMessage()); //except.printStackTrace(); --- 137,141 ---- catch(java.io.IOException except) { ! Errors.throwMathLibException("VariableList: IO exception"); ErrorLogger.debugLine(except.getMessage()); //except.printStackTrace(); *************** *** 159,163 **** catch(java.lang.ClassNotFoundException except) { ! ErrorLogger.debugLine("Class not found exception"); //close input objects --- 159,163 ---- catch(java.lang.ClassNotFoundException except) { ! Errors.throwMathLibException("VariableList: Class not found exception"); //close input objects *************** *** 167,171 **** catch(java.lang.ClassCastException except) { ! ErrorLogger.debugLine("Class cast exception"); //close input objects --- 167,171 ---- catch(java.lang.ClassCastException except) { ! Errors.throwMathLibException("VariableList: Class cast exception"); //close input objects *************** *** 180,184 **** catch(java.io.IOException except) { ! ErrorLogger.debugLine("IO exception"); ErrorLogger.debugLine(except.getMessage()); } --- 180,184 ---- catch(java.io.IOException except) { ! Errors.throwMathLibException("VariableList: IO exception"); ErrorLogger.debugLine(except.getMessage()); } |
|
From: Stefan M. <st_...@us...> - 2007-01-05 17:18:22
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/IO In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3046/Source/MathLib/Functions/IO Added Files: savevariables.java loadvariables.java Log Message: moved loading and saving of variable into to external functions. Variables are not loaded/saved automotically at the start of JMathLib any more. --- NEW FILE: loadvariables.java --- package MathLib.Functions.IO; import MathLib.Tokens.*; import MathLib.Functions.ExternalFunction; import java.io.*; public class loadvariables extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) > 1) throwMathLibException("loadvariables: number of arguments > 1"); String file = "." + File.separator + "variables.mlf"; if (getNArgIn(operands) == 1) { if (!(operands[0] instanceof CharToken)) throwMathLibException("loadvariables: argument must be a string"); file = ((CharToken)operands[0]).toString(); } getVariables().loadVariables(file); return null; } // end eval } /* @GROUP IO @SYNTAX loadvariables() loadvariables("name.mlf") @DOC loads the variables from a serialized .mlf-file @EXAMPLES <programlisting> loadvariables() </programlisting> @NOTES The variables are written as a serialized stream of java objects. Therefor the format of the .mlf-file is java-specific. The file is also specific to the versions of MathLib token and classes. @SEE savevariables */ --- NEW FILE: savevariables.java --- package MathLib.Functions.IO; import MathLib.Tokens.*; import MathLib.Functions.ExternalFunction; import java.io.*; public class savevariables extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) > 1) throwMathLibException("savevariables: number of arguments > 1"); String file = "." + File.separator + "variables.mlf"; if (getNArgIn(operands) == 1) { if (!(operands[0] instanceof CharToken)) throwMathLibException("savevariables: argument must be a string"); file = ((CharToken)operands[0]).toString(); } getVariables().saveVariables(file); return null; } // end eval } /* @GROUP IO @SYNTAX savevariables() savevariables("name.mlf") @DOC saves the variables from the current workspace into a serialized .mlf-file @EXAMPLES <programlisting> savevariables() </programlisting> @NOTES The variables are written as a serialized stream of java objects. Therefor the format of the .mlf-file is java-specific. The file is also specific to the versions of MathLib token and classes. @SEE loadvariables */ |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:29:55
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24933 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** ChangeLog.txt 5 Jan 2007 09:26:45 -0000 1.138 --- ChangeLog.txt 5 Jan 2007 14:29:50 -0000 1.139 *************** *** 31,34 **** --- 31,39 ---- 2007/01/05 + stefan * MathLib/Functions/UserFunction.java added handling of "varargin" + stefan * MathLib/Tools/Testsuite/Functions/Matrix/* added lots of tests + stefan * MathLib/Tools/Testsuite/Functions/Matrix/* added lots of tests + + 2007/01/05 stefan + Functions/specfun/_private/ContinuedFraction.java stefan + Functions/specfun/_private/ConvergenceException.java |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:29:25
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24875/Source/MathLib/Functions Modified Files: UserFunction.java Log Message: added support for "varargin" Index: UserFunction.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/UserFunction.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** UserFunction.java 31 Aug 2006 08:41:16 -0000 1.35 --- UserFunction.java 5 Jan 2007 14:29:21 -0000 1.36 *************** *** 38,42 **** { Context functionContext; // The context of the function ! OperandToken result = null; if (mScriptB) --- 38,44 ---- { Context functionContext; // The context of the function ! OperandToken result = null; ! boolean vararginB = false; ! boolean varargoutB = false; if (mScriptB) *************** *** 50,53 **** --- 52,56 ---- // evaluate m-function + // m-functions have a local context (local variables) VariableList localVariables = new VariableList(); functionContext = getContextList().createContext(localVariables); *************** *** 59,71 **** //getContextList().pushContext(activeContext); - //create a local variable to store the no of arguments - //getVariables().createVariable("NARGIN"); - - //create a local variable to store the no of return values expected - //getVariables().createVariable("NARGOUT"); - - //set the functions parameters - //setFunctionParameters(operands); - //set the variable NARGIN to the number of arguments int opLength = 0; --- 62,65 ---- *************** *** 73,86 **** opLength = operands.length; // check if number of parameters inside the function is equal to the number // of calling expression // e.g. plot(x,y,z) // function [...]=plot(x,y,z) ! if (parameterVariables.size() < opLength) Errors.throwMathLibException("UserFunction: "+name+" number of parameters to large"); - // set the variable NARGIN to the number of parameter values - //getVariables().createVariable("NARGIN").assign(new NumberToken(parameterVariables.size())); - // set the variable NARGIN to the number of parameters of the calling function getVariables().createVariable("nargin").assign(new NumberToken(opLength)); --- 67,99 ---- opLength = operands.length; + // check for "varargin" as last input parameter + // e.g. function x=barfoo(a,b,c,varargin) + if (parameterVariables.size()>0) + { + if ( ((String)parameterVariables.get(parameterVariables.size()-1)).equals("varargin") ) + { + vararginB = true; + ErrorLogger.debugLine("UserF: varargin found"); + } + } + + // check for "varargout" as last input parameter + // e.g. function [x,y,varargout]=barfoo(a,b,c) + if (returnVariables.size()>0) + { + if ( ((String)returnVariables.get(returnVariables.size()-1)).equals("varargout") ) + { + varargoutB = true; + ErrorLogger.debugLine("UserF: varargout found"); + } + } + // check if number of parameters inside the function is equal to the number // of calling expression // e.g. plot(x,y,z) // function [...]=plot(x,y,z) ! if ( (parameterVariables.size() < opLength) && !vararginB ) Errors.throwMathLibException("UserFunction: "+name+" number of parameters to large"); // set the variable NARGIN to the number of parameters of the calling function getVariables().createVariable("nargin").assign(new NumberToken(opLength)); *************** *** 89,110 **** getVariables().createVariable("nargout").assign(new NumberToken(returnVariables.size())); - //getContextList().setContextDetails(name); ! // e.g. createVariable("x").assign(operands[1]) ! // e.g. createVariable("x").assign(operands[1]) ! //set the parameters for the function ! for(int paramNo = 0; paramNo < opLength; paramNo++) ! { ! String parameterName = (String)parameterVariables.get(paramNo); ! //System.out.println("UserFunction: "+parameterName); ! getVariables().createVariable(parameterName).assign((OperandToken)operands[paramNo]); ! } ! try { - //executeCurrentContext(); - //result = getFunctionResult(); - // must clone function code, so that the original code remains untouched OperandToken codeLocal = (OperandToken)code.clone(); --- 102,155 ---- getVariables().createVariable("nargout").assign(new NumberToken(returnVariables.size())); ! //set the input parameters for the function ! // e.g. function x=barfoo(x,y,z) ! // e.g. function x=barfoo(x,y,z,varargin) ! if (!vararginB) ! { ! // e.g. function =bar(a,b,c,d,e) ! for(int paramNo = 0; paramNo < opLength; paramNo++) ! { ! String parameterName = (String)parameterVariables.get(paramNo); ! //System.out.println("UserFunction: "+parameterName); ! getVariables().createVariable(parameterName).assign((OperandToken)operands[paramNo]); ! } ! } ! else ! { ! //e.g. function =bar(a,b,c,varargin) ! int parN = parameterVariables.size(); ! int remainingOps = opLength - (parN - 1); ! ! // copy parameters, but not "varargin" (copy parameters 0 ... n-1) ! for(int paramNo = 0; paramNo < Math.min((parN - 1), opLength); paramNo++) ! { ! String parameterName = (String)parameterVariables.get(paramNo); ! ErrorLogger.debugLine("UserF: params: "+parameterName); ! getVariables().createVariable(parameterName).assign((OperandToken)operands[paramNo]); ! } ! ! ErrorLogger.debugLine("UserF: remainingOps: "+ remainingOps); ! ! ! // copy remaining operands into cell array, but only if operands are left ! // e.g. function x=barfoo(a,b,c,d,varargin) ! // with barfoo(1,2,3) will have varargin==null; ! if (remainingOps >0) ! { ! OperandToken[][] values = new OperandToken[remainingOps][1]; ! for (int i=0; i<remainingOps; i++) ! { ! values[i][0] = (OperandToken)operands[parameterVariables.size()-1+i]; ! } ! CellArrayToken cell = new CellArrayToken(values); ! getVariables().createVariable("varargin").assign(cell); ! } ! } ! + // execute m-function try { // must clone function code, so that the original code remains untouched OperandToken codeLocal = (OperandToken)code.clone(); *************** *** 114,118 **** // result should be NumberToken e.g. 1+2 -> >3< // or a MatrixToken e.g. [x,y]=foo(2,4) -> [x,y] - if(returnVariables.size() == 1) { --- 159,162 ---- *************** *** 146,166 **** //reset to the previous variable frame getContextList().popContext(); - //activeContext = null; } catch(ControlException e) { - result = e.getResults(); - if(e.getType() == ControlException.Yield) - { - // assign return values - //activeContext = getContextList().popContext(); - } - else - { // assign return values getContextList().popContext(); //activeContext = null; - } } } --- 190,205 ---- //reset to the previous variable frame getContextList().popContext(); } catch(ControlException e) { // assign return values getContextList().popContext(); //activeContext = null; } + catch (Exception e) + { + getContextList().popContext(); + throwMathLibException(e.getMessage()); + } } |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:27:19
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23931/Source/MathLib/Tools/TestSuite/Functions/Matrix Added Files: testGe.java testLt.java testGt.java testLe.java Log Message: --- NEW FILE: testLt.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testLt extends TestCase { protected Interpreter ml; public testLt(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testLt.class); } /*****************************************************************/ public void testLt01() { ml.executeExpression("a=lt(5,5);"); assertTrue(0 == ml.getScalarValueRe("a")); } public void testLt02() { ml.executeExpression("b=lt(5,6)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testLt03() { ml.executeExpression("b=lt(6,5)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testLt04() { ml.executeExpression("b=lt(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testLt05() { double[][] c = {{0.0, 1.0},{0.0, 1.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = lt(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testLe.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testLe extends TestCase { protected Interpreter ml; public testLe(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testLe.class); } /*****************************************************************/ public void testLe01() { ml.executeExpression("a=le(5,5);"); assertTrue(1 == ml.getScalarValueRe("a")); } public void testLe02() { ml.executeExpression("b=le(5,6)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testLe03() { ml.executeExpression("b=le(6,5)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testLe04() { ml.executeExpression("b=le(0,0)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testLe05() { double[][] c = {{0.0, 1.0},{1.0, 1.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = le(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testGt.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testGt extends TestCase { protected Interpreter ml; public testGt(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testGt.class); } /*****************************************************************/ public void testGt01() { ml.executeExpression("a=gt(5,5);"); assertTrue(0 == ml.getScalarValueRe("a")); } public void testGt02() { ml.executeExpression("b=gt(5,6)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testGt03() { ml.executeExpression("b=gt(6,5)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testGt04() { ml.executeExpression("b=gt(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testGt05() { double[][] c = {{1.0, 0.0},{0.0, 0.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = gt(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testGe.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testGe extends TestCase { protected Interpreter ml; public testGe(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testGe.class); } /*****************************************************************/ public void testGe01() { ml.executeExpression("a=ge(5,5);"); assertTrue(1 == ml.getScalarValueRe("a")); } public void testGe02() { ml.executeExpression("b=ge(5,6)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testGe03() { ml.executeExpression("b=ge(6,5)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testGe04() { ml.executeExpression("b=eq(0,0)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testGe05() { double[][] c = {{1.0, 0.0},{1.0, 0.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = ge(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:27:06
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23544/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: AllTests.java Added Files: testEq.java testMinus.java Log Message: --- NEW FILE: testEq.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testEq extends TestCase { protected Interpreter ml; public testEq(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testEq.class); } /*****************************************************************/ public void testEq01() { ml.executeExpression("a=eq(5,5);"); assertTrue(1 == ml.getScalarValueRe("a")); } public void testEq02() { ml.executeExpression("b=eq(5,6)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testEq03() { ml.executeExpression("b=eq(6,5)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testEq04() { ml.executeExpression("b=eq(0,0)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testEq05() { double[][] c = {{0.0, 0.0},{1.0, 0.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = eq(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testMinus.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testMinus extends TestCase { protected Interpreter ml; public testMinus(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testMinus.class); } /*****************************************************************/ public void testMinus01() { ml.executeExpression("a=minus(5,5);"); assertTrue(0 == ml.getScalarValueRe("a")); } public void testMinus02() { ml.executeExpression("b=minus(5,6)"); assertTrue(-1 == ml.getScalarValueRe("b")); } public void testMinus03() { ml.executeExpression("b=minus(6,5)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testMinus04() { ml.executeExpression("b=minus(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testMinus05() { double[][] c = {{1.0, -4.0},{0.0, -4.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = minus(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/AllTests.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AllTests.java 5 Jan 2007 13:31:43 -0000 1.14 --- AllTests.java 5 Jan 2007 14:27:02 -0000 1.15 *************** *** 29,45 **** --- 29,59 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testDet.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testDiag.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testEq.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestEye.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestFliplr.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestFlipud.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testGe.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testGt.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testLe.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testLt.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMax.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMin.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMinus.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMldivide.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMrdivide.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testMtimes.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testNe.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testNot.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testNumel.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testOnes.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestOr.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testPlus.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testRows.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testSort.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestSubAssign.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestSubMatrix.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testTimes.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testUminus.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testUplus.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestXor.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testZeros.suite()); |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:26:50
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23506/Source/MathLib/Tools/TestSuite/Functions/Matrix Added Files: testMtimes.java testMldivide.java testPlus.java testMrdivide.java testNe.java Log Message: --- NEW FILE: testMtimes.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testMtimes extends TestCase { protected Interpreter ml; public testMtimes(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testMtimes.class); } /*****************************************************************/ public void testMtimes01() { ml.executeExpression("a=mtimes(5,5);"); assertTrue(25 == ml.getScalarValueRe("a")); } public void testMtimes02() { ml.executeExpression("b=mtimes(5,6)"); assertTrue(30 == ml.getScalarValueRe("b")); } public void testMtimes03() { ml.executeExpression("b=mtimes(6,5)"); assertTrue(30 == ml.getScalarValueRe("b")); } public void testMtimes04() { ml.executeExpression("b=mtimes(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testMtimes05() { double[][] c = {{6.0, 28.0},{6.0, 35.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = mtimes(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } public void testMtimes06() { ml.executeExpression("b=mtimes([2,3],[3;4])"); assertTrue(18 == ml.getScalarValueRe("b")); } } --- NEW FILE: testMldivide.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testMldivide extends TestCase { protected Interpreter ml; public testMldivide(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testMldivide.class); } /*****************************************************************/ public void testMldivide01() { ml.executeExpression("a=mldivide(5,5);"); assertTrue(1 == ml.getScalarValueRe("a")); } public void testMldivide02() { ml.executeExpression("b=mldivide(12,6)"); assertTrue(0.5 == ml.getScalarValueRe("b")); } public void testMldivide03() { ml.executeExpression("b=mldivide(6,12)"); assertTrue(2 == ml.getScalarValueRe("b")); } public void testMldivide04() { ml.executeExpression("b=mldivide(5,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } } --- NEW FILE: testNe.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testNe extends TestCase { protected Interpreter ml; public testNe(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testNe.class); } /*****************************************************************/ public void testNe01() { ml.executeExpression("a=ne(5,5);"); assertTrue(0 == ml.getScalarValueRe("a")); } public void testNe02() { ml.executeExpression("b=ne(5,6)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testNe03() { ml.executeExpression("b=ne(6,5)"); assertTrue(1 == ml.getScalarValueRe("b")); } public void testNe04() { ml.executeExpression("b=ne(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testNe05() { double[][] c = {{1.0, 1.0},{0.0, 1.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = ne(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testMrdivide.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testMrdivide extends TestCase { protected Interpreter ml; public testMrdivide(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testMrdivide.class); } /*****************************************************************/ public void testMrdivide01() { ml.executeExpression("a=mrdivide(5,5);"); assertTrue(1 == ml.getScalarValueRe("a")); } public void testMrdivide02() { ml.executeExpression("b=mrdivide(12,6)"); assertTrue(2 == ml.getScalarValueRe("b")); } public void testMrdivide03() { ml.executeExpression("b=mrdivide(6,12)"); assertTrue(0.5 == ml.getScalarValueRe("b")); } public void testMrdivide04() { ml.executeExpression("b=mrdivide(0,5)"); assertTrue(0 == ml.getScalarValueRe("b")); } } --- NEW FILE: testPlus.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testPlus extends TestCase { protected Interpreter ml; public testPlus(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testPlus.class); } /*****************************************************************/ public void testPlus01() { ml.executeExpression("a=plus(5,5);"); assertTrue(10 == ml.getScalarValueRe("a")); } public void testPlus02() { ml.executeExpression("b=plus(5,6)"); assertTrue(11 == ml.getScalarValueRe("b")); } public void testPlus03() { ml.executeExpression("b=plus(6,5)"); assertTrue(11 == ml.getScalarValueRe("b")); } public void testPlus04() { ml.executeExpression("b=plus(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testPlus05() { double[][] c = {{1.0, 10.0},{4.0, 10.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = plus(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } |
|
From: Stefan M. <st_...@us...> - 2007-01-05 14:26:32
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23475/Source/MathLib/Tools/TestSuite/Functions/Matrix Added Files: testUminus.java testUplus.java testTimes.java Log Message: --- NEW FILE: testUminus.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testUminus extends TestCase { protected Interpreter ml; public testUminus(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testUminus.class); } /*****************************************************************/ public void testUminus01() { ml.executeExpression("a=uminus(55);"); assertTrue(-55 == ml.getScalarValueRe("a")); } public void testUminus02() { ml.executeExpression("b=uminus(-56)"); assertTrue(56 == ml.getScalarValueRe("b")); } public void testUminus05() { double[][] c = {{-1.0, -3.0},{2.0, -3.0}}; ml.executeExpression("a=[1,3; -2,3]"); ml.executeExpression("z = uminus(a)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testTimes.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testTimes extends TestCase { protected Interpreter ml; public testTimes(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testTimes.class); } /*****************************************************************/ public void testTimes01() { ml.executeExpression("a=times(5,5);"); assertTrue(25 == ml.getScalarValueRe("a")); } public void testTimes02() { ml.executeExpression("b=times(5,6)"); assertTrue(30 == ml.getScalarValueRe("b")); } public void testTimes03() { ml.executeExpression("b=times(6,5)"); assertTrue(30 == ml.getScalarValueRe("b")); } public void testTimes04() { ml.executeExpression("b=times(0,0)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testTimes05() { double[][] c = {{0.0, 21.0},{4.0, 21.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("b=[0,7; 2,7]"); ml.executeExpression("z = times(a,b)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } --- NEW FILE: testUplus.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testUplus extends TestCase { protected Interpreter ml; public testUplus(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testUplus.class); } /*****************************************************************/ public void testUplus01() { ml.executeExpression("a=uplus(55);"); assertTrue(55 == ml.getScalarValueRe("a")); } public void testUplus02() { ml.executeExpression("b=uplus(-56)"); assertTrue(-56 == ml.getScalarValueRe("b")); } public void testUplus05() { double[][] c = {{1.0, 3.0},{2.0, 3.0}}; ml.executeExpression("a=[1,3; 2,3]"); ml.executeExpression("z =uplus(a)"); assertTrue(Compare.ArrayEquals(c, ml.getArrayValueRe("z"))); } } |
|
From: Stefan M. <st_...@us...> - 2007-01-05 13:31:47
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31271/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: AllTests.java Added Files: testDet.java testCumprod.java testDeterminant.txt Log Message: added tests for comprod,det,determinant --- NEW FILE: testDeterminant.txt --- see testDet.java --- NEW FILE: testCumprod.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testCumprod extends TestCase { protected Interpreter ml; public testCumprod(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testCumprod.class); } public void testCumprod01() { ml.executeExpression("a=cumprod(5);"); assertTrue(5 == ml.getScalarValueRe("a")); } public void testCumprod02() { double[][] a = {{1.0, 2.0, 3.0},{4.0, 10.0, 18.0}}; ml.executeExpression("z = cumprod([1,2,3;4,5,6])"); assertTrue(Compare.ArrayEquals(a, ml.getArrayValueRe("z"))); } public void testCumprod03() { double[][] a = {{1.0, 2.0, 6.0}}; ml.executeExpression("z = cumprod([1,2,3])"); assertTrue(Compare.ArrayEquals(a, ml.getArrayValueRe("z"))); } } --- NEW FILE: testDet.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testDet extends TestCase { protected Interpreter ml; public testDet(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testDet.class); } public void testDet01() { ml.executeExpression("a=det(5);"); assertTrue(5 == ml.getScalarValueRe("a")); } public void testDet02() { ml.executeExpression("z = det([1,2,3;4,5,12;1,1,1])"); assertTrue(6 == ml.getScalarValueRe("z")); } public void testDet03() { ml.executeExpression("z = det([1,2;3,4])"); assertTrue(-2 == ml.getScalarValueRe("z")); } public void testDet04() { ml.executeExpression("z = determinant([2,3;3,4])"); assertTrue(-1 == ml.getScalarValueRe("z")); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/AllTests.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AllTests.java 9 Dec 2006 16:16:56 -0000 1.13 --- AllTests.java 5 Jan 2007 13:31:43 -0000 1.14 *************** *** 25,29 **** --- 25,31 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testColumns.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testCtranspose.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testCumprod.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testCumsum.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testDet.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testDiag.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.TestEye.suite()); |
|
From: Stefan M. <st_...@us...> - 2007-01-05 13:18:02
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24861/Source/MathLib/Tools/TestSuite/Functions/General Modified Files: AllTests.java Added Files: testImag.java testReal.java Log Message: --- NEW FILE: testReal.java --- package MathLib.Tools.TestSuite.Functions.General; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testReal extends TestCase { protected Interpreter ml; public testReal(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testReal.class); } ///////////////////////////////////////////////////////////////// public void testReal01() { ml.executeExpression("a=5+6i"); ml.executeExpression("b=real(a)"); assertTrue(5 == ml.getScalarValueRe("b")); } public void testReal02() { ml.executeExpression("a=55"); ml.executeExpression("b=real(a)"); assertTrue(55 == ml.getScalarValueRe("b")); } public void testReal03() { ml.executeExpression("a=56i"); ml.executeExpression("b=real(a)"); assertTrue(0 == ml.getScalarValueRe("b")); } } --- NEW FILE: testImag.java --- package MathLib.Tools.TestSuite.Functions.General; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testImag extends TestCase { protected Interpreter ml; public testImag(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testImag.class); } ///////////////////////////////////////////////////////////////// public void testImag01() { ml.executeExpression("a=5+6i"); ml.executeExpression("b=imag(a)"); assertTrue(6 == ml.getScalarValueRe("b")); } public void testImag02() { ml.executeExpression("a=55"); ml.executeExpression("b=imag(a)"); assertTrue(0 == ml.getScalarValueRe("b")); } public void testImag03() { ml.executeExpression("a=56i"); ml.executeExpression("b=imag(a)"); assertTrue(56 == ml.getScalarValueRe("b")); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General/AllTests.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AllTests.java 19 Aug 2006 09:55:06 -0000 1.14 --- AllTests.java 5 Jan 2007 13:17:55 -0000 1.15 *************** *** 34,37 **** --- 34,38 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.General.testFix.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testHarmonic.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.General.testImag.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testIscell.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testIschar.suite()); *************** *** 47,50 **** --- 48,52 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.General.testPrimes.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testRand.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.General.testReal.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testSetPFileCaching.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testSign.suite()); |
|
From: Stefan M. <st_...@us...> - 2007-01-05 13:10:20
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21696/Source/MathLib/Tools/TestSuite/Functions Modified Files: AllTests.java Added Files: testUserFunction.java Log Message: added tests for function x=barfoo(a,b,c,varargin) --- NEW FILE: testUserFunction.java --- package MathLib.Tools.TestSuite.Functions; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testUserFunction extends TestCase { protected Interpreter ml; public testUserFunction(String name) { super(name); } public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } protected void setUp() { ml = new Interpreter(true); } public static Test suite() { return new TestSuite(testUserFunction.class); } /****** functions() **************************************************/ public void testUserFunction001() { ml.executeExpression("[a,b]=testFunction007(1,2,3,4);"); assertTrue(1.0 == ml.getScalarValueRe("a")); assertTrue(1.0 == ml.getScalarValueRe("b")); } public void testUserFunction002() { ml.executeExpression("[a,b]=testFunction007(1,2,3,4,5);"); assertTrue(2.0 == ml.getScalarValueRe("a")); assertTrue(1.0 == ml.getScalarValueRe("b")); } public void testUserFunction003() { ml.executeExpression("[a,b]=testFunction007(1,2,3,4,5,6);"); assertTrue(3.0 == ml.getScalarValueRe("a")); assertTrue(1.0 == ml.getScalarValueRe("b")); } public void testUserFunction004() { ml.executeExpression("[a,b]=testFunction007(1,2,3,4,5,'abc');"); assertTrue(3.0 == ml.getScalarValueRe("a")); assertTrue(1.0 == ml.getScalarValueRe("b")); } public void testUserFunction005() { ml.executeExpression("[a,b]=testFunction007(1,2,3,4,5,6,7);"); assertTrue(4.0 == ml.getScalarValueRe("a")); assertTrue(1.0 == ml.getScalarValueRe("b")); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/AllTests.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AllTests.java 19 Aug 2006 10:03:30 -0000 1.16 --- AllTests.java 5 Jan 2007 13:10:14 -0000 1.17 *************** *** 52,55 **** --- 52,56 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.testFunctions.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.testStandardFunctions.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.testUserFunction.suite()); |
|
From: Stefan M. <st_...@us...> - 2007-01-05 13:10:20
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/test In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21696/Source/MathLib/Functions/test Added Files: testFunction007.m Log Message: added tests for function x=barfoo(a,b,c,varargin) --- NEW FILE: testFunction007.m --- function [y,x]=testFunction007(a,b,c,varargin) x=0 z=size(varargin) y=z(1) x=z(2) endfunction |
|
From: Stefan M. <st_...@us...> - 2007-01-05 12:36:44
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6168 Modified Files: build.properties Log Message: preparatin for version 0.8.0 Index: build.properties =================================================================== RCS file: /cvsroot/mathlib/mathlib/build.properties,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** build.properties 4 Nov 2006 18:48:58 -0000 1.10 --- build.properties 5 Jan 2007 12:36:33 -0000 1.11 *************** *** 7,11 **** # Project version ! version=0.7.0 # final project name --- 7,11 ---- # Project version ! version=0.8.0 # final project name |
|
From: Stefan M. <st_...@us...> - 2007-01-05 11:41:13
|
Update of /cvsroot/mathlib/mathlib/Documentation/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv14701/Documentation/src Modified Files: doc.xml Log Message: Index: doc.xml =================================================================== RCS file: /cvsroot/mathlib/mathlib/Documentation/src/doc.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** doc.xml 2 Jan 2007 12:16:05 -0000 1.15 --- doc.xml 5 Jan 2007 11:41:08 -0000 1.16 *************** *** 69,73 **** </abstract> ! <pubdate>January xx, 2007</pubdate> <releaseinfo><para><emphasis> --- 69,73 ---- </abstract> ! <pubdate>January 05, 2007</pubdate> <releaseinfo><para><emphasis> |
|
From: Stefan M. <st_...@us...> - 2007-01-05 09:26:48
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20213 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** ChangeLog.txt 2 Jan 2007 16:21:29 -0000 1.137 --- ChangeLog.txt 5 Jan 2007 09:26:45 -0000 1.138 *************** *** 9,21 **** ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! angle.java, close.java, compan.m, complement.m, createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, ! eq.m, ge.m, gray2ind.m, gray.m, gt.m, hankel.m, inf.java, inv.m, isdefinite.m, isdirectory.java, isfile.java, isfinite.java, ishidden.java, isnan.java, isinf.java, issymmetric.m, lastmodified.java, le.m, lookup.m, mkdir.java, nan.java, ne.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, ! pmt.m, polyval.m, polyreduce.m, poly.m, pv.m, pvl.m, qtransvmat.m, repmat.java, ! rmdir.java, roots.m, size_equal.m, sort.java, stril.m, sylvester_matrix.m, ! toeplitz.m, triangle_lw.m, triangle_sw.m, triu.m, vech.m, wilkinson.m, Updated functions: --- 9,24 ---- ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! angle.java, beta.m, betaln.m, close.java, compan.m, complement.m, ! createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, ! eq.m, gammaln.m, ! ge.m, gray2ind.m, gray.m, gt.m, hankel.m, inf.java, inv.m, isdefinite.m, isdirectory.java, isfile.java, isfinite.java, ishidden.java, isnan.java, isinf.java, issymmetric.m, lastmodified.java, le.m, lookup.m, mkdir.java, nan.java, ne.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, ! pmt.m, polyval.m, polyreduce.m, poly.m, pv.m, pvl.m, qtransvmat.m, rehash.java, ! repmat.java, rmdir.java, roots.m, size_equal.m, sort.java, stril.m, ! sylvester_matrix.m, toeplitz.m, triangle_lw.m, triangle_sw.m, triu.m, vech.m, ! wilkinson.m, Updated functions: *************** *** 27,30 **** --- 30,42 ---- stefan * + 2007/01/05 + stefan + Functions/specfun/_private/ContinuedFraction.java + stefan + Functions/specfun/_private/ConvergenceException.java + stefan + Functions/specfun/_private/Gamma.java + stefan + Functions/specfun/bessel.m + stefan + Functions/specfun/beta.m + stefan + Functions/specfun/betaln.m + stefan + Functions/specfun/gammaln.m + 2007/01/02 stefan * Function.java, FunctionManager.java, MFileLoader.java and added support |
|
From: Stefan M. <st_...@us...> - 2007-01-05 09:10:37
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/specfun In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13633/Source/MathLib/Functions/specfun Added Files: gammaln.java Log Message: --- NEW FILE: gammaln.java --- package MathLib.Functions.specfun; import MathLib.Tokens.*; import MathLib.Functions.ExternalFunction; import MathLib.Functions.specfun._private.*; public class gammaln extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) != 1) throwMathLibException("gammaln: number of arguments != 1"); if (!(operands[0] instanceof NumberToken)) throwMathLibException("gammaln: argument must be a number"); double[][] x = ((NumberToken)operands[0]).getReValues(); int dy = ((NumberToken)operands[0]).getSizeY(); int dx = ((NumberToken)operands[0]).getSizeX(); double[][] gammaln = new double[dy][dx]; for (int xi=0; xi<dx ; xi++) { for (int yi=0; yi<dy ; yi++) { gammaln[yi][xi] = Gamma.logGamma(x[yi][xi]); } } return new NumberToken(gammaln); } // end eval } /* @GROUP specfun @SYNTAX gammaln(x) @DOC return the log of the gamma function @EXAMPLES <programlisting> gammaln(3.5) gammaln([2,3,4;5,6,7]) </programlisting> @NOTES @SEE beta */ |
|
From: Stefan M. <st_...@us...> - 2007-01-05 08:55:56
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/specfun/_private In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7351/Source/MathLib/Functions/specfun/_private Added Files: ConvergenceException.java ContinuedFraction.java Gamma.java Log Message: --- NEW FILE: ContinuedFraction.java --- /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package org.apache.commons.math.util; package MathLib.Functions.specfun._private; import java.io.Serializable; //import org.apache.commons.math.ConvergenceException; //import org.apache.commons.math.MathException; /** * Provides a generic means to evaluate continued fractions. Subclasses simply * provided the a and b coefficients to evaluate the continued fraction. * * <p> * References: * <ul> * <li><a href="http://mathworld.wolfram.com/ContinuedFraction.html"> * Continued Fraction</a></li> * </ul> * </p> * * @version $Revision: 1.1 $ $Date: 2007/01/05 08:55:48 $ */ public abstract class ContinuedFraction implements Serializable { /** Serialization UID */ private static final long serialVersionUID = 1768555336266158242L; /** Maximum allowed numerical error. */ private static final double DEFAULT_EPSILON = 10e-9; /** * Default constructor. */ protected ContinuedFraction() { super(); } /** * Access the n-th a coefficient of the continued fraction. Since a can be * a function of the evaluation point, x, that is passed in as well. * @param n the coefficient index to retrieve. * @param x the evaluation point. * @return the n-th a coefficient. */ protected abstract double getA(int n, double x); /** * Access the n-th b coefficient of the continued fraction. Since b can be * a function of the evaluation point, x, that is passed in as well. * @param n the coefficient index to retrieve. * @param x the evaluation point. * @return the n-th b coefficient. */ protected abstract double getB(int n, double x); /** * Evaluates the continued fraction at the value x. * @param x the evaluation point. * @return the value of the continued fraction evaluated at x. * @throws MathException if the algorithm fails to converge. */ public double evaluate(double x) throws Exception { return evaluate(x, DEFAULT_EPSILON, Integer.MAX_VALUE); } /** * Evaluates the continued fraction at the value x. * @param x the evaluation point. * @param epsilon maximum error allowed. * @return the value of the continued fraction evaluated at x. * @throws MathException if the algorithm fails to converge. */ public double evaluate(double x, double epsilon) throws Exception { return evaluate(x, epsilon, Integer.MAX_VALUE); } /** * Evaluates the continued fraction at the value x. * @param x the evaluation point. * @param maxIterations maximum number of convergents * @return the value of the continued fraction evaluated at x. * @throws MathException if the algorithm fails to converge. */ public double evaluate(double x, int maxIterations) throws Exception { return evaluate(x, DEFAULT_EPSILON, maxIterations); } /** * <p> * Evaluates the continued fraction at the value x. * </p> * * <p> * The implementation of this method is based on equations 14-17 of: * <ul> * <li> * Eric W. Weisstein. "Continued Fraction." From MathWorld--A Wolfram Web * Resource. <a target="_blank" * href="http://mathworld.wolfram.com/ContinuedFraction.html"> * http://mathworld.wolfram.com/ContinuedFraction.html</a> * </li> * </ul> * The recurrence relationship defined in those equations can result in * very large intermediate results which can result in numerical overflow. * As a means to combat these overflow conditions, the intermediate results * are scaled whenever they threaten to become numerically unstable. * * @param x the evaluation point. * @param epsilon maximum error allowed. * @param maxIterations maximum number of convergents * @return the value of the continued fraction evaluated at x. * @throws MathException if the algorithm fails to converge. */ public double evaluate(double x, double epsilon, int maxIterations) throws Exception { double p0 = 1.0; double p1 = getA(0, x); double q0 = 0.0; double q1 = 1.0; double c = p1 / q1; int n = 0; double relativeError = Double.MAX_VALUE; while (n < maxIterations && relativeError > epsilon) { ++n; double a = getA(n, x); double b = getB(n, x); double p2 = a * p1 + b * p0; double q2 = a * q1 + b * q0; if (Double.isInfinite(p2) || Double.isInfinite(q2)) { // need to scale if (a != 0.0) { p2 = p1 + (b / a * p0); q2 = q1 + (b / a * q0); } else if (b != 0) { p2 = (a / b * p1) + p0; q2 = (a / b * q1) + q0; } else { // can not scale an convergent is unbounded. throw new ConvergenceException( "Continued fraction convergents diverged to +/- " + "infinity."); } } double r = p2 / q2; relativeError = Math.abs(r / c - 1.0); // prepare for next iteration c = p2 / q2; p0 = p1; p1 = p2; q0 = q1; q1 = q2; } if (n >= maxIterations) { throw new ConvergenceException( "Continued fraction convergents failed to converge."); } return c; } } --- NEW FILE: Gamma.java --- /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package org.apache.commons.math.special; package MathLib.Functions.specfun._private; //import java.io.Serializable; //import org.apache.commons.math.ConvergenceException; //import org.apache.commons.math.MathException; //import org.apache.commons.math.util.ContinuedFraction; /** * This is a utility class that provides computation methods related to the * Gamma family of functions. * * @version $Revision: 1.1 $ $Date: 2007/01/05 08:55:48 $ */ public class Gamma /*implements Serializable*/ { /** Maximum allowed numerical error. */ private static final double DEFAULT_EPSILON = 10e-9; /** Lanczos coefficients */ private static double[] lanczos = { 0.99999999999999709182, 57.156235665862923517, -59.597960355475491248, 14.136097974741747174, -0.49191381609762019978, .33994649984811888699e-4, .46523628927048575665e-4, -.98374475304879564677e-4, .15808870322491248884e-3, -.21026444172410488319e-3, .21743961811521264320e-3, -.16431810653676389022e-3, .84418223983852743293e-4, -.26190838401581408670e-4, .36899182659531622704e-5, }; /** Avoid repeated computation of log of 2 PI in logGamma */ private static final double HALF_LOG_2_PI = 0.5 * Math.log(2.0 * Math.PI); /** * Default constructor. Prohibit instantiation. */ private Gamma() { //super(); } /** * Returns the natural logarithm of the gamma function Γ(x). * * The implementation of this method is based on: * <ul> * <li><a href="http://mathworld.wolfram.com/GammaFunction.html"> * Gamma Function</a>, equation (28).</li> * <li><a href="http://mathworld.wolfram.com/LanczosApproximation.html"> * Lanczos Approximation</a>, equations (1) through (5).</li> * <li><a href="http://my.fit.edu/~gabdo/gamma.txt">Paul Godfrey, A note on * the computation of the convergent Lanczos complex Gamma approximation * </a></li> * </ul> * * @param x the value. * @return log(Γ(x)) */ public static double logGamma(double x) { double ret; if (Double.isNaN(x) || (x <= 0.0)) { ret = Double.NaN; } else { double g = 607.0 / 128.0; double sum = 0.0; for (int i = lanczos.length - 1; i > 0; --i) { sum = sum + (lanczos[i] / (x + i)); } sum = sum + lanczos[0]; double tmp = x + g + .5; ret = ((x + .5) * Math.log(tmp)) - tmp + HALF_LOG_2_PI + Math.log(sum / x); } return ret; } /** * Returns the regularized gamma function P(a, x). * * @param a the a parameter. * @param x the value. * @return the regularized gamma function P(a, x) * @throws MathException if the algorithm fails to converge. */ public static double regularizedGammaP(double a, double x) throws Exception { return regularizedGammaP(a, x, DEFAULT_EPSILON, Integer.MAX_VALUE); } /** * Returns the regularized gamma function P(a, x). * * The implementation of this method is based on: * <ul> * <li> * <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html"> * Regularized Gamma Function</a>, equation (1).</li> * <li> * <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html"> * Incomplete Gamma Function</a>, equation (4).</li> * <li> * <a href="http://mathworld.wolfram.com/ConfluentHypergeometricFunctionoftheFirstKind.html"> * Confluent Hypergeometric Function of the First Kind</a>, equation (1). * </li> * </ul> * * @param a the a parameter. * @param x the value. * @param epsilon When the absolute value of the nth item in the * series is less than epsilon the approximation ceases * to calculate further elements in the series. * @param maxIterations Maximum number of "iterations" to complete. * @return the regularized gamma function P(a, x) * @throws MathException if the algorithm fails to converge. */ public static double regularizedGammaP(double a, double x, double epsilon, int maxIterations) throws Exception { double ret; if (Double.isNaN(a) || Double.isNaN(x) || (a <= 0.0) || (x < 0.0)) { ret = Double.NaN; } else if (x == 0.0) { ret = 0.0; } else if (a >= 1.0 && x > a) { // use regularizedGammaQ because it should converge faster in this // case. ret = 1.0 - regularizedGammaQ(a, x, epsilon, maxIterations); } else { // calculate series double n = 0.0; // current element index double an = 1.0 / a; // n-th element in the series double sum = an; // partial sum while (Math.abs(an) > epsilon && n < maxIterations) { // compute next element in the series n = n + 1.0; an = an * (x / (a + n)); // update partial sum sum = sum + an; } if (n >= maxIterations) { throw new ConvergenceException( "maximum number of iterations reached"); } else { ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * sum; } } return ret; } /** * Returns the regularized gamma function Q(a, x) = 1 - P(a, x). * * @param a the a parameter. * @param x the value. * @return the regularized gamma function Q(a, x) * @throws MathException if the algorithm fails to converge. */ public static double regularizedGammaQ(double a, double x) throws Exception { return regularizedGammaQ(a, x, DEFAULT_EPSILON, Integer.MAX_VALUE); } /** * Returns the regularized gamma function Q(a, x) = 1 - P(a, x). * * The implementation of this method is based on: * <ul> * <li> * <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html"> * Regularized Gamma Function</a>, equation (1).</li> * <li> * <a href=" http://functions.wolfram.com/GammaBetaErf/GammaRegularized/10/0003/"> * Regularized incomplete gamma function: Continued fraction representations (formula 06.08.10.0003)</a></li> * </ul> * * @param a the a parameter. * @param x the value. * @param epsilon When the absolute value of the nth item in the * series is less than epsilon the approximation ceases * to calculate further elements in the series. * @param maxIterations Maximum number of "iterations" to complete. * @return the regularized gamma function P(a, x) * @throws MathException if the algorithm fails to converge. */ public static double regularizedGammaQ(final double a, double x, double epsilon, int maxIterations) throws Exception { double ret; if (Double.isNaN(a) || Double.isNaN(x) || (a <= 0.0) || (x < 0.0)) { ret = Double.NaN; } else if (x == 0.0) { ret = 1.0; } else if (x < a || a < 1.0) { // use regularizedGammaP because it should converge faster in this // case. ret = 1.0 - regularizedGammaP(a, x, epsilon, maxIterations); } else { // create continued fraction ContinuedFraction cf = new ContinuedFraction() { protected double getA(int n, double x) { return ((2.0 * n) + 1.0) - a + x; } protected double getB(int n, double x) { return n * (a - n); } }; ret = 1.0 / cf.evaluate(x, epsilon, maxIterations); ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * ret; } return ret; } } --- NEW FILE: ConvergenceException.java --- /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //package org.apache.commons.math; package MathLib.Functions.specfun._private; //import java.io.Serializable; /** * Error thrown when a numerical computation can not be performed because the * numerical result failed to converge to a finite value. * * @version $Revision: 1.1 $ $Date: 2007/01/05 08:55:48 $ */ public class ConvergenceException extends Exception /*implements Serializable*/{ /** Serializable version identifier */ private static final long serialVersionUID = -3657394299929217890L; /** * Default constructor. */ public ConvergenceException() { this(null, null); } /** * Construct an exception with the given message. * @param message descriptive error message. */ public ConvergenceException(String message) { this(message, null); } /** * Construct an exception with the given message and root cause. * @param message descriptive error message. * @param cause root cause. */ public ConvergenceException(String message, Throwable cause) { super(message, cause); } /** * Create an exception with a given root cause. * @param throwable caught exception causing this problem */ public ConvergenceException(Throwable throwable) { this(null, throwable); } } |