Do you remember all kinds of complicated mathematical formulas in the school days ?sin、log2、tan And so on. , If I see this, I think it's troublesome ?
adopt MXReflection frame , You can use Java Computing these mathematical operations and functions that we once thought were extremely complex , Just use the fields related to the class .
MXReflection You can read the value from the specified field , And inject the results into the @Expression Comment fields .
<dependency> |
So how to use this framework ?
It's simple , Only two... Are needed java notes .
1、 adopt @Arg value , We can specify the name of the custom parameter to be used in the objective function .
2、@Expression Comment values contain function expressions with arguments .
It's not hard to use this framework , Here are two calculation cases , It's easy to understand how to use this framework through cases :
Case study 1
public class Example1Test { |
Output:
Field 3 result: -34.32819235851987 |
Case study 2
|
Output:
Field 3 result: 2.8 |
MXReflection Framework support mXparser The math set provided in the math library is as follows :
- Operators (+, -, *, /, #, !, ^)
- Binary Relations (=, ==, =<, =>, <, >, <>, !=, ~=)
- Boolean Operators (&, &&, /, ~&, ~&&, ~/, |, ||…)
- Bitwise Operators (@~, @&, @^, @|, @<<, @>>)
- Unary Functions (sin, cos, tan, tg, ctan, ctg, cot, sec,…)
- Binary Functions (log, mod, C, Bern, Stirl1, Stirl2, …)
- 3-args Functions (if, chi, CHi, Chi, cHi, pUni, cUni, qUni, pNor, cNor, qNor)
- Variadic Functions (iff, min, max, ConFrac, ConPol, gcd, …)
- Iterated Operators (sum, prod, avg, vari, stdi, mini, maxi)
- Calculus Operators (int, der, der-, der+, dern, diff, difb)
- Math Constants (pi, e, [gam], [phi], [PN], [B*], [F’d], [F’a], …)
- Physical Constants ([c], [G.], [g], [hP], [h-], [lP], [mP], [tP])
- Astronomical Constants ([ly], [au], [pc], [kpc], [Earth-R-eq], …)
- Random Variables ([Uni], [Int], [Int1], [Int2], [Int3], [Int4], …)
- Metric prefixes ([%], [%%], [Y], [sept], [Z], [sext], [E], …)
- Parser Symbols ((, ), ,, ;)
- Units
In parameter analysis ,MXReflection Supports all field data types with digital content as parameters . You can put all of Java The type is the same as... That returns the numerical result toString Implementation used together . Supported result fields java Type a :
- Double
- double
- Long
- long
- String
- BigInteger
But pay attention to , about long、long and BigInteger,MXReflection Use to parse the final result before injection . It is recommended to make sure that the expression returns an integer type .
Scan the QR code and follow me , Reply key words mxreflection
, Get source code library and project examples !
It is forbidden to reprint without authorization , Violators shall be held responsible according to law
For authorization, please contact :[email protected]
