subsop

acer's picture
> q := x^(1/2):

> type(q, `^`);
                                     true
> op(0,q);
                                       ^

> subsindets(q, `^`, f->subsop(0=H,f));
Error, (in unknown) improper op or subscript selector

What's wrong with that last one? It's modelled on the first Example in the ?subsindets help-page.

Are there cases where the following would not be a good enough workaround?

> subsindets(q, `^`, f->H(op(f)));
                                   H(x, 1/2)

The same thing seems to happen for `*` and `+`. But this infix neutral operator seems ok,

> z := s &* P;
                                  z := s &* P

> subsindets(z, specfunc(anything,`&*`), f->subsop(0=H,f));
                                    H(s, P)

acer

illegal use of subsop

See the help page for subsop, third bullet, second sentence

  A speci of 0 is allowed only for function, indexed expression, and series exprs. 

Note that neutral operators are represented as functions,

dismantle(x &* y);

FUNCTION(3)
   NAME(4): `&*`
   EXPSEQ(3)
      NAME(4): x
      NAME(4): y

acer's picture

ok, but..

Thanks Joe, but I was not surprised that it worked OK for `&*`.

I'm wondering why it doesn't work for `^`, `*`, and `+`. As I believe that I showed, op(0,..) of such things can be accessed.

acer

JacquesC's picture

Not implemented

Unfortunately, op and subsop are not completely symmetric. They are 2 totally different pieces of code, and not all of op's features are supported by subsop. I do not know of a 'good' reason for that, just history.

history and future

More important would be to know whether these things can be made consistent. And if they can, they will.

JacquesC's picture

Consistent

I am fairly sure that they can be made consistent. As to when that will happen, you'd have to ask for the prioritized task list for the Kernel Group to figure that out.  Somehow I would guess that this doesn't rank too high...

Road map

I would find very useful to know such lists. Ie know where Maple is going. I guess that Maplesoft's policy is not to show  its cards the competition, though.

JacquesC's picture

Exactly!

As long as Maple remains a closed-source product, that will be so.  Note that this is not necessarily related to Maplesoft being for-profit, as many companies (like Mozilla, Sun and Red Hat) have shown.

type

I do not know whether it is a good reason, but I have just happen to compare these two paragraphs, the one in ?subsop, cited by Joe:

A speci of 0 is allowed only for function, indexed expression, and series exprs.

with this one in ?op:

For some data structures, op(0, e) is defined as a special case (for more information, see the particular data structure help page). For functions, op(0, e) is the name of the function. For subscripted names, op(0, e) is the name without the subscript. For series, op(0, e) is x-a where x is the variable and a is the expansion point of the series. If calculating op(0, series(exp(x), x=a)), x-a returns rather than a. For all other data structures, op(0, e) returns the type of e.

I.e., 'subsop' for 0 is allowed for those objects whose 'op' 0 is not the type.

Though it is not an explanation as why this is so, this relation makes me simpler to remember the rule.

type function

So, a workaround is possible: generate an object of type function whose 'op' 0 is `^`:

q := subs(p=`^`,p(x,1/2));
                            q := ^(x, 1/2)

This object is "metastable", so that it is necesary to prevent its full evaluation:

q;
                                  1/2
                                 x

eval(q,1);

                              ^(x, 1/2)

In this way:

subsop(0=H,eval(q,1));
                              H(x, 1/2)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}