[GiNaC-list] a counterintuitive case with subs

Feng Feng f.feng at outlook.com
Sun Mar 20 10:44:26 CET 2022

Dear all,

I got a problem with the function subs, and I am not sure it is a possible bug or not,
but it seems counterintuitive.

Here is the code to reproduce the case:
#include "ginac/ginac.h"
using namespace std;
using namespace GiNaC;
int main() {
    symbol s("s");
    ex t = subs(1/s,s==1/s, subs_options::no_pattern);
    cout << t << endl;
    return 0;
The output is 1/s instead of s.

PS: if I remove the subs_options::no_pattern, the output is s as expected.

and I have a look at the source code of basic::subs, it seems it comes from the following code:
that is, the final substitutions on the new object as a whole,
// Perform substitutions on the new object as a whole
return copy->subs_one_level(m, options);

Thanks very much in advance.

Best regards!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20220320/05c98a32/attachment.htm>

More information about the GiNaC-list mailing list