acer

32747 Reputation

29 Badges

20 years, 109 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

If you have additional details (such as pseudocode for the unweighted case) then please add it in a Reply/Comment here rather than in a separate Question.

Can you stack random row vectors created with a suitable density option value?

Or do you need it to be super fast and efficient?

@ajfriedlan I know what you're trying to do. I spent some time looking at it a few days ago.

I have doubts that `parameters` will help/work for you, since in your example the values of the varying i,j indices relate to differing subexpressions containing the dependent variable K.

I have several other observations on your problem, including accuracy/precision, the discontinuity jumps, evalf/Int vs dsolve/numeric, etc. I got some speedup and memory reduction, but I'd like to see it 20 times faster and 1/10th the allocation. I've also asked the dsolve developer about how to clear the hidden storage that seems to be going on for your example.

I have not yet had enough free time to respond properly in your Question's own thread.

But I will not respond at all if you continue to duplicate your question, including repeating it in such old posts as this.

@Ramakrishnan 

1) filenames including the absolute path (though names relative to currentdir may work)

2) This code doesn't go anywhere in the original worksheet to be converted.  You run it standalone (in the GUI if you wish),  and merely reference the original worksheet by name.

3) The target of this conversion is a new .mw file. Subsequent export to .pdf (if you want it) would still be done the usual way, ie. by opening the new worksheet in the GUI.

@Carl Love There is no typographically or structurally leading `-` for this example.

restart;

Sign := (e::algebraic)->
   if e::{`+`,`*`} then thisproc(op(1,e))
   elif e::function then 1
   else try sign(e) catch "invalid argument": thisproc(op(1,e)) end try
   fi
:

expr := (-x+1)^3;

(-x+1)^3

Sign(expr);

-1

 

Download hmm.mw

@nm I understand now, thank you.

You are using `frontend` quite differently from both what I suggested earler and what I put in my answer. Why!?

One point is to freeze the denominator in the case that it is a sum (so that the term can be seen a a polynomial). But if sums are to be frozen then the first addend must be examined in the case that the whole expression is a sum (and possibly also because freezing might conceivable change the order).

 

@Christopher2222 What are you talking about?

You can upload a file here, and add a link into your Question (or a followup Reply) using the green up-arrow in the Mapleprimes editor's toolbar.

Does your example work in your Maple 14 if you enter it in 1D (plaintext) Maple Notation?

Did it perhaps produce that error only when entered in 2D Input?

(I have a hazy recollection that the elementwise syntax ( ~ ) may not have been fully recognized by the 2D Input parser when it first appeared. I could be misremembering.)

 

The setsort option that can be passed to the interface when launching Maple, but I don't think that any of its permissible values is going to allow you to get that ordering of integers in a set.

For what purpose do you need L to be a set rather than a list?

 

The form of the coefficients (of powers of k) can be simplified. How much so depends on what assumptions may be placed on the remaining parameters, or how much it matters to respect branch-cut choices for the radical subexpressions.

Can you tell us anything about A, P, and N?

 

@mmcdara In your other example, I believe that you'll need PDF = unapply(f,t) instead of PDF = (t -> f) so as to obtain PDF as a procedure that properly uses its parameter t.

My_ChiSquare_ChiSquare_Gof_Test_ac.mw

Do you now want a customized command Distribution that will detect when it gets called like, say, Distribution(GeneralizedBetaDistribution(a,b,scale,shift)) and invokes Statistics:-Distribution as in your example, but otherwise simply passes along all arguments?

@Carl Love It looks like the command-completion popup.

These command-completion templates are stored (somewhere). But I don't know offhand whether it's practical or possible to augment that with one or more templates for a custom user-defined procedure.

(If you are asking how he got it into Mapleprimes, I don't know how he got the image here -- possibly via a screenshot.)

Here are two ways it could be done.

They use slightly different ways to access the stored values/fields. You could even make it do both of these ways.

One point is that as an object you get the new type, Person, for free without having to utilize TypeTools:-Add and a proc that tests, say, a Record approach.

The definition of the object is centralized. Changing it only requires editing that defintion (and, naturally, wherever the constructor gets called, if you alter the kinds of arguments the constructor accepts.)

restart;

Person:=module()
    option object;
    local ModulePrint, R;
    export ModuleApply::static:=proc()
      Object(Person, _passed);
    end;
    export ModuleCopy::static:=proc(new::Person, proto::Person,
                                    name::string, age::nonnegint)
      if nargs=4 then
        new:-R := Record(':-name'=name,':-age'=age);
      else
        error "invalid arguments"; end if;
    end proc;
    export `?[]`::static:=proc(a, idx::list)
        if idx=[] then
          [a:-R:-name, a:-R:-age][];
        elif nops(idx)=1 then
          a:-R[idx[1]];
        else error "too many indices, %1", [idx][];
      end if;
    end proc;
    ModulePrint:=proc(a)
      # or whatever you want
      'Person'(R:-name,R:-age);
    end proc:
  end module:

P1 := Person("john doe 1", 99):

P2 := Person("john doe 2", 80):

P1;

_m139837426773472

P2;

_m139837426775168

type(P1, Person), type(P2, Person);

true, true

P1[];

"john doe 1", 99

P2[];

"john doe 2", 80

P1[name], P2[name]

"john doe 1", "john doe 2"

P1[age], P2[age];

99, 80

P1[name, age];

Error, (in ?[]) too many indices, [name, age]

foo:=proc()"joe doe 1";
   Person("john doe 1", 99);
end proc:

boo:=proc()
   Person("john doe 2", 80):
end proc:

S1:=foo();
S2:=boo();

_m139837429143520

_m139837429160672

type(S1, Person), type(S2, Person);

true, true

S1[name], S2[name]

"john doe 1", "john doe 2"

S1[age], S2[age];

99, 80

 

# Another way

restart;

Person:=module()
    option object;
    local ModulePrint, lname, lage;
    export ModuleApply::static:=proc()
      Object(Person, _passed);
    end;
    export ModuleCopy::static:=proc(new::Person, proto::Person)
      if nargs=4 then
        (new:-lname,new:-lage) := args[3], args[4];
      else
        error "invalid arguments"; end if;
    end proc;
    export name::static:=proc(a)
      a:-lname;
    end proc;
    export age::static:=proc(a)
      a:-lage;
    end proc;
    ModulePrint:=proc(a)
      # or whatever you want
      'Person'(lname,lage);
    end proc:
  end module:

P1 := Person("john doe 1", 99):

P2 := Person("john doe 2", 80):

P1;

_m139837426773408

P2;

_m139837426775040

type(P1, Person), type(P2, Person);

true, true

name(P1), name(P2);

"john doe 1", "john doe 2"

age(P1), age(P2);

99, 80

foo:=proc()"joe doe 1";
   Person("john doe 1", 99);
end proc:

boo:=proc()
   Person("john doe 2", 80):
end proc:

S1:=foo();
S2:=boo();

_m139837429174080

_m139837429191200

type(S1, Person), type(S2, Person);

true, true

name(S1), name(S2);

"john doe 1", "john doe 2"

age(S1), age(S2);

99, 80

 

Download person_object_2.mw

First 216 217 218 219 220 221 222 Last Page 218 of 600