acer

32627 Reputation

29 Badges

20 years, 45 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Markiyan Hirnyk Please tell us the point of your remark, because without any words of explanation it seems pointless. What were you hoping that your command would return, in terms of an explicit, exact symbolic result?

@Andriy Do you mean that you now want to unassign the names in `a`?

restart:

a:=[chris,jack,john,jason,fred,alex]:
seq(assign(i, 0), i = a);

map(unassign, eval(a,1))[];

a;
             [chris, jack, john, jason, fred, alex]

@J4James I only put the plottools:-transform in there to reflect the x- and y-axes. That command turns the data from Array into listlist. So either use some invocation involving nops (or numelems) instead of rtable_dims to pick off the dimensions of the two listlists, or don't transform the axes at that time.You don't necessarily need to transform and switch x-y axes, as it is easy to just change how the entries get printed.

F12 := -(1/2*(S+sqrt(S^2+4*alpha)))*alpha:
F22 := (1/2*(-S+sqrt(S^2+4*alpha)))*alpha:
p1 := plot3d({F12,F22}, alpha=max(-1,-S^2/4)..0, S=-20..20):
A:=op([1,1],p1):
m:= rhs(rtable_dims(A)[1]):
n:= rhs(rtable_dims(A)[2]):
for i from 1 to m do
for j from 1 to n do
X := A[i,j,1];
Y := A[i,j,2];
Z := A[i,j,3];
printf("%f %f %f\n",Y,X,Z);
end do:
end do:
B:=op([2,1],p1):
m:= rhs(rtable_dims(B)[1]):
n:= rhs(rtable_dims(B)[2]):
for i from 1 to m do
for j from 1 to n do
X := B[i,j,1];
Y := B[i,j,2];
Z := B[i,j,3];
printf("%f %f %f\n",Y,X,Z);
end do:
end do:

@J4James Yes.

op(p1) are all the operands of the PLOT3D structure assigned to `p1`. It has two MESH substructures, because the first argument to plot3d was a set of two expressions (lambda1 and lambda2).

op(1,p1) is the first MESH, and op(2,p1) is the second MESH.

And so op([1,1],p1) is the Array in the first MESH, and op([2,1],p1) is the Array in the second MESH.

 

@J4James It appears that you have some preconception of how the data that may represent a surface must be formatted or structured. There is no single way in which the data that represents a surface (to somebody or to some application) must be structured.

Are you saying that you need or expect a regular grid of data points -- evenly spaced in x and y directions say -- because you wish to use the data inside some other (plotting?) program which expects such a format? If so, then you could make that more clear, if that is what you mean by "extracting" the data.

What exactly do you consider to be wrong with the extracted data (triples) from your original posted code? Is it because some other application also renders one curved edge as very jagged? If that is so, then what format would you want instead? Using a very, very fine grid just to get rid of jaggedness that could otherise be far more easily handled by a different structure&interpretation seems like a resource expensive approach.

What is your target application for the exported data? What is the defintion of the format in which you want data to be exported?

The plottools:-getdata command is just an alternative (to `op`) for getting one's hands on the Arrays or data. It doesn't provide anything different about how that data is formatted. (All it really does is call `op` itself).

lambda1:=(S+sqrt(S^2+4*alpha))/(2):
lambda2:=(S-sqrt(S^2+4*alpha))/(2):
p1:= plot3d({lambda1,lambda2}, alpha=max(-1/4*S^2,-5)..5, S=-10..10, grid=[5,5]):
A:=op([1,1],p1):
B:=op([2,1],p1):
dd:=plottools:-getdata(p1);
dd[1,-1]; # A
dd[2,-1]; # B

The joy of the MESH structure for your example is that Maple's interfaces know how to render a surface from it that doesn't have the very jagged edge. There's no reason to expect that some other application should be able to do the same with it.

@J4James 

lambda1:=(S+sqrt(S^2+4*alpha))/(2):
lambda2:=(S-sqrt(S^2+4*alpha))/(2):
p1:= plot3d({lambda1,lambda2}, alpha=max(-1/4*S^2,-5)..5, S=-10..10, grid=[5,5]):
A:=op([1,1],p1):
m:= rhs(rtable_dims(A)[1]):
n:= rhs(rtable_dims(A)[2]):
for i from 1 to m do
for j from 1 to n do
X := A[i,j,1];
Y := A[i,j,2];
Z := A[i,j,3];
printf("%f %f %f\n",Y,X,Z);
end do:
end do:

Make sure that `A` is assigned a MESH Array. And repeat as necessary, for other MESH Arrays in the PLOT3D structure.

In modern Maple plottools:-getdata can be used instead of `op`, for getting at the rtables or listlists in the MESH or GRID. But that still leaves you the work of exporting it.

@J4James Your original plot3d call produces a GRID data substructure within the PLOT3D data structure itself.

On the other hand, when the plot3d call is modified to use a variable bound for the inner range then the result is a PLOT3D structure containing a MESH.

Ie, considering just one of the two surfaces from your example,

restart:
with(plots):
lambda1:=(S+sqrt(S^2+4*alpha))/(2):
P0:=plot3d(lambda1, alpha=-5..5, S=-10..10):
P1:=plot3d(lambda1, alpha=max(-1/4*S^2,-5)..5, S=-10..10):
op(P0);
op(P1);

It is the GRID vs MESH aspect which is making the difference to the nature of the resulting surface's own grid. Sorry, but I don't know of any source which discusses the rendering of these structures in great detail.

My call to `isolate` was just a way to get a parametrization of the joining spacecure between the two surface pieces. It was fortune, in a sense, that formulaically it worked out simply for this example. I wanted the (formulaic) variable end-point of the range just because I happened to recall how the patching/gridding of surfaces could get done, according to whether it is GRID or MESH.

Another example is below, (where I use some thought to figure out which result from `solve` might suffice, though perhaps the mimimum under assumptions of realness might simplify to what was wanted here). I flip the x- and y-axes, just to get the same exact view as the original.

F12 := -(1/2*(S+sqrt(S^2+4*alpha)))*alpha:
F22 := (1/2*(-S+sqrt(S^2+4*alpha)))*alpha:
solve(F12=F22,alpha);
plot3d({F12,F22}, S=-20..20, alpha=-1..0);
plottools:-transform((x,y,z)->[y,x,z])(
   plot3d({F12,F22}, alpha=max(-1,-S^2/4)..0, S=-20..20));

I'd be surprised if there wasn't an even easier way to force a suitable MESH in the plot3d result.

@Axel Vogt Yes, I was using 64bit Maple 17.02 on Windows 7.

I find it interesting that evalb returns true for the "equality" test of two procedures for which addressof returns two different results.

@John Fredsted 

For HermitianTranspose of Matrix A, there is A^%H

@madssdam The `with` command is not supposed to be utilized within a procedure. Consider utilizing use or `uses` instead (the latter of which is mentioned in the proc help-page) for adjusting the environment within the scope of that procedure.

Are you hoping to change the global bindings related to the exports of other packages, when your own custom package is loaded? If so, then why, except for convenience? It's just my opinion of course but in such a set up I would consider the behaviour of the global environment to be a strange thing, with behaviour that would be unusual and apparently inconsistent. It might seem useful in simple cases, but I would be concerned with addling the binding stack in such a way.

Can't you explicitly issue with(RealDomain): with(mypackage): at the top level instead, which keeps it clear what is loaded. Or, alternatively, could you create explicit exports for the names you want rebound by loading your package, even if those consisted simply of calls to exports of other packages such as RealDomain?

I do not see the behaviour in your first case (with a,b,c,d shown still) when running either Maple 16.00 32bit or Maple 16.02 32bit on ubuntu 10.04. I tried also on an i386 based SuSE 10.1 with 32bit Maple 16.00 and 16.02 and there again I also do not see the first behaviour you showed.

A Matrix (capital M) does not have last-name-evaluation. Even if you had used matrix (lowercase m) to get a table based array (which does have last-name-eval) then you should see the literal `A` printed as the result of issuing `A;` and not what you showed.

What minor version number are you using (Maple 16.00, 16.01, 16.02, etc)? Which Linux distribution? Could you double check whether you really do get that behaviour after issuing exactly the command shown?

Since you used uppercase M for Matrix, this is likely about evaluation under `print/rtable` I would expect, and not anything to do with last-name-evaluation.

acer

That call to Units:-AddSystem might be removed from the local AtomicWeight procedure. If you issued it just once at the top level, then the AtomicWeight procedure could be called repeatedly without its reexecuting that call to AddSystem each time. That should be more efficient. (I got a cpu timing difference of about 2 sec vs 24 sec, for 10000 repeats of a call like mat:-AtomicWeight(Cl).)

So then you could consider putting that call to Units:-AddSystem into a local module member named ModuleLoad. Once you save such a revised module to Library archive (the subject of your post) then that modification could come into play. In a new session (with the saved archive in libname) then that ModuleLoad procedure would get run just once at the moment that the module is first accessed from the archive. Ie, when you first call mat:-AtomicWeight or some other export, or when you first issue with(mat). It would also get called once upon the first reference following a restart.

Just a thought.

Apart from the section on modules in the Programming Manual, you might also take a quick look at this answer to a related, older question.

acer

@Gauss It's often best to state up front what you are really after.

If you know that the expression is just a product powers of names then you could be more direct, eg.

ee:=Pi^3*x^2*y^3/(z^7*r^3*p):

map(`[]`@op,select(type,[op(ee)],And(name,Non(constant))^negint));

                  [[z, -7], [r, -3], [p, -1]]

map(`[]`@op,[indets(ee,And(name,Non(constant))^negint)[]]);

                  [[p, -1], [r, -3], [z, -7]]

map2(op,1,[indets(ee,And(name,Non(constant))^negint)[]]);

                           [p, r, z]

And if you know that there will be no coefficients containing named constants then it can be simpler. Eg,

ee:=x^2*y^3/(z^7*r^3*p):

map(`[]`@op,select(type,[op(ee)],name^negint));

                  [[z, -7], [r, -3], [p, -1]]

map(`[]`@op,[indets(ee,name^negint)[]]);

                  [[p, -1], [r, -3], [z, -7]]

map2(op,1,[indets(ee,name^negint)[]]);

                           [p, r, z]

@cesar torres What happens if you change,

  A := Array(1 .. 5, 1 .. 3);

to

  A := Matrix(5, 3, datatype=float[8]);

?

What version of Maple are you using?

What is the value of `kk`?

acer

First 365 366 367 368 369 370 371 Last Page 367 of 597