Navigation Menu

Skip to content

Commit

Permalink
Issue axkr#18: Setting for disabling lazy evaluation of multiplication
Browse files Browse the repository at this point in the history
see especially MainTestCase#testGithub18() test case
  • Loading branch information
tranleduy2000 committed Mar 15, 2018
1 parent b88a3fc commit 01afa64
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 67 deletions.
Expand Up @@ -11,7 +11,7 @@
* Tests LaTeX export function
*/
public class BasicTeXTestCase extends TestCase {

TeXUtilities texUtil;

public BasicTeXTestCase(String name) {
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testTeX013() {

public void testTeX014() {
check("Sin(x)^2", "{\\sin(x)}^{2}");
check("Sin(2x)^2", "{\\sin(2\\,x)}^{2}");
check("Sin(2*x)^2", "{\\sin(2\\,x)}^{2}");
}

public void testTeX015() {
Expand All @@ -97,7 +97,7 @@ public void testTeX015() {
check("Complex(-a, -1)", " - a - \\imag");
check("Complex(a, -b)", "a - b\\,\\imag");
check("Complex(a, b)", "a + b\\,\\imag");
check("Complex(3/4,-(6/7)*I)", "\\frac{3}{4}+\\frac{6}{7}");
check("Complex(3/4,-(6/7)*I)", "\\frac{3}{4}+\\frac{6}{7}");
check("3/4-(6/7)*I", "\\frac{3}{4}-\\frac{6}{7}\\,i ");
check("1+2*I", "1+2\\,i ");
check("1-2*I", "1-2\\,i ");
Expand All @@ -112,59 +112,59 @@ public void testTeX015() {
public void testTeX016() {
check("(a*d+b*c)*d^(-1)*f^(-1)", "\\frac{b\\,c+a\\,d}{d\\,f}");
}

public void testTeX017() {
check("1/4*d^(-1)*f^(-1)", "\\frac{1}{4\\,d\\,f}");
}

public void testTeX018() {
check("1/4*a^2*b^(-1)*f^(-1)", "\\frac{a^{2}}{4\\,b\\,f}");
}

public void testTeX019() {
check("n!", "n ! ");
check("n!!", "n !! ");
}

public void testTeX020() {
check("Hold(++x)", "\\text{Hold}(\\text{++}x)");
check("Hold(y^2/.x->3)", "\\text{Hold}(y^{2}\\text{/.}\\,x\\to 3)");
check("Hold(y^2//.x->3)", "\\text{Hold}(y^{2}\\text{//.}\\,x\\to 3)");
check("Hold(1 * 5 * x + 1 * 63)", "\\text{Hold}(5\\,x+63)");
check("10*f(x)", "10\\,f(x)");
check("Hold((5*3)/2)", "\\text{Hold}(\\frac{3\\cdot 5}{2})");
check("Integrate(8+5x, {x, 5, 10})", "\\int_{5}^{10} 8+5\\,x\\,\\mathrm{d}x");
check("Integrate(8+5*x, {x, 5, 10})", "\\int_{5}^{10} 8+5\\,x\\,\\mathrm{d}x");
}

public void testTeX021() {
check("-Infinity", " - \\infty");
check("GoldenRatio", "\\phi");
check("Infinity", "\\infty");

check("EulerGamma", "\\gamma");
check("Pi", "\\pi");
// check("E", "E");
// check("Catalan", "");
// check("Degree", "");
//
//
//
//
// check("Glaisher", "");
// check("I", "");
//
//
// check("Khinchin", "");

}

public void testTeX022() {
// issue #116
check("-I*1/2*Sqrt(2)", "\\frac{\\left( -1\\,i \\right) \\,\\sqrt{2}}{2}");
}

public void testTeX023() {
// issue #117
check("5*3^(5*x)*Log(3)", "5\\cdot 3^{5\\,x}\\,\\log(3)");
}

public void check(String strEval, String strResult) {
StringWriter stw = new StringWriter();
texUtil.toTeX(strEval, stw);
Expand All @@ -186,4 +186,4 @@ protected void setUp() {
}
}

}
}
@@ -1,15 +1,15 @@
package org.matheclipse.core.basic;

import java.util.HashSet;
import java.util.Set;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import org.hipparchus.util.Precision;
import org.matheclipse.core.eval.EvalEngine;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.core.interfaces.ISymbol;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.HashSet;
import java.util.Set;

/**
* General configuration settings.
Expand Down Expand Up @@ -164,40 +164,9 @@ public static boolean isFileSystemEnabled(EvalEngine engine) {
}

/**
* <p>
* If <code>true</code> the <code>*</code> operator must be written for a <code>Times()</code> expression. I.e. you
* cannot write <code>2(b+c)</code> anymore, but have to write <code>2*(b+c)</code> to get
* <code>Times(2, Plus(b, c))</code>.
* </p>
* <p>
* You also enable <a href="https://en.wikipedia.org/wiki/Scientific_notation#E-notation">scientific E-notation</a>.
* I.e. <code>1E-2</code> is converted to a double value <code>0.01</code> for floating point numbers and not parsed
* as <code>Plus(-2, E)</code> anymore.
* </p>
* <p>
* You also enable integer literal input with a prefix, similar to
* <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html">Java integer literals</a>
* <ul>
* <li><code>0b</code> or <code>0B</code> for binary numbers</li>
* <li><code>0x</code> or <code>0X</code> for hexadecimal numbers</li>
* <li><code>0o</code> or <code>0O</code> for octal numbers</li>
* </ul>
* </p>
* <p>
*
* </p>
* <p>
* If <code>true</code> the <code>*</code> operator must be written for a <code>Times()</code> expression.
*/
public static boolean EXPLICIT_TIMES_OPERATOR = false;


/**
* <p>
* If <code>true</code> the implicit <code>*</code> operator has a higher precedence than all other operators. I.e.
* <code>1/2Pi</code> is parsed as <code>Power(Times(2, Pi), -1)</code>. If <code>false</code> the implicit
* <code>*</code> operator has a normal precedence as in all other cases. I.e. <code>1/2Pi</code> is parsed as
* <code>Times(Rational(1,2), Pi)</code>.
* </p>
*/
public static boolean DOMINANT_IMPLICIT_TIMES = false;
}
@@ -1,11 +1,5 @@
package org.matheclipse.core.expression;

import java.io.Externalizable;
import java.math.BigInteger;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import org.apfloat.Apcomplex;
import org.apfloat.Apfloat;
import org.hipparchus.util.ArithmeticUtils;
Expand All @@ -24,6 +18,12 @@
import org.matheclipse.core.visit.IVisitorInt;
import org.matheclipse.core.visit.IVisitorLong;

import java.io.Externalizable;
import java.math.BigInteger;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import edu.jas.arith.PrimeInteger;

/**
Expand Down Expand Up @@ -445,7 +445,7 @@ public IASTAppendable factorInteger() {
/**
* Get all prime factors of this integer
*
* @param result
* param result
* add the prime factors to this result list
* @return
*/
Expand Down Expand Up @@ -884,7 +884,7 @@ public IExpr times(final IExpr that) {
if (that instanceof ComplexSym) {
return ((ComplexSym) that).multiply(ComplexSym.valueOf(this)).normalize();
}
return IInteger.super.times(that);
return super.times(that);
}

@Override
Expand Down
Expand Up @@ -143,11 +143,6 @@ public int hashCode() {
return fOrdinal;
}

/** {@inheritDoc} */
@Override
public int ordinal() {
return fOrdinal;
}
@Override
final public boolean isBuiltInSymbol() {
return true;
Expand Down

0 comments on commit 01afa64

Please sign in to comment.