[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-libmatheval] evaluator_get_variables only works for initial evaluat
From: |
Gregg . Kirkpatrick |
Subject: |
[Bug-libmatheval] evaluator_get_variables only works for initial evaluator |
Date: |
Thu, 4 May 2006 16:41:40 +1000 |
Hi,
I am using libmatheval in a way that has multiple evaluator objects
instantiated at one time. The objects seem to evaluate correctly but only
the last object instantiated will return correct information in the
"evaluator_get_variables" call.
I am running this test on Solaris 2.8 and building using the Forte 7
compiler and linker, these were also used to build libmatheval and the
libraries upon which it depends. All libraries passed their "make check"
tests.
Any help appreciated.
Cheers,
Gregg Kirkpatrick
The code below outputs the following:
------------------------------------------------------
****EVAL1****
(((aa+bb)+cc)/3)
count: 0
ave = 2
****EVAL2****
(((dd+ee)+ff)/3)
count: 3
dd ee ff
ave = 2
------------------------------------------------------
------------------------------------------------------
#include <matheval.h>
#include <iostream>
int
main (int argc, char *argv[])
{
void *eval1;
void *eval2;
char *var1[] = {"aa", "bb", "cc"};
char *var2[] = {"dd", "ee", "ff"};
double val[] = {1, 2, 3};
// create
eval1 = evaluator_create("(aa+bb+cc)/3");
eval2 = evaluator_create("(dd+ee+ff)/3");
char **names(0);
int count(0);
std::cout << "****EVAL1****" << std::endl;
// get the string and the var names for eval1
std::cout << evaluator_get_string(eval1) << std::endl;
evaluator_get_variables(eval1, &names, &count);
std::cout << "count: " << count << std::endl;
for (int i = 0; i < count; i++)
{
std::cout << names[i];
}
std::cout << std::endl;
// evaluate eval1
std::cout << "ave = " << evaluator_evaluate(eval2, 3, var2, val)
<< std::endl;
std::cout << "****EVAL2****" << std::endl;
// get the string and the var names for eval2
std::cout << evaluator_get_string(eval2) << std::endl;
evaluator_get_variables(eval2, &names, &count);
std::cout << "count: " << count << std::endl;
for (int i = 0; i < count; i++)
{
std::cout << names[i] << " ";
}
std::cout << std::endl;
// evaluate eval2
std::cout << "ave = " << evaluator_evaluate(eval1, 3, var1, val)
<< std::endl;
// cleanup
evaluator_destroy(eval1);
evaluator_destroy(eval2);
return 0;
}
------------------------------------------------------
National Australia Bank Limited - ACN 004 044 937
This email may contain confidential information. If you are not the intended
recipient, please immediately notify us at address@hidden or by replying to the
sender, and then destroy all copies of this email. Except where this email
indicates otherwise, views expressed in this email are those of the sender and
not of National Australia Bank Limited. Advice in this email does not take
account of your objectives, financial situation, or needs. It is important for
you to consider these matters and, if the e-mail refers to a product(s), you
should read the relevant Product Disclosure Statement(s)/other disclosure
document(s) before making any decisions. If you do not want email marketing
from us in future, forward this email with "unsubscribe" in the subject line to
address@hidden in order to stop marketing emails from this sender. National
Australia Bank Limited does not represent that this email is free of errors,
viruses or interference
- [Bug-libmatheval] evaluator_get_variables only works for initial evaluator,
Gregg . Kirkpatrick <=