## Jace.NET 0.9: your input is appreciated!

Most of the last previous releases were limited and only introduced bug fixes or new mathematical functions. Jace.NET has already a complete support for all the standard math, but for the next release I have decided to increase the scope: from version 0.9 forward Jace.NET will have full support for matrices!

The following syntax is planned:

- Definition of a matrix: A = [1,2,3;4,5,6;7,8,9]
- Scalar multiplication: 3*A
- Matrix multiplication: A*B
- Transpose: A’ or transpose(A)
- Select a matrix element: A[2,3]
- New functions: ones(3,3), zeros(3,3)

For the initial 0.9.x release(s), I have foreseen the following constraints to simplify the initial support for matrices:

- It will not be supported to use variables in matrix elements: so the following syntax will initially
**not**be allowed: [1,2,3;4,var,6;7,8,9] - All matrix elements will be interpreted as doubles in the engine (not as integers)

And now comes the part where you are involved as a reader: I would really like have your input.

- Would this satisfy you (matrix) needs?
- Is the proposal ok?
- Are the constraints acceptable?
- Besides matrix support, what else would you like to see in Jace.NET?

Hope to hear from you guys!

Advertisements

Hi you got a good job thanks for it 🙂 I have a one question, how convert trigonometrical functions angle? For example default radian angles supported, sin(pı/2)=1 i am need to convert radian to degree and result sin(90)=1.

You can do: rad * 180/pi. Jace has no formula out of the box to do this, but you could quite easily define a custom one: https://github.com/pieterderycke/Jace/wiki/Custom-Functions Does this answer your question?

Hi. First of all, thank you a lot.I am a newbie to android development, and have used jace to do mathematical operations. May you please provide me ideas how to override the existing trigonometric functions with my custom functions. I too want to convert radians to degrees. Thanks again.

Hi again, i am found one bug. jace net calculate 0^0=1, but 0^0= not 0, please fix it 🙂

It would be great to have logic operator like ‘and’ ‘or’ and relation operator like ‘>’ ‘<' '='

Maybe the tree parsing algorithm has to be change.

Decimal support is important if any financial calculation involved.

parameter would be Dictionary instead of Dictionary

Would it not be easy to give us a way to lazy resolve variables rather than having to define the variables and it’s values before hand? So if a variable cannot be found it fires an event asking for the variable to be resolved. This would save us having to load a lot of variables before we can do some small calculations. Because we don’t always know before hand which expression is calculated.

Hello MacShack, you do not have to care if a variable is used or not. The engine has no problem if more variables are provided then used. Do you have performance issues for getting all the variables instead of a subset? What type of application are you building?

My point is more that the caller of a formula might not know at the time of calculation what the required variables are to calculate a given formula. Maybe they are generated based on the name of the formula. To generate all possible combinations with its values might be an expensive job. Especially if the formula only needs a couple of variables. Or maybe they want a default value for undefined variables. I’ve downloaded your project and am using it now in a multithreaded procedure. And it works great! I’ll do some benchmarking later. I have a question regarding your speed comparison with NCalc. Is the steep performance increase near the end because of better formula caching? Can you explain why the speed isn’t linear? Thanks again.

Hi,

I’ve had a look at your code and found some interesting points for improvement. For instance. Why don’t you accept an IDictionary/IReadOnlyDictionary interface? Why do you concern your calculator with things like case sensitivity? This is a dictionaries functionality and concern (new Dictionary(StringComparer.OrdinalIgnoreCase)), right? Why not leave that up to the one providing the values and formulas? When you do these two things you can do what I mentioned in my previous post. I can create a class that implements the IDictionary interface and can resolve values when they are requested through the index or TryGetValue. But I think it would be nicer to create your own class that handles the resolvement of variables. This way the class can be extended by any body and this opens a new scope of posibilities.

Thanks for delivering such great work!!!

Hi,

Good remark. In a first phase I will modify it to IDictionary, but indeed probably be better to create a dedicated class (Internally I already do this for functions and constants). It would maybe indeed better to let app builders decide on the case sensitivity.

I wouldn’t make it a class but rather would make it an interface.

in the dev branch on github I have already modified the code to use an IDictionary

I did some more digging. I’ve now changed the dictionary types to IReadOnlyDictionaries (since i’m using .net 4.5) I wonder why you created a dynamic method that uses ContainsKey and then get_Item. Why not use TryGetValue? It is about 40% faster than what you use now. Also, ContainsKey and TryGetValue are only used to throw a nicer exception. If speed is key then you might consider just using get_Item. I wonder what you think of these suggestions.

Hello MacShack, you have a good remark it should be better to switch to TryGetValue. I will adapt the code.

I have switched to TryGetValue in the dev branch for the dynamic compilers and the interpreters. Thanks for the performance tip!

We are using your code for the calculations we do in our application. We first parallely build all the formulae that we know are going to be calculated and then we parallely calculate all the formulae with all the different variable values. This has given us a spectacular performance increase compared to our old calc engine. I’m curious as to what the new benchmarks would look like compared to NCalc.

Make it so it can use Strings a input and output … “SomeFunctionSetText(‘helloworld’)”

Hi,

Is any work done in the matrix stuff?

It will be possible to use variables in “Select a matrix element”: for example A[B,3]?

a more general format of matrix definition could be

A = [[1,2,3],[4,5,6],[7,8,9]]