[GiNaC-devel] Patches to fix nonnegative info flag
Vladimir V. Kisil
kisilv at maths.leeds.ac.uk
Wed Apr 22 16:29:13 CEST 2015
Dear All,
I am attaching three micro patches to fix problems with the
following programme (present output is included):
#include "ginac/ginac.h"
int main(){
GiNaC::ex half=GiNaC::numeric(1,2),
E=-pow(8, half);
std::cout << "E nonneg: " << E.info(GiNaC::info_flags::nonnegative) << std::endl;
// --> E nonneg: 1
std::cout << "Absolute value of E: " << abs(E) << std::endl;
// --> Absolute value of E: -sqrt(8)
std::cout << "Absolute value of (-E): " << abs(-E) << std::endl;
// --> Absolute value of (-E): abs(sqrt(8))
return 0;
}
First, the present GiNaC returns
mul::info(GiNaC::info_flags::nonnegative) just opposite to the correct
one. This is one patch.
Second, presently pow::info(GiNaC::info_flags::nonnegative) can be
false even if pow::info(GiNaC::info_flags::positive) is true. this the
second patch.
Finally, I think that abs shall return -arg if arg is negative or
(-arg) is nonnegative, this is the third patch.
If all three patches are implemented, then the output of the above
example is:
E nonneg: 0
Absolute value of E: sqrt(8)
Absolute value of (-E): sqrt(8)
Best wishes,
Vladimir
--
Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/
Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu
Software: Geometry of cycles http://moebinv.sourceforge.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fixed-mul-info-info_flags-nonnegative.patch
Type: text/x-diff
Size: 856 bytes
Desc: c++ patch
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20150422/2b816157/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fixed-pow-info-info_flags-nonnegative.patch
Type: text/x-diff
Size: 1199 bytes
Desc: c++ patch
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20150422/2b816157/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Abs-function-returns-arg-if-arg-is-nonnegative.patch
Type: text/x-diff
Size: 765 bytes
Desc: c++ patch
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20150422/2b816157/attachment-0002.bin>
More information about the GiNaC-devel
mailing list