Home > C#, Jace.NET > Jace.NET 0.9: your input is appreciated!

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! Smile

Categories: C#, Jace.NET
  1. February 26, 2014 at 16:54

    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.

    • pieterderycke
      February 26, 2014 at 20:28

      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?

      • jyotiranjan
        September 5, 2016 at 13:36

        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.

  2. February 26, 2014 at 17:54

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

  3. rick
    April 28, 2014 at 00:07

    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

  4. MacShack
    October 18, 2014 at 00:40

    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.

    • pieterderycke
      October 19, 2014 at 18:15

      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?

      • Macshack
        October 19, 2014 at 19:10

        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.

  5. MacShack
    October 18, 2014 at 19:39


    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!!!

    • pieterderycke
      October 19, 2014 at 18:20


      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.

      • Macshack
        October 20, 2014 at 17:22

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

    • pieterderycke
      October 25, 2014 at 13:00

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

  6. MacShack
    October 18, 2014 at 21:44

    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.

    • pieterderycke
      October 19, 2014 at 18:17

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

    • pieterderycke
      October 25, 2014 at 14:14

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

      • Macshack
        October 26, 2014 at 09:28

        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.

  7. Anton Christiansen
    January 12, 2015 at 08:31

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

  8. October 27, 2015 at 15:40

    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]?

  9. October 27, 2015 at 16:14

    a more general format of matrix definition could be
    A = [[1,2,3],[4,5,6],[7,8,9]]

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: