www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Automatic Equation and Inequation evaluation.

reply "Carlos" <checoimg gmail.com> writes:
I'm interested in this kind of functionalities; Does D have
something on this ?

I thought about something like a "eval" function that would use
specified algorithms.
something likes this

import std.stdio, std.math, std.eval;

void main()
{
eval(Real; a+b^^x+c=56){
algor.brute(&result);
        }
writeln("Positive value is : ", result);
}
Jun 14 2013
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that would use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
        }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
Jun 15 2013
parent reply "Carlos" <checoimg gmail.com> writes:
On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
 On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that would use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
       }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
algor.brute does the work. IF you know that algorithm you would know what it does. Another question would be if this way of coding makes sense to you. This is what the "eval" function does ( in theory ), It takes The words : Real, Rational, Irrational or R, Q , Q' and from there is defined which numerical group is going to be used for the evaluation. Then it identifies the operators and variables and defines the equation in a format like a text format with a end file character in the end so equations can be as long as you want. After that between {algor.(name)} in name you call the algorithm you want to use for the evaluation there can be predefined algorithm with D but maybe you can define your own algorithms. What do you think does this makes sense or would you implement it other way ?
Jun 15 2013
parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Saturday, 15 June 2013 at 11:44:03 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
 On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that would 
 use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
      }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
algor.brute does the work. IF you know that algorithm you would know what it does. Another question would be if this way of coding makes sense to you. This is what the "eval" function does ( in theory ), It takes The words : Real, Rational, Irrational or R, Q , Q' and from there is defined which numerical group is going to be used for the evaluation. Then it identifies the operators and variables and defines the equation in a format like a text format with a end file character in the end so equations can be as long as you want. After that between {algor.(name)} in name you call the algorithm you want to use for the evaluation there can be predefined algorithm with D but maybe you can define your own algorithms. What do you think does this makes sense or would you implement it other way ?
D provides no such thing. AFAIK, there is nothing in Phobos provided that does it either. It should be doable, where the second argument is a string. Something like: auto eq = Equation(Real, "a+b^^x+c=56"); auto result = Equation.brute(); I think it would quite a specialized numerical library though, so I don't think it would find its way into the standard library. I'm not sure any such D Library exists. You'll either have to port an existing library, or link with a C/C++ existing library.
Jun 15 2013
parent reply "Carlos" <checoimg gmail.com> writes:
On Saturday, 15 June 2013 at 12:36:26 UTC, monarch_dodra wrote:
 On Saturday, 15 June 2013 at 11:44:03 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
 On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that would 
 use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
     }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
algor.brute does the work. IF you know that algorithm you would know what it does. Another question would be if this way of coding makes sense to you. This is what the "eval" function does ( in theory ), It takes The words : Real, Rational, Irrational or R, Q , Q' and from there is defined which numerical group is going to be used for the evaluation. Then it identifies the operators and variables and defines the equation in a format like a text format with a end file character in the end so equations can be as long as you want. After that between {algor.(name)} in name you call the algorithm you want to use for the evaluation there can be predefined algorithm with D but maybe you can define your own algorithms. What do you think does this makes sense or would you implement it other way ?
D provides no such thing. AFAIK, there is nothing in Phobos provided that does it either. It should be doable, where the second argument is a string. Something like: auto eq = Equation(Real, "a+b^^x+c=56"); auto result = Equation.brute(); I think it would quite a specialized numerical library though, so I don't think it would find its way into the standard library. I'm not sure any such D Library exists. You'll either have to port an existing library, or link with a C/C++ existing library.
OK but if developed it would be included in D ? Right ? It would be very useful I think.
Jun 15 2013
next sibling parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Saturday, 15 June 2013 at 13:23:07 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 12:36:26 UTC, monarch_dodra wrote:
 On Saturday, 15 June 2013 at 11:44:03 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
 On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that would 
 use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
    }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
algor.brute does the work. IF you know that algorithm you would know what it does. Another question would be if this way of coding makes sense to you. This is what the "eval" function does ( in theory ), It takes The words : Real, Rational, Irrational or R, Q , Q' and from there is defined which numerical group is going to be used for the evaluation. Then it identifies the operators and variables and defines the equation in a format like a text format with a end file character in the end so equations can be as long as you want. After that between {algor.(name)} in name you call the algorithm you want to use for the evaluation there can be predefined algorithm with D but maybe you can define your own algorithms. What do you think does this makes sense or would you implement it other way ?
D provides no such thing. AFAIK, there is nothing in Phobos provided that does it either. It should be doable, where the second argument is a string. Something like: auto eq = Equation(Real, "a+b^^x+c=56"); auto result = Equation.brute(); I think it would quite a specialized numerical library though, so I don't think it would find its way into the standard library. I'm not sure any such D Library exists. You'll either have to port an existing library, or link with a C/C++ existing library.
OK but if developed it would be included in D ? Right ? It would be very useful I think.
Depends what you mean by "included in D" ? In the standard library, I wouldn't know (but I don't think so). But that doesn't mean it couldn't be distributed as a trusted and reliable third party library.
Jun 15 2013
parent "Carlos" <checoimg gmail.com> writes:
On Saturday, 15 June 2013 at 14:42:38 UTC, monarch_dodra wrote:
 On Saturday, 15 June 2013 at 13:23:07 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 12:36:26 UTC, monarch_dodra wrote:
 On Saturday, 15 June 2013 at 11:44:03 UTC, Carlos wrote:
 On Saturday, 15 June 2013 at 08:46:13 UTC, John Colvin wrote:
 On Saturday, 15 June 2013 at 02:05:00 UTC, Carlos wrote:
 I'm interested in this kind of functionalities; Does D have
 something on this ?

 I thought about something like a "eval" function that 
 would use
 specified algorithms.
 something likes this

 import std.stdio, std.math, std.eval;

 void main()
 {
 eval(Real; a+b^^x+c=56){
 algor.brute(&result);
   }
 writeln("Positive value is : ", result);
 }
It's not clear what that would do from your example. I presume a, b and c are defined somewhere and eval solves for x?
algor.brute does the work. IF you know that algorithm you would know what it does. Another question would be if this way of coding makes sense to you. This is what the "eval" function does ( in theory ), It takes The words : Real, Rational, Irrational or R, Q , Q' and from there is defined which numerical group is going to be used for the evaluation. Then it identifies the operators and variables and defines the equation in a format like a text format with a end file character in the end so equations can be as long as you want. After that between {algor.(name)} in name you call the algorithm you want to use for the evaluation there can be predefined algorithm with D but maybe you can define your own algorithms. What do you think does this makes sense or would you implement it other way ?
D provides no such thing. AFAIK, there is nothing in Phobos provided that does it either. It should be doable, where the second argument is a string. Something like: auto eq = Equation(Real, "a+b^^x+c=56"); auto result = Equation.brute(); I think it would quite a specialized numerical library though, so I don't think it would find its way into the standard library. I'm not sure any such D Library exists. You'll either have to port an existing library, or link with a C/C++ existing library.
OK but if developed it would be included in D ? Right ? It would be very useful I think.
Depends what you mean by "included in D" ? In the standard library, I wouldn't know (but I don't think so). But that doesn't mean it couldn't be distributed as a trusted and reliable third party library.
I mean that anyone with the code can use it without installing anything but the compiler package. And third party could be the first choice before it could be included.
Jun 15 2013
prev sibling parent "BLM768" <blm768 gmail.com> writes:
On Saturday, 15 June 2013 at 13:23:07 UTC, Carlos wrote:
 OK but if developed it would be included in D ? Right ? It 
 would be very useful I think.
It could be useful, but only in a very specific type of program, so it's unlikely that it would be bundled with the D compiler. It would almost certainly be distributed as a separate download from its own site.
Jun 15 2013