s.py

155 Reputation

4 Badges

20 years, 44 days

MaplePrimes Activity


These are answers submitted by s.py

I know that this kind of coding is to avoid, and i usually do. But it's actually a great shortcut in my algorithm.

I m doing a recursive solving function, adding variables as needed. At some steps i try all the possible values for this variables, so the problem : writing a function replacing values by nexts for a random number of variables.

For the unassigned arguments case, it's not (here) a problem as I code this in a private function called only from the main one. I m sure the variables are always assigned.

Ok, i know i can simply write a function returning a list and use it as : L := newvalues(L);
But for me there is then an unecessary list copy.

Thank you for your help
 

Sometime hard to find what we need in the documentation.
Here it is : ?extension

Now it works, and I dont clearly understand why my previous code dont. Would it be c++, I could say it is related to namespaces.

Topic closed

On my computer print output is immediat using worksheet mode, delayed using document mode
(and im sure it's same on all configurations)

Design choice or bug ? I dont know. This difference isn't exposed in the documentation AFAIC
Thank you all for your help

Note:
Using document mode, i ve tried multithreading with a producer calculating and a consummer printing. This does not help, priting is still delayed (But as they tell in the doc, maple multithread is not fully finallized)

Topic closed
 

thanks robert,

i ve tried

same pb, it took 20 secondes, and the results come all together after this 20 secondes.
(xp, maple 12 gui)

try the following  :

test := proc (fun1, fun2, i)
  if i < 0 then
     print(fun1*fun2 = collect(fun1*fun2, x))
  else
     test(subs(a[i] = 1, fun1), subs(a[i] = 1, fun2), i-1);
     test(subs(a[i] = -1, fun1), subs(a[i] = -1, fun2), i-1);
  fi;
end proc;

this (stupid) procedure just print all the products of two polynoms with indexed values a[i] being +1 or -1 :

test(a[0]*x, a[1]*x+a[2], 2);

x*(x+1) = x^2+x
-x*(x+1) = -x^2-x
x*(-x+1) = -x^2+x
-x*(-x+1) = x^2-x
etc.

ok. the problem is not obvious with this values. try the following :

test(sum(a[i]*x^i, i = 0 .. 5), sum(a[i+6]*x^i, i = 0 .. 10), 16);

this takes more time and nothing is printed while it runs. all come only at end.

Ok,  that is what i'm doing, but seeing all the work i was expecting something else.

But seems no way, i'll try it

Thank you



 

"Now, would you really expect this comedy of errors to be well-documented?"

With this knowledge, i would have started right with Array. So yes, i expect all known limitations to be documented, in all applications. Hope, hope...

Deep knowledge of Maple's archaeology, thank you :)

For your axiom, from what i can understand (being french) if a very long beta would be enough to avoid all design mistakes, then why not to start with the first version ? Then nothing to remove in next version, no compatibility problem, no need for a longer beta period. But we know there is always bugs, design or code ;)

 

"You are probably attempting to directly assign elements of a list with more than 100 elements"

No, my list was exactely a : list(list(integer,algebraic,algebraic)) with 25 items.
Or if u prefer a list of 25 lists of 3 items. But the third column algebraics are heavy, tens of screen pages on output. My procedures are about to simplify this algebraics.

Not an efficient technic, ok, but what is the efficient one and where is it discouraged in the doc ? I've seen nothing on that.

Interesting. I will further investigate that.

(I note that x and y are still said renamed x~ and y~)

thank you for this one
py

Using the right thing is the right way. and attributes is better than properties for my problem.

The following works :

clrattr := proc(L)
  if nargs>1 then
    map(clrattr,[args]);
  elif type(L,'symbol') then
    setattribute(L);
  elif type(L,{'list','set'}) then
    map(clrattr,L);
  elif type(L,'algebraic') then 
    map(clrattr,indets(L));
  fi;
end proc;


Ok there is still a small pb with indexed names, but I can do without it.

Thank you all for you help :)
py

I can't, again :(

The solver i try to implement is beyong the automatic processes of maple. it needs some user interactivity afaics. Some procedures do parts of the work and return results. Then the user decide what to do next and some other procedures are used. And so on.

When i'll have fully implemented it, perhaps it will help me to find an unified method. For now I can't imagine it.
I can use 'assuming' for top level functions, but the solver decides itself to assume some other names on need and this assumes would be lost from a call to another.

mmm... I thought my question was a simple one, but finally seems it's not. And seems i'll have to rethink the whole logic using another way.

yes, almost what i need, but infortunately : 

assume(x,'constant');
f := indets(a*x+b);
                           f := {a,b,x~}
MyReset(f);
                                 f
f;
                                 f
a,b,x;
                              a,b,x~
L := [a,b,x~];
                            L := [a,b,x~]
MyReset(L);
                                 L
L;
                                 L 
a,b,x;
                               a,b,x~

a,b,x are not modified, the lists are unassigned. 
to use such a function i need to know in advance what names to give it.
what i need is : 

MyReset(a);
                                                                          a
assume(x,'constant'); MyReset(x);
                                                                          x;
assume(x,'constant'); MyReset([a,b,x]);
                                                                       [a,b,x]
assume(x,'constant'); MyReset(indets(f));
                                                                       {a,b,x}
assume(x,'constant'); MyReset(f);
                                                                       {a,b,x}

oups, delphi user typo ;)

in previous post,
replace "procedure do_something(someargs)" by "do_something := proc(someargs)"
and "procedure check_results(someargs)" by "check_results := proc(someargs)"

obviously :)
(but this kind of typo is not the source of the pb, my actual code execute well. i can't have the good results,nothing more)
 

if i could ! :)

but my samples were just some of my tries from an heavy code, where i've not the actual names (an more, some of the names can be autogenerated temp names)

assume_all := proc(assumethis)
   local k;
   k := indets(assumethis);
   map(assume,k,'constant'); # constant, or whatever u want
end proc;

unassume_all := proc(unassumethis)
  local k;
  k := indets(unassumethis);
   ... here code to unassume all the indets ... but what code ? ... k:='k' doesn't work. when returning
   ... from unassume_all my vars are still assumed ...
end proc;

procedure do_something(someargs)
  ...
  if somereason then
    assume_all(somevars);
    ...
  fi;
  ...
end proc;

procedure check_results(someargs)
  unassume_all(someargs);
  ...
end proc;
 

Page 1 of 1