Carl Love

Carl Love

28130 Reputation

25 Badges

13 years, 310 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@bellaqueame I've rewritten your ElemRing:

ElemRing:= proc(
   f::depends(polynom(polynom(integer, tauh), x)), 
   x::name,
   tauh::specfunc(polynom(integer, _Z), RootOf),
   p::prime
)
local i, n:= p^(degree(op(tauh))*degree(f,x))-1, ring:= rtable(0..n);
   for i to n do 
      ring[i]:= Nextpoly(ring[i-1], x, tauh) mod p
   od;
   [seq(ring)]
end proc: 

Please execute this in Math Input (aka 1D Input) or in a Code Edit Region because I suspect that the depends parameter modifier doesn't work in 2D Input. Your versions have numerous levels of unnecessary, nested list-forming brackets. I think that this is the reason that they don't work. I don't feel like disentangling all your nested lists, because they're simply not necessary.

Note that I changed the parameters (and their order) from your ElemRing. Like before, the x (a global unassigned name) should be passed! It's not necessary to pass k because it can be deduced from tauh. The order is just my style preference and follows the argument order of Nextpoly. It is traditional in Maple that the field characteristic p be the last parameter.

@bellaqueame From your "invalid power" error, I assume that you're using 2D Input. The error can be corrected by changing

<seq(a^(` q `^k), k= 0..n)>^+

to

<seq(a^(` q `^k), k= 0..n)>^%T

and also make the same change on the following line.

I strongly discourage the use of 2D Input. I use Maple Input (aka 1D Input).

I haven't looked at your code yet.

@bellaqueame As far as I'm concerned, there's no practical difference between an infinite equivalent class and its canonical representative. For example, consider 3/5: Is it just a rational number, or is it the equivalence class of all pairs of integers (n,m) such that 5*n = 3*m? And does making that distinction make any practical difference? Only set theorists make that distinction, and then only when they're being pedantic.

My command Rem(..., f, x) mod p does include the ring extension element! It's the x, and I told you to pass the x to your FastEval.

Doesn't the following code do (over a randomly generated ring) what you describe above?: 

restart:

p:= 3: d:= 2: q:= p^d: n:= 2: #size parameters
interface(rtablesize= 2+p^(n*d)):

alias(T = RootOf(Randprime(d, z) mod p, z)): #random degree-d field extension

#explicit list of ring elements:
R:= [seq(rtable(
   (0..p-1)$(n*d), 
   ()-> add(add(args[d*i+j+1]*xi^i, i= 0..n-1)*T^j, j= 0..d-1)
))];

#random polynomial that splits into n distinct linear factors over F_q:
f:= sort(
   collect(Expand(mul(xi-a, a= combinat:-randcomb(R,n))) mod p, xi, expand), 
   xi
);
 
#table of powers of every ring element:
<
   <seq(a^(` q `^k), k= 0..n)>^+,
   <seq(`=======`, k= 0..n)>^+,
   Matrix((nops(R), n+1), (i,j)-> Powmod(R[i], q^(j-1), f, xi) mod p)
>;

Powmod(a, n, f, x) mod p is equivalent to Rem(a^n, f, x) mod p but is a little more efficient.

Regarding ceil(log[2](n)), it's equivalent to

ceillog2:= (n::posint)-> `if`(n=1, 0, 1+ilog2(n-1)):

 

@acer Vote up. Since these commands are undocumented, do you have any idea what mtr and mtd stand for? That would help me remember them.

@izhammulya It's not at all strange that the minimal solution sets those variables to their maximal values. All coefficients are positive and those variables appear in equality constraints but not the objective. I think that you simply made a mistake by including them in the constraints. Removing those variables from the problem entirely is equivalent to setting them to 0.

@izhammulya If you think that those variables should be 0, then simply remove them from the problem!

@izhammulya Please post your problem as an attached worksheet. For one thing, it'll be much easier to read. You can attach a file by using the green uparrow on the toolbar of the MaplePrimes editor.

I could write a procedure that does that, but before I do, I'm curious what the purpose is for you. Any of the following commands is likely to provide more-relevant information about a DAG and its substructures:

indets, #by far the number-one choice
ToInert,
dismantle, #gives a visualization, but difficult to process results programmatically

disassemble@addressof

@jbuddenh Yours is the second problem in a week reported in MaplePrimes caused by the poor rendition of code examples in Maplesoft's online help pages. As I told that other Questioner, I recommend that you always compare with the in-program help (in this case ?Statistics,Distributions,Uniform). And for additional clarity, press F5 to display the code in a monospaced font if it's not already thus displayed.

@minhhieuh2003 Thanks, I totally understand your Question now.

The answer depends on whether Typesetting:-mrow has an option akin to tabulation, such as placement at a certain distance from the left edge of the virtual box that it works in. Trying to fit in a certain number of space characters is unreliable if you're not using a monospaced font.

@Carl Love Upon deeper analysis, it looks like your character is equivalent to the ASCII &Assign;, which leads me to believe that you got it from a palette. I'd recommend that those palette symbols be reserved for display purposes and that only keyboard characters be used for coding purposes. While this recommendation is not strictly required, it does help keep one out of trouble.

I think that most of the readers here are having trouble understanding your Question. Would you please elaborate, rephrase, and include an attached worksheet? Do you mean that you want to use the TAB key to change the selection of multiple-choice answers?

@sand15 This Reply is not directly related to your question from two Replies above, but I wonder what you hope to achieve by setting UseHardwareFloats:= true. Do you believe that if you don't do this then it's equivalent to setting it to false? That's not the case: There's a middle value between true and false named deduced, which is the default value and the one most useful for most purposes.

@Carl Love After seeing a Reply by Acer above, I realize that of course doing 2 substitutions is better than doing n indexing operations, so I change the above to

n:= 10: 
cat(seq(subs([0= "T", 1= "H"], rtable(1..n, random(0..1)))));

Note that even 0 is a pointer in Maple (as can be seen by addressof(0)), so the substitution of 0 only occurs once rather than at every array position that contains (likewise for 1, of course).

Something that Daniel just said makes me think that maybe there's a possibility that you want to share RAM memory across some open worksheets, so that when a variable is changed in one, it's also changed in the other (because they're literally the same variable, with the same memory address). This is easy to do in Maple if you accept these conditions:

  • It's all or nothing: To do this, you must share all memory: Anything that can be seen in one worksheet can be seen in the other, including the countless global variables that are deeply hidden in the Maple library code that you probably don't know about.
  • It's totally up to you to avoid the crazy conflicts that can occur if the two worksheets write to the same memory.

If this is what you want, let me know. It's trivial to set this up, and it works decently if you're not actively executing code in both worksheets at the same time. This kind of link between worksheets is broken when they're closed; it's not like a workbook.

First 288 289 290 291 292 293 294 Last Page 290 of 711