complex number support added

This commit is contained in:
serso
2011-09-18 00:08:04 +04:00
parent c99dd57e60
commit 898ac936df
16 changed files with 458 additions and 143 deletions

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com
*/
package org.solovyev.util.math;
import org.jetbrains.annotations.Nullable;
/**
* User: serso
* Date: 9/17/11
* Time: 11:35 PM
*/
public class Complex {
@Nullable
private String real, imag;
@Nullable
public String getReal() {
return real;
}
public void setReal(@Nullable String real) {
this.real = real;
}
@Nullable
public String getImag() {
return imag;
}
public void setImag(@Nullable String imag) {
this.imag = imag;
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com
*/
package org.solovyev.util.math;
import org.jetbrains.annotations.NonNls;
import java.util.Arrays;
import java.util.List;
/**
* User: serso
* Date: 9/17/11
* Time: 10:01 PM
*/
public interface Functions {
String SIN = "sin";
String SINH = "sinh";
String ASIN = "asin";
String ASINH = "asinh";
String COS = "cos";
String COSH = "cosh";
String ACOS = "acos";
String ACOSH = "acosh";
String TAN = "tan";
String TANH = "tanh";
String ATAN = "atan";
String ATANH = "atanh";
String LOG = "log";
String LN = "ln";
String MOD = "mod";
String EXP = "exp";
String SQRT_SIGN = "";
String SQRT = "sqrt";
public static final List<String> all = Arrays.asList(SIN, SINH, ASIN, ASINH, COS, COSH, ACOS, ACOSH, TAN, TANH, ATAN, ATANH, LOG, LN, MOD, SQRT, SQRT_SIGN, EXP);
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com
*/
package org.solovyev.util.math;
import org.jetbrains.annotations.NotNull;
public enum MathEntity {
minus("-"),
equals("="),
factorial("!"),
plus("+"),
multiply("*"),
divide("/"),
power("^"),
sin("sin"),
asin("asin"),
cos("cos"),
acos("acos"),
tg("tg"),
atg("atg"),
exp("exp"),
log("log"),
ln("ln"),
mod("mod"),
sqrt("sqrt");
@NotNull
private final String text;
private MathEntity (@NotNull String text) {
this.text = text;
}
@NotNull
public String getText() {
return text;
}
}

View File

@@ -24,7 +24,7 @@ public enum MathEntityType {
group_symbols,
group_symbol;
public static final List<Character> constants = Arrays.asList('e', 'π');
public static final List<Character> constants = Arrays.asList('e', 'π', 'i');
public static final List<Character> dots = Arrays.asList('.', ',');
@@ -32,8 +32,8 @@ public enum MathEntityType {
public static final List<Character> binaryOperations = Arrays.asList('-', '+', '*', '×', '∙', '/', '^' );
public static final List<String> functions = Arrays.asList("sin", "asin", "cos", "acos", "tg", "atg", "log", "ln", "mod", "");
public static final List<String> functions = Functions.all;
public static final List<String> groupSymbols = Arrays.asList("[]", "()", "{}");
public static final List<Character> openGroupSymbols = Arrays.asList('[', '(', '{');