acer

32303 Reputation

29 Badges

19 years, 308 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

int(sec(x)^2,x); acer
int(sec(x)^2,x); acer
Thanks Joe, It's tricky. If one doesn't re-select the whole entry, in between those steps, then one can end up with the object conjugate(`#mi("foo")`). It has to be done just right, to get `#mover(mi("foo"),mo("¯"))` as the atomic identifier. And there doesn't seem to be a nice easy visual way to tell what one has actually obtained. I notice that, having already tagged this accented foo as an atomic identifier, reselecting it and going into the context-menu again does not show the Atomic identifier checkbox as checked. This may be a bug. So not only is there no nice (not lprint) programmatic or visual way to ascertain the input object's "atomic identifier status", the clicky context-menu way is also problematic. It would be very nice to have a fully programmatic (no mouse, non-interactive, non-command-completion) way in which to enter all types of object -- including those from the palettes -- that get fully typeset as 2D Math input. acer
Thanks Joe, It's tricky. If one doesn't re-select the whole entry, in between those steps, then one can end up with the object conjugate(`#mi("foo")`). It has to be done just right, to get `#mover(mi("foo"),mo("¯"))` as the atomic identifier. And there doesn't seem to be a nice easy visual way to tell what one has actually obtained. I notice that, having already tagged this accented foo as an atomic identifier, reselecting it and going into the context-menu again does not show the Atomic identifier checkbox as checked. This may be a bug. So not only is there no nice (not lprint) programmatic or visual way to ascertain the input object's "atomic identifier status", the clicky context-menu way is also problematic. It would be very nice to have a fully programmatic (no mouse, non-interactive, non-command-completion) way in which to enter all types of object -- including those from the palettes -- that get fully typeset as 2D Math input. acer
It's not the initial double underscore that is key, judging by experiment. It is that particular string. It may be used internally to denote the absence of a supplied legend by the user. As a design, I'd prefer to see the kernel or interface's built-in plotter be able to accept *no* legend to denote that situation. Maybe that's a matter of taste. acer
There are quite a few talented Maple programmers in this world. An open source distributed computing maple add-on might be a good project. I could imagine that it might use Maple's Sockets package to distribute well-packaged subtasks out to seperate, distributed maple instances. I'm surprised that there are few significant add-on packages for Maple developed outside of Maplesoft itself. I don't see why, with such a large an talented expert base, a commercial piece of software like Maple doesn't have more high quality open source (and possibly "free") contributions. After all, one of Maple's strengths is the relative ease with which it can be extended. acer
There are quite a few talented Maple programmers in this world. An open source distributed computing maple add-on might be a good project. I could imagine that it might use Maple's Sockets package to distribute well-packaged subtasks out to seperate, distributed maple instances. I'm surprised that there are few significant add-on packages for Maple developed outside of Maplesoft itself. I don't see why, with such a large an talented expert base, a commercial piece of software like Maple doesn't have more high quality open source (and possibly "free") contributions. After all, one of Maple's strengths is the relative ease with which it can be extended. acer
> f := module() export g; g:=proc(x) x; end proc; end module: > evalhf(f:-g(1.1)); 1.10000000000000008 > evalhf(proc() f:-g(1.1); end proc()); Error, unable to evaluate function `f:-g` in evalhf > proc() f:-g(1.1); end proc(); 1.1 > g:=proc(x) x; end proc: > evalhf(proc() g(1.1); end proc()); 1.10000000000000008 There are two problems. The first was that top-level global sin was used instead of the module export foo:-sin. The second is that, more generally, evalhf can find and use module exports when outside a procedure but not when within procedures. acer
To evaluate an expression at an instance of a variable, use the eval() command in its two-argument form. For example, E := sin(x)+x; eval(E,x=4.0); That will evaluate E with 4.0 as the value for x. acer
The left-column space has almost nothing in it, while the right column space is much too full. The "Recent Comments" list, in the right column, is the fastest changing, so it should be right up near the top. It's unpleasant how, if one misses a comment before it passes out of this summary list by being superceded, it can't be found again without having to scan the dates on all the forums. And even then, clicking in the forum pages' topic links gets one only to the start of the topic, not to the most recent comment which is then so much harder to find. Slowly changing summaries like recent blogs should be lower in the right column, and it changes so slowly. It also has a nice convenient backup mechanism to help one locate the recent blogs, in the top bar. If it has a top bar tab, like blogs does, it should be father down in the right column. The announcements could go in the left column. Good idea, Axel. My last suggestion here is that some (any, actually) of the other suggestions posted in the past be addressed. Those include comment title's overwriting content when browsers are not maximized, adding a bug reporting mechanism, fixing the way commonalities in user profiles (which appear as links) don't work, and returning the view count on blog entires (which Will said he look into, quite a while ago). acer
While I thank you for the response, Jacques, I'll say that it sounds more like a description of the mechanism that might be used than a rationale for the behaviour. Which new user wouldn't get caught by this? Which expert would guess the (new to Maple 11) behaviour? It's quite a fumble. In Maple 10, it did not work like that. Maple would issue an error saying that p:-sin was unknown to it. Eg, "Error, unable to evaluate function `p:-sin` in evalhf". If Maple 10 can figure out that p:-sin is unknown to it, then Maple 11 should be able to figure out not to dispatch to the global :-sin wherever the code contains the module member p:-sin. It's a strange behaviour. Did I miss where it's documented, I wonder? Would it affect all function names mentioned in the help-page ?evalhf,fcnlist ? acer
In Maple 11, > save "myfile.m": Error, must specify names to save > a:=proc() local x; x; end: > x:=5; > y:=a(); > save y,a,x, "gg.m"; > quit And now, in a new session, > read "gg.m"; > y; 5 Did it ever actually save the local nature of the `x` which had been assigned to y? Could it be done with a .mla and savelib? It seems not. Also, did the save to .m mechanism ever fully support modules? Another interesting example. Robert Israel (and Joe Riel) showed recently on comp.soft-sys.math.maple how to create a Vector/Matrix with the same symbol for the "unassigned" entries. For example, U := Vector(2,symbol=convert('U',`local`)); (I doubt this is a sensible desire, since it bypasses certain guards on recursive assignments -- which would normally be desirable. Eg, U:=5*U, followed by accessing U[1]. Compare with the behaviour there of last_name_eval vector/matrix/array. But the user seemed insistent.) If I do, > save U, "gg.m"; > quit then, > read "gg.m"; > U; Execution stopped: Stack limit reached. so again the local nature of the U in the entries seems not preserved. But, if instead I savelib the U Vector to a .mla, then in a susequent session I can apparently access U, U[1], etc. The difference is interesting. acer
In Maple 11, > save "myfile.m": Error, must specify names to save > a:=proc() local x; x; end: > x:=5; > y:=a(); > save y,a,x, "gg.m"; > quit And now, in a new session, > read "gg.m"; > y; 5 Did it ever actually save the local nature of the `x` which had been assigned to y? Could it be done with a .mla and savelib? It seems not. Also, did the save to .m mechanism ever fully support modules? Another interesting example. Robert Israel (and Joe Riel) showed recently on comp.soft-sys.math.maple how to create a Vector/Matrix with the same symbol for the "unassigned" entries. For example, U := Vector(2,symbol=convert('U',`local`)); (I doubt this is a sensible desire, since it bypasses certain guards on recursive assignments -- which would normally be desirable. Eg, U:=5*U, followed by accessing U[1]. Compare with the behaviour there of last_name_eval vector/matrix/array. But the user seemed insistent.) If I do, > save U, "gg.m"; > quit then, > read "gg.m"; > U; Execution stopped: Stack limit reached. so again the local nature of the U in the entries seems not preserved. But, if instead I savelib the U Vector to a .mla, then in a susequent session I can apparently access U, U[1], etc. The difference is interesting. acer
My reasoning was as follows. Since the external routines for matrix exponential demand full rectangular hardware datatype Matrices, then have hermitian_basis produce those in the first place (to avoid copies). This should avoid a lot of copying, and allow the evalf calls around Matrix results to be avoided. I also used some lower level (but not undocumented, internal) functions to do the linear algebra, although I wouldn't expect that to compare with the effect of avoiding copies and using the hardware datatype. I removed some conversions, where it seemed possible. Please check for correctness, and adjust accordingly. :) I didn't get as much of a speedup and memory improvement as I hoped for, only about 33% or so on N=20.
################################################################################
hermitian_basis := proc(N::posint)
#
# returns a list of N^2-1 traceless, orthogonal, hermitian NxN matrices
# (generalized Pauli or Gell-Mann matrices) which form a basis of a
# vector space and can serve as the generators of SU(N). For N=2,
# this yields the normal Pauli matrices.
# The procedure follows [Tilma, Sudarshan, J. Phys. A 35 (2002) 10467]
#
options cache;
local kronecker_symbol, temp_list, temp_list_counter, lambda, lambda1,
      lambda2, i, j, mu, nu, st, scal;
st:=time();
Digits := max(Digits,trunc(evalhf(Digits)));
kronecker_symbol := (a,b) -> if a=b then 1 else 0 end if;
#
# following the reference, first two sets of linearly independent hermitian
# matrices (lambda1, lambda2) are generated and stored in a temporary list.
#
temp_list :=
[seq( seq( op([Matrix(N, (mu,nu)->kronecker_symbol(j,mu)*kronecker_symbol(i,nu)
                             +kronecker_symbol(j,nu)*kronecker_symbol(i,mu),
                 datatype=complex(float)),
          Matrix(N, (mu,nu)->-I*(kronecker_symbol(i,mu)*kronecker_symbol(j,nu)
                             -kronecker_symbol(i,nu)*kronecker_symbol(j,mu)),
                 datatype=complex(float)) ]),
          i=1..j-1 ), j=1..N )];
#
# the remaining N-1 matrices are generated (as described in the reference).
#
for i from 2 to N do
   lambda[i^2-1] := Matrix(N, datatype=complex(float)):
   # Since only diagonal elements are nonzero, scale them as assigned,
   # instead of scaling each whole Matrix. Check which is better.
   scal := evalf(sqrt(2/(i^2-i)));
   for j from 1 to i-1 do
      lambda[i^2-1][j,j] := scal; # was 1
   end do;
  lambda[i^2-1][i,i] := (-i+1)*scal; # was -i+1
  #LinearAlgebra:-LA_Main:-MatrixScalarMultiply(lambda[i^2-1],scal,inplace=true,outputoptions=[]);
end do:
                                                                                                                                           
#
# now the matrices from the temporary list and the matrices with fixed index
# are combined to a single list
#
temp_list_counter := 1;
for i from 1 to N^2-1 do
   if not assigned(lambda[i]) then
      lambda[i] := temp_list[temp_list_counter];
      temp_list_counter := temp_list_counter + 1;
   end if;
end do;
printf("hb time: %a \n", time()-st);
return lambda;
end proc:
####################################################################################                                                                                                                                            
####################################################################################
parametrize_unitary_Euler := proc(N::posint)
#
# returns a list containing a general NxN unitary matrix as described by the
# given list of parameters (or the keyword "random").
# The procedure follows [Tilma, Sudarshan, J. Phys. A 35 (2002) 10467] (see Eq. (19))
#
local lambda, i, j, k, m, alpha, used_lambdas, U, st, temp;
st := time();
#
# create a list of N^2-1 (uniformly distributed) random numbers in the
# range 0..2*Pi. These are actually the random parameters for the unitary matrix.
#
alpha := RandomTools[Generate](list(float(range=0..evalf(2*Pi), method=uniform), N^2-1));
                                                                                                                                           
#
# first, a list of the generalized Gell-Mann matrices is needed as
# a hermitian basis of the space of NxN matrices.
#
lambda := hermitian_basis(N);
                                                                                                                                           
#
# define auxiliary function j(m) as in the reference
#
#j := m -> piecewise(m=N, 0, sum(2*(m+l), l=0..N-m-1));
#
# actually the same but easier is the following
j := m -> (N+m-1)*(N-m);
                                                                                                                                           
#
# create a list of those lambda matrices that are actually used
# (in the order of later use, including multiple occurrences)
#
used_lambdas := Vector(N^2-1):
i := 1;
for m from N to 2 by -1 do
   for k from 2 to m do
      used_lambdas[i]   := 3;
      used_lambdas[i+1] := (k-1)^2 + 1;
      i := i+2;
   end do:
end do:
for m from 2 to N do
   used_lambdas[i] := m^2-1;
   i := i+1;
end do:
printf("puE 1st time: %a \n", time()-st);
temp := LinearAlgebra:-LA_Main:-MatrixScalarMultiply(
              lambda[used_lambdas[1]], I*alpha[used_lambdas[1]],
              inplace=false, outputoptions=[]);
U := LinearAlgebra:-LA_Main:-MatrixFunction(
              temp, exp(dummy), dummy, outputoptions=[]);
for k from 2 to op(1,used_lambdas) do
   temp := LinearAlgebra:-LA_Main:-MatrixScalarMultiply(
                 lambda[used_lambdas[k]], I*alpha[used_lambdas[k]],
                 inplace=false, outputoptions=[]);
   U := LinearAlgebra:-LA_Main:-MatrixMatrixMultiply(
                 U, LinearAlgebra:-LA_Main:-MatrixFunction(
                             temp, exp(dummy), dummy, outputoptions=[]),
                             inplace=false, outputoptions=[]);
end do;
printf("puE time: %a \n", time()-st);
return U;
                                                                                                                                           
end proc:
#########################################################################################
                                                                                                                                           
NN := 20:
st,ba:=time(),kernelopts(bytesalloc):parametrize_unitary_Euler(NN):time()-st,kernelopts(bytesalloc)-ba;
st,ba:=time(),kernelopts(bytesalloc):parametrize_unitary_Euler(NN):time()-st,kernelopts(bytesalloc)-ba;
acer
My reasoning was as follows. Since the external routines for matrix exponential demand full rectangular hardware datatype Matrices, then have hermitian_basis produce those in the first place (to avoid copies). This should avoid a lot of copying, and allow the evalf calls around Matrix results to be avoided. I also used some lower level (but not undocumented, internal) functions to do the linear algebra, although I wouldn't expect that to compare with the effect of avoiding copies and using the hardware datatype. I removed some conversions, where it seemed possible. Please check for correctness, and adjust accordingly. :) I didn't get as much of a speedup and memory improvement as I hoped for, only about 33% or so on N=20.
################################################################################
hermitian_basis := proc(N::posint)
#
# returns a list of N^2-1 traceless, orthogonal, hermitian NxN matrices
# (generalized Pauli or Gell-Mann matrices) which form a basis of a
# vector space and can serve as the generators of SU(N). For N=2,
# this yields the normal Pauli matrices.
# The procedure follows [Tilma, Sudarshan, J. Phys. A 35 (2002) 10467]
#
options cache;
local kronecker_symbol, temp_list, temp_list_counter, lambda, lambda1,
      lambda2, i, j, mu, nu, st, scal;
st:=time();
Digits := max(Digits,trunc(evalhf(Digits)));
kronecker_symbol := (a,b) -> if a=b then 1 else 0 end if;
#
# following the reference, first two sets of linearly independent hermitian
# matrices (lambda1, lambda2) are generated and stored in a temporary list.
#
temp_list :=
[seq( seq( op([Matrix(N, (mu,nu)->kronecker_symbol(j,mu)*kronecker_symbol(i,nu)
                             +kronecker_symbol(j,nu)*kronecker_symbol(i,mu),
                 datatype=complex(float)),
          Matrix(N, (mu,nu)->-I*(kronecker_symbol(i,mu)*kronecker_symbol(j,nu)
                             -kronecker_symbol(i,nu)*kronecker_symbol(j,mu)),
                 datatype=complex(float)) ]),
          i=1..j-1 ), j=1..N )];
#
# the remaining N-1 matrices are generated (as described in the reference).
#
for i from 2 to N do
   lambda[i^2-1] := Matrix(N, datatype=complex(float)):
   # Since only diagonal elements are nonzero, scale them as assigned,
   # instead of scaling each whole Matrix. Check which is better.
   scal := evalf(sqrt(2/(i^2-i)));
   for j from 1 to i-1 do
      lambda[i^2-1][j,j] := scal; # was 1
   end do;
  lambda[i^2-1][i,i] := (-i+1)*scal; # was -i+1
  #LinearAlgebra:-LA_Main:-MatrixScalarMultiply(lambda[i^2-1],scal,inplace=true,outputoptions=[]);
end do:
                                                                                                                                           
#
# now the matrices from the temporary list and the matrices with fixed index
# are combined to a single list
#
temp_list_counter := 1;
for i from 1 to N^2-1 do
   if not assigned(lambda[i]) then
      lambda[i] := temp_list[temp_list_counter];
      temp_list_counter := temp_list_counter + 1;
   end if;
end do;
printf("hb time: %a \n", time()-st);
return lambda;
end proc:
####################################################################################                                                                                                                                            
####################################################################################
parametrize_unitary_Euler := proc(N::posint)
#
# returns a list containing a general NxN unitary matrix as described by the
# given list of parameters (or the keyword "random").
# The procedure follows [Tilma, Sudarshan, J. Phys. A 35 (2002) 10467] (see Eq. (19))
#
local lambda, i, j, k, m, alpha, used_lambdas, U, st, temp;
st := time();
#
# create a list of N^2-1 (uniformly distributed) random numbers in the
# range 0..2*Pi. These are actually the random parameters for the unitary matrix.
#
alpha := RandomTools[Generate](list(float(range=0..evalf(2*Pi), method=uniform), N^2-1));
                                                                                                                                           
#
# first, a list of the generalized Gell-Mann matrices is needed as
# a hermitian basis of the space of NxN matrices.
#
lambda := hermitian_basis(N);
                                                                                                                                           
#
# define auxiliary function j(m) as in the reference
#
#j := m -> piecewise(m=N, 0, sum(2*(m+l), l=0..N-m-1));
#
# actually the same but easier is the following
j := m -> (N+m-1)*(N-m);
                                                                                                                                           
#
# create a list of those lambda matrices that are actually used
# (in the order of later use, including multiple occurrences)
#
used_lambdas := Vector(N^2-1):
i := 1;
for m from N to 2 by -1 do
   for k from 2 to m do
      used_lambdas[i]   := 3;
      used_lambdas[i+1] := (k-1)^2 + 1;
      i := i+2;
   end do:
end do:
for m from 2 to N do
   used_lambdas[i] := m^2-1;
   i := i+1;
end do:
printf("puE 1st time: %a \n", time()-st);
temp := LinearAlgebra:-LA_Main:-MatrixScalarMultiply(
              lambda[used_lambdas[1]], I*alpha[used_lambdas[1]],
              inplace=false, outputoptions=[]);
U := LinearAlgebra:-LA_Main:-MatrixFunction(
              temp, exp(dummy), dummy, outputoptions=[]);
for k from 2 to op(1,used_lambdas) do
   temp := LinearAlgebra:-LA_Main:-MatrixScalarMultiply(
                 lambda[used_lambdas[k]], I*alpha[used_lambdas[k]],
                 inplace=false, outputoptions=[]);
   U := LinearAlgebra:-LA_Main:-MatrixMatrixMultiply(
                 U, LinearAlgebra:-LA_Main:-MatrixFunction(
                             temp, exp(dummy), dummy, outputoptions=[]),
                             inplace=false, outputoptions=[]);
end do;
printf("puE time: %a \n", time()-st);
return U;
                                                                                                                                           
end proc:
#########################################################################################
                                                                                                                                           
NN := 20:
st,ba:=time(),kernelopts(bytesalloc):parametrize_unitary_Euler(NN):time()-st,kernelopts(bytesalloc)-ba;
st,ba:=time(),kernelopts(bytesalloc):parametrize_unitary_Euler(NN):time()-st,kernelopts(bytesalloc)-ba;
acer
First 572 573 574 575 576 577 578 Last Page 574 of 591