mathlib-commitlog Mailing List for JMathLib - Octave, Matlab clone in java (Page 39)
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-02-03 19:44:52
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15159/Source/MathLib/Interpreter Modified Files: Parser.java LexicalAnalyser.java Log Message: throw exception for */ ** /* */ // (multiple operators) Index: Parser.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter/Parser.java,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** Parser.java 17 Jan 2007 19:46:40 -0000 1.125 --- Parser.java 3 Feb 2007 19:44:49 -0000 1.126 *************** *** 325,329 **** // e.g. a=/7 a=*8 +*5 -*8 -/9 if (( (nextToken instanceof AssignmentOperatorToken) || ! (nextToken instanceof AddSubOperatorToken) ) && (pToken instanceof MulDivOperatorToken) ) Errors.throwParserException("multiple operators * /"); --- 325,330 ---- // e.g. a=/7 a=*8 +*5 -*8 -/9 if (( (nextToken instanceof AssignmentOperatorToken) || ! (nextToken instanceof AddSubOperatorToken) || ! (nextToken instanceof MulDivOperatorToken) ) && (pToken instanceof MulDivOperatorToken) ) Errors.throwParserException("multiple operators * /"); Index: LexicalAnalyser.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter/LexicalAnalyser.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** LexicalAnalyser.java 7 Jan 2007 15:43:04 -0000 1.73 --- LexicalAnalyser.java 3 Feb 2007 19:44:49 -0000 1.74 *************** *** 618,622 **** nextToken = new NumberToken(0,value); } ! else if(name.equals("Inf")) { // positive and negative infinity --- 618,622 ---- nextToken = new NumberToken(0,value); } ! else if(name.equals("Inf") || name.equals("inf")) { // positive and negative infinity |
|
From: Stefan M. <st_...@us...> - 2007-02-03 18:32:21
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv14462/Source/MathLib/Tools/TestSuite/Functions/General Modified Files: testClass.java Log Message: Index: testClass.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General/testClass.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testClass.java 3 Feb 2007 13:34:56 -0000 1.1 --- testClass.java 3 Feb 2007 18:32:14 -0000 1.2 *************** *** 43,46 **** --- 43,51 ---- } + public void testClass05() { + ml.executeExpression("b=logical(3)"); + ml.executeExpression("a=class(b)"); + assertTrue(ml.getString("a").equals("logical")); + } |
|
From: Stefan M. <st_...@us...> - 2007-02-03 13:52:39
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25521 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** ChangeLog.txt 3 Feb 2007 11:57:11 -0000 1.162 --- ChangeLog.txt 3 Feb 2007 13:52:35 -0000 1.163 *************** *** 9,23 **** ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! angle.java, bench.m, beta.m, betaln.m, center.m, cloglog.m, close.java, ! compan.m, complement.m, cov.m, createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, eq.m, false.m, gammaln.m, ge.m, gray2ind.m, gray.m, ! gt.m, ! hankel.m, hurst.m, inf.java, inv.m, isa.java, isdefinite.m, isdirectory.java, ! isfile.java, isfinite.java, ishidden.java, islogical.java, isnan.java, isinf.java, ! issymmetric.m, ! lastmodified.java, le.m, loadvariables.java, logical.java, lookup.m, mean.m, ! meansq.java, mkdir.java, nan.java, ne.m, nthroot.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, pmt.m, polyval.m, polyreduce.m, poly.m, print_usage.java, --- 9,21 ---- ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! _class.java, angle.java, bench.m, beta.m, betaln.m, center.m, class.m, ! cloglog.m, close.java, compan.m, complement.m, cov.m, createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, eq.m, false.m, gammaln.m, ge.m, gray2ind.m, gray.m, ! gt.m, hankel.m, hurst.m, inf.java, inv.m, isa.java, isdefinite.m, ! isdirectory.java, isfile.java, isfinite.java, ishidden.java, islogical.java, isnan.java, isinf.java, ! issymmetric.m, lastmodified.java, le.m, loadvariables.java, logical.java, ! lookup.m, mean.m, meansq.java, mkdir.java, nan.java, ne.m, nthroot.m, ntsc2rgb.m, nper.m, numel.java, orth.m, pascal.m, perms.m, pmt.m, polyval.m, polyreduce.m, poly.m, print_usage.java, *************** *** 39,42 **** --- 37,43 ---- 2007/02/3 + stefan + Functions/General/_class.java + stefan + Functions/General/class.m + stefan + TestSuite/Functions/General/testClass.java stefan + testCtranspose.java added tests for ctranspose(a) stefan + testTranspose.java added tests for ctranspose(a) |
|
From: Stefan M. <st_...@us...> - 2007-02-03 13:35:01
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17586/Source/MathLib/Tools/TestSuite/Functions/General Modified Files: AllTests.java Added Files: testClass.java Log Message: --- NEW FILE: testClass.java --- package MathLib.Tools.TestSuite.Functions.General; import MathLib.Tools.junit.framework.*; import MathLib.Interpreter.*; public class testClass extends TestCase { protected Interpreter ml; public testClass(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(testClass.class); } ///////////////////////////////////////////////////////////////// public void testClass01() { ml.executeExpression("a=class(88)"); assertTrue(ml.getString("a").equals("double")); } public void testClass02() { ml.executeExpression("a=class('asd88')"); assertTrue(ml.getString("a").equals("char")); } public void testClass03() { ml.executeExpression("a=class([8 89 9])"); assertTrue(ml.getString("a").equals("double")); } public void testClass04() { ml.executeExpression("b=cell(3)"); ml.executeExpression("a=class(b)"); assertTrue(ml.getString("a").equals("cell")); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/General/AllTests.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AllTests.java 14 Jan 2007 19:19:03 -0000 1.17 --- AllTests.java 3 Feb 2007 13:34:56 -0000 1.18 *************** *** 24,27 **** --- 24,28 ---- suite.addTest(MathLib.Tools.TestSuite.Functions.General.testBitShift.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testBitXOr.suite()); + suite.addTest(MathLib.Tools.TestSuite.Functions.General.testClass.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testClear.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.General.testClock.suite()); |
|
From: Stefan M. <st_...@us...> - 2007-02-03 13:35:01
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/General In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17586/Source/MathLib/Functions/General Added Files: _class.java class.m Log Message: --- NEW FILE: class.m --- function x=class(y) x=_class(y); endfunction --- NEW FILE: _class.java --- package MathLib.Functions.General; import MathLib.Tokens.Token; import MathLib.Tokens.OperandToken; import MathLib.Tokens.DataToken; import MathLib.Tokens.CharToken; import MathLib.Functions.ExternalFunction; public class _class extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) != 1) throwMathLibException("_class: number of arguments != 1"); if (!(operands[0] instanceof DataToken)) throwMathLibException("_class: first operand must be a data token"); String opDataType = ((DataToken)operands[0]).getDataType(); return new CharToken(opDataType); } } /* @GROUP general @SYNTAX class(value) @DOC returns the class name of some array. @EXAMPLES <programlisting> a=55 class(a) -> double b='asdf' class(b) -> char </programlisting> @NOTES . @SEE isa, ismatrix, isnumeric, isscalar, issquare, islogical */ |
|
From: Stefan M. <st_...@us...> - 2007-02-03 12:11:13
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv14553/Source/MathLib/Functions/Matrix Modified Files: find.java Log Message: Index: find.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/find.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** find.java 13 Jan 2007 22:36:02 -0000 1.10 --- find.java 3 Feb 2007 12:11:05 -0000 1.11 *************** *** 20,32 **** throwMathLibException("find: number of arguments <1 or >2"); ! if (!(operands[0] instanceof NumberToken)) ! throwMathLibException("find: works only on numbers"); ! // get data from arguments ! double[][] values = ((NumberToken)operands[0]).getReValues(); ! int dy = values.length; ! int dx = values[0].length; - // find number of nonzero elements int no = 0; --- 20,43 ---- throwMathLibException("find: number of arguments <1 or >2"); ! double[][] values = null; ! int dy = 0; ! int dx = 0; ! ! if ((operands[0] instanceof NumberToken)) ! { ! // get data from arguments ! values = ((NumberToken)operands[0]).getValuesRe(); ! } ! else if ((operands[0] instanceof LogicalToken)) ! { ! NumberToken num = ((LogicalToken)operands[0]).getNumberToken(); ! values = num.getValuesRe(); ! } ! else ! throwMathLibException("find: works only on numbers and booleans"); ! dy = values.length; ! dx = values[0].length; // find number of nonzero elements int no = 0; |
|
From: Stefan M. <st_...@us...> - 2007-02-03 12:07:01
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12886/Source/MathLib/Functions/Matrix Modified Files: Adjoint.java Log Message: code cleanup Index: Adjoint.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/Adjoint.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Adjoint.java 6 Jan 2007 09:32:14 -0000 1.12 --- Adjoint.java 3 Feb 2007 12:06:57 -0000 1.13 *************** *** 15,39 **** public OperandToken evaluate(Token[] operands) { ! OperandToken result = null; ! Token operand = operands[0]; if (getNArgIn(operands) != 1) throwMathLibException("Adjoint: number of arguments != 1"); ! if(operand instanceof NumberToken) { ! NumberToken matrix = ((NumberToken)operand); ! if(matrix.getSizeX() == matrix.getSizeY()) ! { ! int size = matrix.getSizeX(); ! ! result = new NumberToken(calcAdjoint(matrix.getReValues(), size)); ! } ! else ! { ! MathLib.Interpreter.Errors.throwMathLibException(ERR_NOT_SQUARE_MATRIX); ! } } return result; --- 15,38 ---- public OperandToken evaluate(Token[] operands) { ! OperandToken result = null; if (getNArgIn(operands) != 1) throwMathLibException("Adjoint: number of arguments != 1"); ! if(!(operands[0] instanceof NumberToken)) ! throwMathLibException("Adjoint: works only on numbers"); ! ! NumberToken matrix = ((NumberToken)operands[0]); ! ! if(matrix.getSizeX() == matrix.getSizeY()) { ! int size = matrix.getSizeX(); ! result = new NumberToken(calcAdjoint(matrix.getReValues(), size)); } + else + { + MathLib.Interpreter.Errors.throwMathLibException(ERR_NOT_SQUARE_MATRIX); + } return result; *************** *** 48,52 **** { FunctionToken token = null; ! Function function = null; try { --- 47,52 ---- { FunctionToken token = null; ! Function function = null; ! try { |
|
From: Stefan M. <st_...@us...> - 2007-02-03 12:06:49
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12829/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: testAdjoint.java Log Message: added test for adjoint() Index: testAdjoint.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testAdjoint.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testAdjoint.java 30 Jan 2007 19:52:54 -0000 1.2 --- testAdjoint.java 3 Feb 2007 12:06:37 -0000 1.3 *************** *** 22,43 **** } ! /****** not() ************************************************************/ ! public void testNot01() { ! ml.executeExpression("a=adjoint(3);"); ! assertTrue(0 == ml.getScalarValueRe("a")); ! assertTrue(3 == ml.getScalarValueIm("a")); ! } ! public void testNot02() { ! ml.executeExpression("a=not(0)"); ! assertTrue(1 == ml.getScalarValueRe("a")); ! } ! public void testNot03() { ! double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! double[][] b = {{0.0, 0.0, 0.0},{ 0.0, 1.0, 1.0},{ 0.0, 0.0, 1.0}}; ! double[][] c = {{0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0}}; ! ml.setArray("a", a, c); ! ml.executeExpression("z = not(a)"); assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("z"))); - assertTrue(Compare.ArrayEquals(c, ml.getArrayValueIm("z"))); } --- 22,29 ---- } ! public void testAdjoint01() { ! double[][] b = {{5, -3},{-4, 2}}; ! ml.executeExpression("z = adjoint([2,3;4,5])"); assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("z"))); } |
|
From: Stefan M. <st_...@us...> - 2007-02-03 11:57:16
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8612 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** ChangeLog.txt 30 Jan 2007 19:48:08 -0000 1.161 --- ChangeLog.txt 3 Feb 2007 11:57:11 -0000 1.162 *************** *** 35,41 **** ---- HISTORY ------------------------------------------------------------------ ! 2007/01/xx stefan * 2007/01/30 stefan # Functions/Matrix/not.java fixed wrong evaluation of numbers --- 35,45 ---- ---- HISTORY ------------------------------------------------------------------ ! 2007/02/xx stefan * + 2007/02/3 + stefan + testCtranspose.java added tests for ctranspose(a) + stefan + testTranspose.java added tests for ctranspose(a) + 2007/01/30 stefan # Functions/Matrix/not.java fixed wrong evaluation of numbers |
|
From: Stefan M. <st_...@us...> - 2007-02-03 11:56:07
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8198/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: AllTests.java testCtranspose.java Added Files: testTranspose.java Log Message: added tests for ctranspose() and transpose() Index: AllTests.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/AllTests.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AllTests.java 14 Jan 2007 18:40:40 -0000 1.17 --- AllTests.java 3 Feb 2007 11:55:57 -0000 1.18 *************** *** 56,59 **** --- 56,60 ---- 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.testTranspose.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testUminus.suite()); suite.addTest(MathLib.Tools.TestSuite.Functions.Matrix.testUplus.suite()); Index: testCtranspose.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testCtranspose.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testCtranspose.java 31 Oct 2004 16:13:40 -0000 1.1 --- testCtranspose.java 3 Feb 2007 11:55:57 -0000 1.2 *************** *** 22,43 **** } ! /****** not() ************************************************************/ ! public void testNot01() { ! ml.executeExpression("a=not(1);"); ! assertTrue(0 == ml.getScalarValueRe("a")); ! } ! public void testNot02() { ! ml.executeExpression("a=not(0)"); ! assertTrue(1 == ml.getScalarValueRe("a")); ! } ! public void testNot03() { ! double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! double[][] b = {{0.0, 0.0, 0.0},{ 0.0, 1.0, 1.0},{ 0.0, 0.0, 1.0}}; ! double[][] c = {{0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0}}; ! ml.setArray("a", a, c); ! ml.executeExpression("z = not(a)"); ! assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("z"))); ! assertTrue(Compare.ArrayEquals(c, ml.getArrayValueIm("z"))); } } \ No newline at end of file --- 22,57 ---- } ! public void testCtranspose01() { ! ml.executeExpression("a=ctranspose(2);"); ! assertTrue(2 == ml.getScalarValueRe("a")); ! assertTrue(0 == ml.getScalarValueIm("a")); } + public void testCtranspose02() { + ml.executeExpression("a=ctranspose(2i);"); + assertTrue(0 == ml.getScalarValueRe("a")); + assertTrue(-2 == ml.getScalarValueIm("a")); + } + + public void testCtranspose03() { + ml.executeExpression("a=ctranspose(22+33i);"); + assertTrue(22 == ml.getScalarValueRe("a")); + assertTrue(-33 == ml.getScalarValueIm("a")); + } + + public void testCtranspose04() { + ml.executeExpression("a=ctranspose([2,3;4,5]);"); + double[][] b = {{2.0, 4.0},{3.0, 5.0}}; + assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("a"))); + } + + public void testCtranspose05() { + ml.executeExpression("a=ctranspose([2,3i;4-44i,5]);"); + double[][] re = {{2.0, 4.0},{ 0.0, 5.0}}; + double[][] im = {{0.0, 44.0},{-3.0, 0.0}}; + assertTrue(Compare.ArrayEquals(re, ml.getArrayValueRe("a"))); + assertTrue(Compare.ArrayEquals(im, ml.getArrayValueIm("a"))); + } + + } \ No newline at end of file --- NEW FILE: testTranspose.java --- package MathLib.Tools.TestSuite.Functions.Matrix; import MathLib.Tools.junit.framework.*; import MathLib.Tools.TestSuite.*; import MathLib.Interpreter.*; public class testTranspose extends TestCase { protected Interpreter ml; public testTranspose(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(testTranspose.class); } public void testTranspose01() { ml.executeExpression("a=transpose(6);"); assertTrue(6 == ml.getScalarValueRe("a")); assertTrue(0 == ml.getScalarValueIm("a")); } public void testTranspose02() { ml.executeExpression("a=transpose(2i);"); assertTrue(0 == ml.getScalarValueRe("a")); assertTrue(2 == ml.getScalarValueIm("a")); } public void testTranspose03() { ml.executeExpression("a=transpose(22+33i);"); assertTrue(22 == ml.getScalarValueRe("a")); assertTrue(33 == ml.getScalarValueIm("a")); } public void testTranspose04() { ml.executeExpression("a=transpose([2,3;4,5]);"); double[][] b = {{2.0, 4.0},{3.0, 5.0}}; assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("a"))); } public void testTranspose05() { ml.executeExpression("a=transpose([2,3i;4-44i,5]);"); double[][] re = {{2.0, 4.0},{0.0, 5.0}}; double[][] im = {{0.0, -44.0},{3.0, 0.0}}; assertTrue(Compare.ArrayEquals(re, ml.getArrayValueRe("a"))); assertTrue(Compare.ArrayEquals(im, ml.getArrayValueIm("a"))); } } |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:56:14
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9374/Source/MathLib/Tokens Modified Files: WhileOperatorToken.java CaseToken.java LogicalToken.java Log Message: better support for logical tokens Index: CaseToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/CaseToken.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CaseToken.java 6 Jan 2007 09:36:19 -0000 1.10 --- CaseToken.java 30 Jan 2007 19:55:52 -0000 1.11 *************** *** 42,52 **** OperandToken result = exp.evaluate(null); ! if(result instanceof NumberToken) { ! if(((NumberToken)result).getValueRe() != 0) { ErrorLogger.debugLine("case is TRUE "); code.evaluate(null); ! return NumberToken.one; } } --- 42,52 ---- OperandToken result = exp.evaluate(null); ! if(result instanceof LogicalToken) { ! if(((LogicalToken)result).getValue(0)) { ErrorLogger.debugLine("case is TRUE "); code.evaluate(null); ! return new LogicalToken(true); } } *************** *** 56,60 **** ErrorLogger.debugLine("case is DEFAULT "); code.evaluate(null); ! return NumberToken.one; } --- 56,60 ---- ErrorLogger.debugLine("case is DEFAULT "); code.evaluate(null); ! return new LogicalToken(true); } Index: WhileOperatorToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/WhileOperatorToken.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** WhileOperatorToken.java 26 Dec 2006 12:28:52 -0000 1.11 --- WhileOperatorToken.java 30 Jan 2007 19:55:52 -0000 1.12 *************** *** 37,40 **** --- 37,41 ---- ErrorLogger.debugLine("line = " + relationLine.toString()); OperandToken result = relationLine.evaluate(null); + if (result instanceof NumberToken) { *************** *** 69,77 **** { OperandToken codeLine = ((OperandToken)whileCode.clone()); ! ErrorLogger.debugLine("Parser: IfThen is true"); code = codeLine.evaluate(null); } } ! } // end while return null; --- 70,98 ---- { OperandToken codeLine = ((OperandToken)whileCode.clone()); ! ErrorLogger.debugLine("Parser: while number is true"); code = codeLine.evaluate(null); } } ! else if (result instanceof LogicalToken) ! { ! boolean cond = ((LogicalToken)result).getValue(0); ! ! // if condition is false, then break while loop ! if (!cond) break; ! ! /* evaluate code */ ! OperandToken code; ! if (cond) ! { ! OperandToken codeLine = ((OperandToken)whileCode.clone()); ! ErrorLogger.debugLine("Parser: while boolean is true"); ! code = codeLine.evaluate(null); ! } ! ! } ! else ! Errors.throwMathLibException("While: unknown token"); ! ! } // end while return null; Index: LogicalToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/LogicalToken.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LogicalToken.java 22 Jan 2007 19:18:38 -0000 1.3 --- LogicalToken.java 30 Jan 2007 19:55:52 -0000 1.4 *************** *** 584,587 **** --- 584,608 ---- */ + /**calculate the transpose of an array + @return the result as an OperandToken*/ + public OperandToken transpose() + { + // transposed array + boolean[][] b = new boolean[sizeX][sizeY]; + + // swap rows and columns + for (int y=0; y<sizeY; y++) + { + for (int x=0; x<sizeX; x++) + { + int n = yx2n(y,x); + // copy (y,x) -> (x,y) + b[x][y] = values[n]; + } + } + return new LogicalToken(b); + } + + /**@return true if this number token is a scalar (1*1 matrix)*/ public boolean isScalar() |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:55:26
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv9292/Source/MathLib/Tools/TestSuite/Tokens Modified Files: TestUnaryOperatorToken.java Log Message: support of logical tokens Index: TestUnaryOperatorToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Tokens/TestUnaryOperatorToken.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestUnaryOperatorToken.java 3 Dec 2006 17:41:12 -0000 1.4 --- TestUnaryOperatorToken.java 30 Jan 2007 19:55:13 -0000 1.5 *************** *** 13,19 **** --- 13,21 ---- super(name); } + public static void main (String[] args) { MathLib.Tools.junit.textui.TestRunner.run (suite()); } + protected void setUp() { ml = new Interpreter(true); *************** *** 51,84 **** public void test300() { ml.executeExpression("!4"); ! assertTrue(0.0 == ml.getScalarValueRe("ans")); } public void test301() { ml.executeExpression("!0"); ! assertTrue(1.0 == ml.getScalarValueRe("ans")); } public void test302() { ml.executeExpression("~4"); ! assertTrue(0.0 == ml.getScalarValueRe("ans")); } public void test303() { ml.executeExpression("~0"); ! assertTrue(1.0 == ml.getScalarValueRe("ans")); } public void test310() { ml.executeExpression("!(2<3)"); ! assertTrue(0.0 == ml.getScalarValueRe("ans")); } public void test311() { ml.executeExpression("!(2>3)"); ! assertTrue(1.0 == ml.getScalarValueRe("ans")); } public void test312() { ml.executeExpression("~(2<3)"); ! assertTrue(0.0 == ml.getScalarValueRe("ans")); } public void test313() { ml.executeExpression("~(2>3)"); ! assertTrue(1.0 == ml.getScalarValueRe("ans")); } --- 53,86 ---- public void test300() { ml.executeExpression("!4"); ! assertTrue(!ml.getScalarValueBoolean("ans")); } public void test301() { ml.executeExpression("!0"); ! assertTrue(ml.getScalarValueBoolean("ans")); } public void test302() { ml.executeExpression("~4"); ! assertTrue(!ml.getScalarValueBoolean("ans")); } public void test303() { ml.executeExpression("~0"); ! assertTrue(ml.getScalarValueBoolean("ans")); } public void test310() { ml.executeExpression("!(2<3)"); ! assertTrue( !ml.getScalarValueBoolean("ans")); } public void test311() { ml.executeExpression("!(2>3)"); ! assertTrue(ml.getScalarValueBoolean("ans")); } public void test312() { ml.executeExpression("~(2<3)"); ! assertTrue( !ml.getScalarValueBoolean("ans")); } public void test313() { ml.executeExpression("~(2>3)"); ! assertTrue( ml.getScalarValueBoolean("ans")); } *************** *** 92,96 **** ml.executeExpression("c=y(a)"); assertTrue(77.0 == ml.getScalarValueRe("b")); ! assertTrue(2.0 == ml.getScalarValueRe("a")); assertTrue(22.0 == ml.getScalarValueRe("c")); } --- 94,98 ---- ml.executeExpression("c=y(a)"); assertTrue(77.0 == ml.getScalarValueRe("b")); ! assertTrue( 2.0 == ml.getScalarValueRe("a")); assertTrue(22.0 == ml.getScalarValueRe("c")); } *************** *** 105,109 **** ml.executeExpression("c=y(a)"); assertTrue(88.0 == ml.getScalarValueRe("b")); ! assertTrue(3.0 == ml.getScalarValueRe("a")); assertTrue(33.0 == ml.getScalarValueRe("c")); } --- 107,111 ---- ml.executeExpression("c=y(a)"); assertTrue(88.0 == ml.getScalarValueRe("b")); ! assertTrue( 3.0 == ml.getScalarValueRe("a")); assertTrue(33.0 == ml.getScalarValueRe("c")); } |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:53:09
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7986/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: testChol.java testAdjoint.java Log Message: support of logical tokens Index: testAdjoint.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testAdjoint.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testAdjoint.java 31 Oct 2004 16:13:40 -0000 1.1 --- testAdjoint.java 30 Jan 2007 19:52:54 -0000 1.2 *************** *** 24,29 **** /****** not() ************************************************************/ public void testNot01() { ! ml.executeExpression("a=not(1);"); assertTrue(0 == ml.getScalarValueRe("a")); } public void testNot02() { --- 24,30 ---- /****** not() ************************************************************/ public void testNot01() { ! ml.executeExpression("a=adjoint(3);"); assertTrue(0 == ml.getScalarValueRe("a")); + assertTrue(3 == ml.getScalarValueIm("a")); } public void testNot02() { Index: testChol.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testChol.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testChol.java 31 Oct 2004 16:13:39 -0000 1.1 --- testChol.java 30 Jan 2007 19:52:54 -0000 1.2 *************** *** 25,42 **** public void testNot01() { ml.executeExpression("a=not(1);"); ! assertTrue(0 == ml.getScalarValueRe("a")); } public void testNot02() { ml.executeExpression("a=not(0)"); ! assertTrue(1 == ml.getScalarValueRe("a")); } public void testNot03() { double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! double[][] b = {{0.0, 0.0, 0.0},{ 0.0, 1.0, 1.0},{ 0.0, 0.0, 1.0}}; ! double[][] c = {{0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0}}; ! ml.setArray("a", a, c); ml.executeExpression("z = not(a)"); ! assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("z"))); ! assertTrue(Compare.ArrayEquals(c, ml.getArrayValueIm("z"))); } --- 25,40 ---- public void testNot01() { ml.executeExpression("a=not(1);"); ! assertTrue(!ml.getScalarValueBoolean("a")); } public void testNot02() { ml.executeExpression("a=not(0)"); ! assertTrue(ml.getScalarValueBoolean("a")); } public void testNot03() { double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! boolean[][] b = {{false, false, false},{ false, true, true},{ false,false, true}}; ! ml.setArray("a", a, null); ml.executeExpression("z = not(a)"); ! assertTrue(Compare.ArrayEquals(b, ml.getArrayValueBoolean("z"))); } |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:49:04
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6222/Source/MathLib/Tokens Modified Files: ForOperatorToken.java Log Message: added support for logical tokens Index: ForOperatorToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/ForOperatorToken.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ForOperatorToken.java 26 Dec 2006 12:28:12 -0000 1.11 --- ForOperatorToken.java 30 Jan 2007 19:48:57 -0000 1.12 *************** *** 76,80 **** // Check condition of For(...) OperandToken relationLine = ((OperandToken)forRelation.clone()); ! OperandToken result = relationLine.evaluate(null); if (result instanceof NumberToken) { --- 76,81 ---- // Check condition of For(...) OperandToken relationLine = ((OperandToken)forRelation.clone()); ! OperandToken result = relationLine.evaluate(null); ! if (result instanceof NumberToken) { *************** *** 108,112 **** { OperandToken codeLine = ((OperandToken)forCode.clone()); ! ErrorLogger.debugLine("Parser: IfThen is true"); code = codeLine.evaluate(null); --- 109,113 ---- { OperandToken codeLine = ((OperandToken)forCode.clone()); ! ErrorLogger.debugLine("Parser: for number is true"); code = codeLine.evaluate(null); *************** *** 116,119 **** --- 117,144 ---- } } + else if (result instanceof LogicalToken) + { + boolean cond = ((LogicalToken)result).getValue(0); + + // if condition is false, then break while loop + if (!cond) break; + + /* evaluate code */ + OperandToken code; + if (cond) + { + OperandToken codeLine = ((OperandToken)forCode.clone()); + ErrorLogger.debugLine("Parser: for boolean is true"); + code = codeLine.evaluate(null); + + //evaluate increment code + OperandToken incrementLine = ((OperandToken)forIncrement.clone()); + incrementLine.evaluate(null); + } + + } + else + Errors.throwMathLibException("For: unknown token"); + } // end while } |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:48:16
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5798 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** ChangeLog.txt 28 Jan 2007 17:56:48 -0000 1.160 --- ChangeLog.txt 30 Jan 2007 19:48:08 -0000 1.161 *************** *** 38,41 **** --- 38,44 ---- stefan * + 2007/01/30 + stefan # Functions/Matrix/not.java fixed wrong evaluation of numbers + 2007/01/21 stefan * Tokens/RelationOperatorToken.java now returning LogicalTokens |
|
From: Stefan M. <st_...@us...> - 2007-01-30 19:47:25
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5767/Source/MathLib/Functions/Matrix Modified Files: not.java Log Message: bugfix for not Index: not.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/Matrix/not.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** not.java 21 Jan 2007 16:21:34 -0000 1.7 --- not.java 30 Jan 2007 19:47:18 -0000 1.8 *************** *** 23,40 **** int n = num.getNumberOfElements(); ! double[] values = new double[n]; for (int i=0; i<n ; i++) { if (num.getValueRe(i) != 0.0) { ! values[i] = 1.0; } else { ! values[i] = 0.0; } } ! return new NumberToken(num.getSize(), values, null); } else if (operands[0] instanceof LogicalToken) --- 23,43 ---- int n = num.getNumberOfElements(); ! boolean[] values = new boolean[n]; for (int i=0; i<n ; i++) { + if (num.getValueIm(i)!=0.0) + throwMathLibException("not: only works on REAL numbers"); + if (num.getValueRe(i) != 0.0) { ! values[i] = false; } else { ! values[i] = true; } } ! return new LogicalToken(num.getSize(), values); } else if (operands[0] instanceof LogicalToken) *************** *** 69,77 **** @NOTES @EXAMPLES ! NOT([1,1;1,1]) = [0,0;0,0] ! NOT([0,1,2]) = [1,0,0] @SEE and, or, xor - */ --- 72,82 ---- @NOTES @EXAMPLES ! <programlisting> ! not([false, true]) = [true, false] ! not([1,1;1,1]) = [0,0;0,0] ! not([0,1,2]) = [1,0,0] ! </programlisting> @SEE and, or, xor */ |
|
From: Stefan M. <st_...@us...> - 2007-01-29 20:04:52
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1879/Source/MathLib/Tools/TestSuite/Tokens Modified Files: TestRelationOperatorToken.java Log Message: changed return values to boolean or boolean[][] Index: TestRelationOperatorToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Tokens/TestRelationOperatorToken.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestRelationOperatorToken.java 21 Nov 2004 19:09:32 -0000 1.2 --- TestRelationOperatorToken.java 29 Jan 2007 20:04:30 -0000 1.3 *************** *** 27,50 **** public void test001a() { ml.executeExpression("a=(2<3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test001b() { ml.executeExpression("a=(3<2)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test001c() { ml.executeExpression("a=([1,2,3,4]<3)"); ! double[][] r = {{1,1,0,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test001d() { ml.executeExpression("a=(3<[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{0,0,0,1},{0,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test001e() { ml.executeExpression("a=([3,1; 1,4]<[1,2; 3,4])"); ! double[][] r = {{0,1},{1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 27,50 ---- public void test001a() { ml.executeExpression("a=(2<3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test001b() { ml.executeExpression("a=(3<2)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test001c() { ml.executeExpression("a=([1,2,3,4]<3)"); ! boolean[][] r = {{true,true,false,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test001d() { ml.executeExpression("a=(3<[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{false,false,false,true},{false,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test001e() { ml.executeExpression("a=([3,1; 1,4]<[1,2; 3,4])"); ! boolean[][] r ={{false,true},{true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 52,75 **** public void test002a() { ml.executeExpression("a=(5>4)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test002b() { ml.executeExpression("a=(1>2)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test002c() { ml.executeExpression("a=([4,2,3,4]>3)"); ! double[][] r = {{1,0,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test002d() { ml.executeExpression("a=(3>[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{1,1,0,0},{1,0,0,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test002e() { ml.executeExpression("a=([3,1; 1,4]>[1,2; 3,4])"); ! double[][] r = {{1,0},{0,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 52,75 ---- public void test002a() { ml.executeExpression("a=(5>4)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test002b() { ml.executeExpression("a=(1>2)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test002c() { ml.executeExpression("a=([4,2,3,4]>3)"); ! boolean[][] r = {{true,false,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test002d() { ml.executeExpression("a=(3>[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{true,true,false,false},{true,false,false,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test002e() { ml.executeExpression("a=([3,1; 1,4]>[1,2; 3,4])"); ! boolean[][] r = {{true,false},{false,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 77,104 **** public void test003a() { ml.executeExpression("a=(2<=3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test003b() { ml.executeExpression("a=(3<=2)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test003bb() { ml.executeExpression("a=(3<=3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test003c() { ml.executeExpression("a=([1,2,3,4]<=3)"); ! double[][] r = {{1,1,1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test003d() { ml.executeExpression("a=(3<=[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{0,0,1,1},{0,1,1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test003e() { ml.executeExpression("a=([3,1; 1,4]<=[1,2; 3,4])"); ! double[][] r = {{0,1},{1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 77,104 ---- public void test003a() { ml.executeExpression("a=(2<=3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test003b() { ml.executeExpression("a=(3<=2)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test003bb() { ml.executeExpression("a=(3<=3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test003c() { ml.executeExpression("a=([1,2,3,4]<=3)"); ! boolean[][] r = {{true,true,true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test003d() { ml.executeExpression("a=(3<=[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{false,false,true,true},{false,true,true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test003e() { ml.executeExpression("a=([3,1; 1,4]<=[1,2; 3,4])"); ! boolean[][] r = {{false,true},{true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 106,133 **** public void test004a() { ml.executeExpression("a=(4>=3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test004b() { ml.executeExpression("a=(1>=2)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test004bb() { ml.executeExpression("a=(2>=2)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test004c() { ml.executeExpression("a=([1,2,3,4]>=3)"); ! double[][] r = {{0,0,1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test004d() { ml.executeExpression("a=(3>=[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{1,1,1,0},{1,0,1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } public void test004e() { ml.executeExpression("a=([3,1; 1,4]>=[1,2; 3,4])"); ! double[][] r = {{1,0},{0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 106,133 ---- public void test004a() { ml.executeExpression("a=(4>=3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test004b() { ml.executeExpression("a=(1>=2)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test004bb() { ml.executeExpression("a=(2>=2)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test004c() { ml.executeExpression("a=([1,2,3,4]>=3)"); ! boolean[][] r = {{false,false,true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test004d() { ml.executeExpression("a=(3>=[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{true,true,true,false},{true,false,true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test004e() { ml.executeExpression("a=([3,1; 1,4]>=[1,2; 3,4])"); ! boolean[][] r = {{true,false},{false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 135,158 **** public void test005a() { ml.executeExpression("a=(3==3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test005b() { ml.executeExpression("a=(3==2)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test005c() { ml.executeExpression("a=([1,2,3,4]==3)"); ! double[][] r = {{0,0,1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test005d() { ml.executeExpression("a=(3==[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{0,0,1,0},{0,0,1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test005e() { ml.executeExpression("a=([3,1; 3,4]==[1,2; 3,4])"); ! double[][] r = {{0,0},{1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 135,158 ---- public void test005a() { ml.executeExpression("a=(3==3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test005b() { ml.executeExpression("a=(3==2)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test005c() { ml.executeExpression("a=([1,2,3,4]==3)"); ! boolean[][] r = {{false,false,true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test005d() { ml.executeExpression("a=(3==[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{false,false,true,false},{false,false,true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test005e() { ml.executeExpression("a=([3,1; 3,4]==[1,2; 3,4])"); ! boolean[][] r = {{false,false},{true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 160,207 **** public void test006a() { ml.executeExpression("a=(2!=3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test006b() { ml.executeExpression("a=(3!=3)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test006c() { ml.executeExpression("a=([1,2,3,4]!=3)"); ! double[][] r = {{1,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test006d() { ml.executeExpression("a=(3!=[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{1,1,0,1},{1,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test006e() { ml.executeExpression("a=([3,1; 1,4]!=[1,2; 3,4])"); ! double[][] r = {{1,1},{1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } public void test006f() { ml.executeExpression("a=(2!=3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test006g() { ml.executeExpression("a=(3!=3)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test006h() { ml.executeExpression("a=([1,2,3,4]!=3)"); ! double[][] r = {{1,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test006i() { ml.executeExpression("a=(3!=[1,2,3,4; 2,4,3,4])"); ! double[][] r = {{1,1,0,1},{1,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test006j() { ml.executeExpression("a=([3,1; 1,4]!=[1,2; 3,4])"); ! double[][] r = {{1,1},{1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 160,207 ---- public void test006a() { ml.executeExpression("a=(2!=3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test006b() { ml.executeExpression("a=(3!=3)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test006c() { ml.executeExpression("a=([1,2,3,4]!=3)"); ! boolean[][] r = {{true,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test006d() { ml.executeExpression("a=(3!=[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{true,true,false,true},{true,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test006e() { ml.executeExpression("a=([3,1; 1,4]!=[1,2; 3,4])"); ! boolean[][] r = {{true,true},{true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test006f() { ml.executeExpression("a=(2!=3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test006g() { ml.executeExpression("a=(3!=3)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test006h() { ml.executeExpression("a=([1,2,3,4]!=3)"); ! boolean[][] r = {{true,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test006i() { ml.executeExpression("a=(3!=[1,2,3,4; 2,4,3,4])"); ! boolean[][] r = {{true,true,false,true},{true,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test006j() { ml.executeExpression("a=([3,1; 1,4]!=[1,2; 3,4])"); ! boolean[][] r = {{true,true},{true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 209,236 **** public void test007a() { ml.executeExpression("a=(0|3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test007aa() { ml.executeExpression("a=(3|0)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test007b() { ml.executeExpression("a=(0|0)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test007c() { ml.executeExpression("a=([1,2,3,4]|0)"); ! double[][] r = {{1,1,1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test007cc() { ml.executeExpression("a=([0,0,1,0]|0)"); ! double[][] r = {{0,0,1,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test007e() { ml.executeExpression("a=([0,0; 1,4]|[1,0; 0,1])"); ! double[][] r = {{1,0},{1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 209,236 ---- public void test007a() { ml.executeExpression("a=(0|3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test007aa() { ml.executeExpression("a=(3|0)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test007b() { ml.executeExpression("a=(0|0)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test007c() { ml.executeExpression("a=([1,2,3,4]|0)"); ! boolean[][] r = {{true,true,true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test007cc() { ml.executeExpression("a=([0,0,1,0]|0)"); ! boolean[][] r = {{false,false,true,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test007e() { ml.executeExpression("a=([0,0; 1,4]|[1,0; 0,1])"); ! boolean[][] r = {{true,false},{true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } *************** *** 238,266 **** public void test008a() { ml.executeExpression("a=(2&3)"); ! assertTrue(1.0 == ml.getScalarValueRe("a")); } public void test008b() { ml.executeExpression("a=(3&0)"); ! assertTrue(0.0 == ml.getScalarValueRe("a")); } public void test008c() { ml.executeExpression("a=([1,2,0,4]&3)"); ! double[][] r = {{1,1,0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test008d() { ml.executeExpression("a=(-4&[1,0,3,4; 0,0,3,4])"); ! double[][] r = {{1,0,1,1},{0,0,1,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test008dd() { ml.executeExpression("a=(0&[1,0,3,4; 0,0,3,4])"); ! double[][] r = {{0,0,0,0},{0,0,0,0}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"))); } public void test008e() { ml.executeExpression("a=([3,1; 0,5]&[0,0; 3,4])"); ! double[][] r = {{0,0},{0,1}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueRe("a"), 0.001)); } --- 238,266 ---- public void test008a() { ml.executeExpression("a=(2&3)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void test008b() { ml.executeExpression("a=(3&0)"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void test008c() { ml.executeExpression("a=([1,2,0,4]&3)"); ! boolean[][] r = {{true,true,false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test008d() { ml.executeExpression("a=(-4&[1,0,3,4; 0,0,3,4])"); ! boolean[][] r = {{true,false,true,true},{false,false,true,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test008dd() { ml.executeExpression("a=(0&[1,0,3,4; 0,0,3,4])"); ! boolean[][] r = {{false,false,false,false},{false,false,false,false}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } public void test008e() { ml.executeExpression("a=([3,1; 0,5]&[0,0; 3,4])"); ! boolean[][] r = {{false,false},{false,true}}; ! assertTrue(Compare.ArrayEquals(r, ml.getArrayValueBoolean("a"))); } |
|
From: Stefan M. <st_...@us...> - 2007-01-28 17:56:55
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5954 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** ChangeLog.txt 21 Jan 2007 16:23:41 -0000 1.159 --- ChangeLog.txt 28 Jan 2007 17:56:48 -0000 1.160 *************** *** 42,45 **** --- 42,46 ---- stefan * Tokens/ConditionToken.java added support for LogicalTokens stefan + Functions/General/bench.m + stefan * Interpreter/Interpreter.java reading boolean scalars/arrays 2007/01/20 |
|
From: Stefan M. <st_...@us...> - 2007-01-24 20:46:51
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21719/Source/MathLib/Tokens Modified Files: NumberToken.java Log Message: made constructor more saver Index: NumberToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/NumberToken.java,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** NumberToken.java 20 Jan 2007 15:26:33 -0000 1.104 --- NumberToken.java 24 Jan 2007 20:46:23 -0000 1.105 *************** *** 117,122 **** { super(5, "double"); ! sizeY = _real.length; ! sizeX = _real[0].length; sizeA = new int[]{sizeY, sizeX}; noElem = sizeY * sizeX; --- 117,131 ---- { super(5, "double"); ! if (_real!=null) ! { ! ! sizeY = _real.length; ! sizeX = _real[0].length; ! } ! else if(_imaginary!=null) ! { ! sizeY = _imaginary.length; ! sizeX = _imaginary[0].length; ! } sizeA = new int[]{sizeY, sizeX}; noElem = sizeY * sizeX; *************** *** 127,133 **** for(int yy = 0; yy < sizeY; yy++) { ! values[xx*sizeY+yy][REAL] = _real[yy][xx]; ! ! // imaginary number may be null if (_imaginary != null) values[xx*sizeY+yy][IMAG] = _imaginary[yy][xx]; --- 136,144 ---- for(int yy = 0; yy < sizeY; yy++) { ! if (_real != null) ! values[xx*sizeY+yy][REAL] = _real[yy][xx]; ! else ! values[xx*sizeY+yy][REAL] = 0; ! if (_imaginary != null) values[xx*sizeY+yy][IMAG] = _imaginary[yy][xx]; |
|
From: Stefan M. <st_...@us...> - 2007-01-24 20:46:38
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21751/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: TestSubAssign.java Log Message: Index: TestSubAssign.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/TestSubAssign.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TestSubAssign.java 16 Jul 2006 19:31:34 -0000 1.11 --- TestSubAssign.java 24 Jan 2007 20:46:35 -0000 1.12 *************** *** 253,266 **** public void testSubAssign130() { ! ml.executeExpression("clear(aaa)"); ! ml.executeExpression("aaa(1,3)=99"); double[][] bRe = {{0.0, 0.0, 99.0}}; ! assertTrue(Compare.ArrayEquals(bRe, ml.getArrayValueRe("aaa"))); } public void testSubAssign131() { ! ml.executeExpression("clear(aaa)"); ! ml.executeExpression("aaa(3)=999"); double[][] bRe = {{0.0, 0.0, 999.0}}; ! assertTrue(Compare.ArrayEquals(bRe, ml.getArrayValueRe("aaa"))); } public void testSubAssign133() { --- 253,266 ---- public void testSubAssign130() { ! ml.executeExpression("clear(aaaa)"); ! ml.executeExpression("aaaa(1,3)=99"); double[][] bRe = {{0.0, 0.0, 99.0}}; ! assertTrue(Compare.ArrayEquals(bRe, ml.getArrayValueRe("aaaa"))); } public void testSubAssign131() { ! ml.executeExpression("clear(aaaa)"); ! ml.executeExpression("aaaa(3)=999"); double[][] bRe = {{0.0, 0.0, 999.0}}; ! assertTrue(Compare.ArrayEquals(bRe, ml.getArrayValueRe("aaaa"))); } public void testSubAssign133() { |
|
From: Stefan M. <st_...@us...> - 2007-01-22 19:18:56
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tokens In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1207/Source/MathLib/Tokens Modified Files: LogicalToken.java Log Message: some bugfix Index: LogicalToken.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tokens/LogicalToken.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LogicalToken.java 21 Jan 2007 16:22:09 -0000 1.2 --- LogicalToken.java 22 Jan 2007 19:18:38 -0000 1.3 *************** *** 213,222 **** } ! /** return a new Number Token of size y*x * */ public DataToken getElementSized(int y, int x) { ! return new NumberToken(y, x, new double[y*x],null); } --- 213,222 ---- } ! /** * */ public DataToken getElementSized(int y, int x) { ! return new LogicalToken(y, x, new boolean[y*x]); } *************** *** 229,234 **** boolean[] newValues = new boolean[dy*dx]; ! ErrorLogger.debugLine("number "+dy+" "+dx); ! ErrorLogger.debugLine("number "+sizeY+" "+sizeX); // new array must be bigger than original value, otherwise values will be --- 229,234 ---- boolean[] newValues = new boolean[dy*dx]; ! ErrorLogger.debugLine("boolean "+dy+" "+dx); ! ErrorLogger.debugLine("boolean "+sizeY+" "+sizeX); // new array must be bigger than original value, otherwise values will be *************** *** 242,246 **** { int n = yx2n(yy,xx); ! ErrorLogger.debugLine("number "+yy+" "+xx); newValues[xx*dy + yy] = values[n]; } --- 242,246 ---- { int n = yx2n(yy,xx); ! ErrorLogger.debugLine("boolean "+yy+" "+xx); newValues[xx*dy + yy] = values[n]; } *************** *** 309,313 **** } ! /** Set value at position y, x * @param y = y position in matrix --- 309,334 ---- } ! /** ! * ! * @return ! */ ! public boolean[][] getValues() ! { ! boolean[][] temp = new boolean[sizeY][sizeX]; ! ! if ((sizeY==0) && (sizeX==0)) ! return null; ! ! for(int yy = 0; yy < sizeY; yy++) ! { ! for(int xx = 0; xx < sizeX; xx++) ! { ! int n = yx2n(yy,xx); ! temp[yy][xx] = values[n]; ! } ! } ! return temp; ! } ! /** Set value at position y, x * @param y = y position in matrix |
|
From: Stefan M. <st_...@us...> - 2007-01-21 17:17:49
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv5806/Source/MathLib/Tools/TestSuite/Functions/Matrix Modified Files: testGe.java TestAny.java testLt.java testGt.java testEq.java testNot.java testNe.java testLe.java Log Message: Index: testLe.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testLe.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testLe.java 5 Jan 2007 14:27:16 -0000 1.1 --- testLe.java 21 Jan 2007 17:17:43 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testLe01() { ml.executeExpression("a=le(5,5);"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void testLe02() { ml.executeExpression("b=le(5,6)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testLe03() { ml.executeExpression("b=le(6,5)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testLe04() { ml.executeExpression("b=le(0,0)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testLe05() { ! boolean[][] c = {{false, true},{true, true}}; 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.getArrayValueBoolean("z"))); } Index: testNot.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testNot.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testNot.java 28 May 2004 18:19:33 -0000 1.3 --- testNot.java 21 Jan 2007 17:17:43 -0000 1.4 *************** *** 25,42 **** public void testNot01() { ml.executeExpression("a=not(1);"); ! assertTrue(0 == ml.getScalarValueRe("a")); } public void testNot02() { ml.executeExpression("a=not(0)"); ! assertTrue(1 == ml.getScalarValueRe("a")); } public void testNot03() { double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! double[][] b = {{0.0, 0.0, 0.0},{ 0.0, 1.0, 1.0},{ 0.0, 0.0, 1.0}}; double[][] c = {{0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0}}; ml.setArray("a", a, c); ml.executeExpression("z = not(a)"); ! assertTrue(Compare.ArrayEquals(b, ml.getArrayValueRe("z"))); ! assertTrue(Compare.ArrayEquals(c, ml.getArrayValueIm("z"))); } --- 25,41 ---- public void testNot01() { ml.executeExpression("a=not(1);"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void testNot02() { ml.executeExpression("a=not(0)"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void testNot03() { double[][] a = {{1.0, 2.0, 3.0},{-1.0, 0.0, 0.0},{11.23, -1.5, 0.0}}; ! boolean[][] b = {{false, false, false},{false, true, true},{false, false, true}}; double[][] c = {{0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0},{ 0.0, 0.0, 0.0}}; ml.setArray("a", a, c); ml.executeExpression("z = not(a)"); ! assertTrue(Compare.ArrayEquals(b, ml.getArrayValueBoolean("z"))); } Index: testEq.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testEq.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testEq.java 5 Jan 2007 14:27:02 -0000 1.1 --- testEq.java 21 Jan 2007 17:17:43 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testEq01() { ml.executeExpression("a=eq(5,5);"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void testEq02() { ml.executeExpression("b=eq(5,6)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testEq03() { ml.executeExpression("b=eq(6,5)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testEq04() { ml.executeExpression("b=eq(0,0)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testEq05() { ! boolean[][] c = {{false, false},{true, false}}; 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.getArrayValueBoolean("z"))); } Index: testNe.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testNe.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testNe.java 5 Jan 2007 14:26:44 -0000 1.1 --- testNe.java 21 Jan 2007 17:17:43 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testNe01() { ml.executeExpression("a=ne(5,5);"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void testNe02() { ml.executeExpression("b=ne(5,6)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testNe03() { ml.executeExpression("b=ne(6,5)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testNe04() { ml.executeExpression("b=ne(0,0)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testNe05() { ! boolean[][] c = {{true, true},{false, true}}; 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.getArrayValueBoolean("z"))); } Index: testGe.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testGe.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testGe.java 5 Jan 2007 14:27:15 -0000 1.1 --- testGe.java 21 Jan 2007 17:17:42 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testGe01() { ml.executeExpression("a=ge(5,5);"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void testGe02() { ml.executeExpression("b=ge(5,6)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testGe03() { ml.executeExpression("b=ge(6,5)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testGe04() { ml.executeExpression("b=eq(0,0)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testGe05() { ! boolean[][] c = {{true, false},{true, false}}; 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.getArrayValueBoolean("z"))); } Index: testLt.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testLt.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testLt.java 5 Jan 2007 14:27:16 -0000 1.1 --- testLt.java 21 Jan 2007 17:17:43 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testLt01() { ml.executeExpression("a=lt(5,5);"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void testLt02() { ml.executeExpression("b=lt(5,6)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testLt03() { ml.executeExpression("b=lt(6,5)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testLt04() { ml.executeExpression("b=lt(0,0)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testLt05() { ! boolean[][] c = {{false, true},{false, true}}; 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.getArrayValueBoolean("z"))); } Index: TestAny.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/TestAny.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestAny.java 23 May 2004 10:41:49 -0000 1.2 --- TestAny.java 21 Jan 2007 17:17:43 -0000 1.3 *************** *** 24,32 **** public void testAny01() { ml.executeExpression("a=any(1.123);"); ! assertTrue(1 == ml.getScalarValueRe("a")); } public void testAny02() { ml.executeExpression("b=any(0.0)"); ! assertTrue(0 == ml.getScalarValueRe("b")); } public void testAny03() { --- 24,32 ---- public void testAny01() { ml.executeExpression("a=any(1.123);"); ! assertTrue(true == ml.getScalarValueBoolean("a")); } public void testAny02() { ml.executeExpression("b=any(0.0)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testAny03() { *************** *** 35,39 **** ml.setArray("a", a, b); ml.executeExpression("z = any(a)"); ! assertTrue(1 == ml.getScalarValueRe("z")); } public void testAny04() { --- 35,39 ---- ml.setArray("a", a, b); ml.executeExpression("z = any(a)"); ! assertTrue(true == ml.getScalarValueBoolean("z")); } public void testAny04() { *************** *** 41,45 **** ml.setArray("e", a, a); ml.executeExpression("z = any(e)"); ! assertTrue(0 == ml.getScalarValueRe("z")); } --- 41,45 ---- ml.setArray("e", a, a); ml.executeExpression("z = any(e)"); ! assertTrue(false == ml.getScalarValueBoolean("z")); } Index: testGt.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Functions/Matrix/testGt.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testGt.java 5 Jan 2007 14:27:16 -0000 1.1 --- testGt.java 21 Jan 2007 17:17:43 -0000 1.2 *************** *** 25,52 **** 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"))); } --- 25,52 ---- public void testGt01() { ml.executeExpression("a=gt(5,5);"); ! assertTrue(false == ml.getScalarValueBoolean("a")); } public void testGt02() { ml.executeExpression("b=gt(5,6)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testGt03() { ml.executeExpression("b=gt(6,5)"); ! assertTrue(true == ml.getScalarValueBoolean("b")); } public void testGt04() { ml.executeExpression("b=gt(0,0)"); ! assertTrue(false == ml.getScalarValueBoolean("b")); } public void testGt05() { ! boolean[][] c = {{true, false},{false, false}}; 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.getArrayValueBoolean("z"))); } |
|
From: Stefan M. <st_...@us...> - 2007-01-21 17:12:53
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3281/Source/MathLib/Interpreter Modified Files: Interpreter.java Log Message: reading boolean values/arrays Index: Interpreter.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Interpreter/Interpreter.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** Interpreter.java 6 Jan 2007 15:01:35 -0000 1.67 --- Interpreter.java 21 Jan 2007 17:12:44 -0000 1.68 *************** *** 266,269 **** --- 266,294 ---- } + /** + * + * @param name + * @return + */ + public boolean getScalarValueBoolean(String name) + { + // get variable from variable list + OperandToken variableData = getVariables().getVariable(name).getData(); + + // check if variable is already set + if (variableData == null) return false; + + // check if data is a LogicalToken + if (!(variableData instanceof LogicalToken)) return false; + + // cast to number token + LogicalToken l = (LogicalToken)(variableData.clone()); + + if (l.isScalar()) + return l.getValue(0); + else + return false; + } + /**get the real values of a an array @param name = name of the array *************** *** 271,276 **** public double[][] getArrayValueRe(String name) { - double[][] retVal = null; - // get variable from variable list OperandToken variableData = getVariables().getVariable(name).getData(); --- 296,299 ---- *************** *** 293,298 **** public double[][] getArrayValueIm(String name) { - double[][] retVal = null; - // get variable from variable list OperandToken variableData = getVariables().getVariable(name).getData(); --- 316,319 ---- *************** *** 309,318 **** return number.getValuesIm(); } ! /** store a scalar variable in mathlib's workspace ! @param name = name of the scalar ! @param valueRe = real value of the scalar ! @param valueIM = imaginary value of the scalar ! */ public void setScalar(String name, double valueRe, double valueIm) { --- 330,361 ---- return number.getValuesIm(); } ! ! /** ! * ! * @param name ! * @return ! */ ! public boolean[][] getArrayValueBoolean(String name) ! { ! // get variable from variable list ! OperandToken variableData = getVariables().getVariable(name).getData(); ! ! // check if variable is already set ! if (variableData == null) return null; ! ! // check if data is a NumberToken ! if (!(variableData instanceof LogicalToken)) return null; ! ! // cast to logical token ! LogicalToken l = (LogicalToken)(variableData.clone()); ! ! return l.getValues(); ! } ! /** store a scalar variable in mathlib's workspace ! * @param name = name of the scalar ! * @param valueRe = real value of the scalar ! * @param valueIM = imaginary value of the scalar ! */ public void setScalar(String name, double valueRe, double valueIm) { |
|
From: Stefan M. <st_...@us...> - 2007-01-21 17:06:05
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30922/Source/MathLib/Tools/TestSuite Modified Files: Compare.java Log Message: support for checking arrays of type boolean Index: Compare.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Tools/TestSuite/Compare.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Compare.java 8 May 2004 18:04:06 -0000 1.3 --- Compare.java 21 Jan 2007 17:05:57 -0000 1.4 *************** *** 37,39 **** --- 37,64 ---- } + /**compare two dimensional boolean arrays*/ + public static boolean ArrayEquals(boolean[][] a, boolean[][] b) + { + // number of rows must be greater 0 and equal + if (a.length < 1) return false; + if (b.length < 1) return false; + if (a.length != b.length) return false; + + // check all elements + for (int y=0; y<a.length; y++) + { + // length of each row must be equal + if (a[y].length != b[y].length) return false; + + // check individual elements + for (int x=0; x<a[y].length; x++) + { + if (a[y][x] != b[y][x]) return false; + } + } + + // arrays are equal + return true; + } + } |
|
From: Stefan M. <st_...@us...> - 2007-01-21 16:23:49
|
Update of /cvsroot/mathlib/mathlib In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3703 Modified Files: ChangeLog.txt Log Message: Index: ChangeLog.txt =================================================================== RCS file: /cvsroot/mathlib/mathlib/ChangeLog.txt,v retrieving revision 1.158 retrieving revision 1.159 diff -C2 -d -r1.158 -r1.159 *** ChangeLog.txt 21 Jan 2007 13:54:27 -0000 1.158 --- ChangeLog.txt 21 Jan 2007 16:23:41 -0000 1.159 *************** *** 9,14 **** ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! angle.java, beta.m, betaln.m, center.m, cloglog.m, close.java, compan.m, ! complement.m, cov.m, createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, eq.m, false.m, gammaln.m, ge.m, gray2ind.m, gray.m, --- 9,14 ---- ---- Functional Changes: version 0.7.0 -> 0.x.x ------------------------------ New functions: ! angle.java, bench.m, beta.m, betaln.m, center.m, cloglog.m, close.java, ! compan.m, complement.m, cov.m, createnewfile.java, cumprod.java, cumsum.m, create_set.m, conj.java, delete.java, det.m, dot.m, eq.m, false.m, gammaln.m, ge.m, gray2ind.m, gray.m, *************** *** 41,44 **** --- 41,45 ---- stefan * Tokens/RelationOperatorToken.java now returning LogicalTokens stefan * Tokens/ConditionToken.java added support for LogicalTokens + stefan + Functions/General/bench.m 2007/01/20 |