Joe Riel

9660 Reputation

23 Badges

20 years, 9 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@Alejandro Jakubi Technically your first point is not, I believe, a bug. The conversion for a rooted vector does not interpret the r, phi, and z symbols as names of coordinates. That is, there is no reason to assume that the value of the angle (phi=0) corresponds to the symbol phi in the component of the tangent vector.  That the call gives the correct answer in my use of RootedVector is because I used the same names.  But I could have used any symbols, so long as I was consistent.  For example

v1 := RootedVector(root=<a,b,c>,[3*cos(b),-2*a,5]):
MapToBasis(v1,cartesian);
                        [           2                ]
                        [   3 cos(b)  + 2 a sin(b)   ]
                        [                            ]
                        [3 sin(b) cos(b) - 2 a cos(b)]
                        [                            ]
                        [             5              ]

You wouldn't expect that to substitute b=0 if the second component of the root vector were 0.

By using the coordinate names in the root vector, I was able to get the expected result. Of course, that is kind of cheating and probably lends to the confusion. It is essentially the same as using a VectorField.

@Alejandro Jakubi Technically your first point is not, I believe, a bug. The conversion for a rooted vector does not interpret the r, phi, and z symbols as names of coordinates. That is, there is no reason to assume that the value of the angle (phi=0) corresponds to the symbol phi in the component of the tangent vector.  That the call gives the correct answer in my use of RootedVector is because I used the same names.  But I could have used any symbols, so long as I was consistent.  For example

v1 := RootedVector(root=<a,b,c>,[3*cos(b),-2*a,5]):
MapToBasis(v1,cartesian);
                        [           2                ]
                        [   3 cos(b)  + 2 a sin(b)   ]
                        [                            ]
                        [3 sin(b) cos(b) - 2 a cos(b)]
                        [                            ]
                        [             5              ]

You wouldn't expect that to substitute b=0 if the second component of the root vector were 0.

By using the coordinate names in the root vector, I was able to get the expected result. Of course, that is kind of cheating and probably lends to the confusion. It is essentially the same as using a VectorField.

@Alejandro Jakubi The root vector in your first example was elided from the output. Use pre-formatted to avoid that.

@Alejandro Jakubi The root vector in your first example was elided from the output. Use pre-formatted to avoid that.

You are missing a double quote.  Try

# !/bin/bash

for dist in "100" "200" ; do
    nohup nice -n19 maple -c "assign(distance,convert($dist,string))" <code.mpl> out_$dist.out &
done

Note that I changed convert($dist,str) to convert($dist,string), since 'str' is not a Maple conversion.

You are missing a double quote.  Try

# !/bin/bash

for dist in "100" "200" ; do
    nohup nice -n19 maple -c "assign(distance,convert($dist,string))" <code.mpl> out_$dist.out &
done

Note that I changed convert($dist,str) to convert($dist,string), since 'str' is not a Maple conversion.

@veil007 Shortly after posting my response I realized that it didn't adequately (if at all) address your issue.  An interesting problem, I'll think about it.

@veil007 Shortly after posting my response I realized that it didn't adequately (if at all) address your issue.  An interesting problem, I'll think about it.

@Alejandro Jakubi Yes.  Without the anchors my version does a partial match, that is, it returns true if the regular expressions matches some subexpression of sym. The anchors ensure that it returns true only if the entire expression is matched. One could add the anchors in the code, say, with cat("^", pat, "$"), however, that requires allocating another string and is slightly less general.

Thanks for the useful post. A generalization is to forego the extraction of the match and just return the evaluated boolean. That allows the user to do a partial match, or, if desired, explicitly add the anchors ("^" and "$") to the regular expression to do  a complete match. As a bonus that is a faster matcher and uses less memory, however, neither may be a concern, or significant. That is, one could assign

TypeTools:-AddType( regexp,
                    proc(sym, pat)
                        type(sym, '{symbol,string}')
                        and type(pat, '{symbol, string}')
                        and StringTools:-RegMatch(pat, sym)
                    end proc ):
type(myFuncA01, regexp("^[a-zA-Z]+A[0-9]+$"));

@hirnyk Here's one approach to enumerating them (it)

StoreSymmetric := proc(L::list,A,n::posint)
description "fill symmetric matrix A with list L";
local i,j,k;
    k := 0;
    for i to n do
        for j from i to n do
            k := k+1;
            A[i,j] := L[k];
        end do;
    end do;
    return NULL;
end proc:

PositiveDefinite := proc(n::posint)
description "return all symmetric, positive definite matrices of order n with entries 0 and 1";
local A,M,N,i,cnt,eigs;
    A := Matrix(n, 'shape=symmetric');
    N := 1/2*n*(n+1);
    M := table();
    cnt := 0;
    for i to 2^N-1 do
        StoreSymmetric(Bits:-Split(i,'bits'=N),A,n);
        eigs := LinearAlgebra:-Eigenvalues(evalf(A));
        if andmap(`>`, eigs, 0) then
            cnt := cnt+1;
            M[cnt] := copy(A);
        end if;
    end do;
    return seq(M[cnt], cnt=1..cnt);
end proc:

PositiveDefinite(5);

@hirnyk Here's one approach to enumerating them (it)

StoreSymmetric := proc(L::list,A,n::posint)
description "fill symmetric matrix A with list L";
local i,j,k;
    k := 0;
    for i to n do
        for j from i to n do
            k := k+1;
            A[i,j] := L[k];
        end do;
    end do;
    return NULL;
end proc:

PositiveDefinite := proc(n::posint)
description "return all symmetric, positive definite matrices of order n with entries 0 and 1";
local A,M,N,i,cnt,eigs;
    A := Matrix(n, 'shape=symmetric');
    N := 1/2*n*(n+1);
    M := table();
    cnt := 0;
    for i to 2^N-1 do
        StoreSymmetric(Bits:-Split(i,'bits'=N),A,n);
        eigs := LinearAlgebra:-Eigenvalues(evalf(A));
        if andmap(`>`, eigs, 0) then
            cnt := cnt+1;
            M[cnt] := copy(A);
        end if;
    end do;
    return seq(M[cnt], cnt=1..cnt);
end proc:

PositiveDefinite(5);

Probably you are doing something wrong. Can you show the assignment to Tproc? Did you use an assignment operator, :=, to assign it?

Just to clarify, you want the code in all sections to be executed, but you don't want certain sections to be visually opened during the process, is that correct?  More exactly, when the process [execution of worksheet] is complete, you want the sections to be as they were before execution, either opened or closed.

@Robert Israel Thanks for the correction and explanation.  I suppose it is a feature, if a bit obtuse.  I stick with 1D input because its operation is much simpler to comprehend. Admittedly there are cases where fluency in 2D input is useful.

First 80 81 82 83 84 85 86 Last Page 82 of 195