Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@dingtianlidi You might try upgrading your MapleSim; it appears to be 2019.1. The 2019.2.1 update is available for all users. I don't know that it will resolve this, but I haven't been able to reproduce it in 2019.2.

I have seen the issue with the repeated Re in the probe window; it goes away if the probe is deleted and added.  I'll file a bug report for that.

I haven't been able to reproduce that, neither by using the msim you uploaded nor by opening the example for the Users Guide.  The msim that you uploaded appears to differ slightly from the one whose image you display in that the quantities selected in Probe1 are not the same.  Could you try resaving the msim (that fails) and reuploading it?  Thanks.

@Kitonum A minor point.  A more efficient way to do the sort is to use the key option to sort.

sort(L, 'key' = evalf):

@Carl Love That's because Permute first sorts the list; that was done to more easily handle the case where the list contains repeated items, however, I should probably modify that to avoid sorting unless there are repeated items.  Or eliminate it altogether.  So far as efficiency goes, some small testing indicates that there may not be a benefit to doing the "transfer" I had previously mentioned.

@Carl Love I believe that your method will allocate more memory as a separate Array must be generated for each permutation (even though it is ultimately discarded). That shouldn't be the case when using an assignment with empty brackets on the left hand side (Maple will realize that it should do a transfer, not an allocation).

Note that I updated my response, above.  I had forgotten that Permute can already handle an arbitrary list of expressions, so neither method is necessary.

Also, rtable indexing by an rtable only works with programmer's indices (parentheses, not brackets).

@Carl Love Thanks for the response. There is a more efficient technique to transfer the permutation output of the Permute iterator to a given Array of arbitrary expressions. As with the Iterator design, it reuses an Array to minimize memory allocation.  I'll add this as an example to the Permute help page.

A := Array(1..5,[a,b,c,d,e]): # Array of elements to permute.
B := Array(1..5):             # output Array
P := Iterator:-Permute(5):
for p in P do
    B[] := A(p);              # permute A according to p and store result in B 
    printf("%{}a\n", B);      # print (replace with something useful)
end do:

Followup I had forgotten that Permute already can do this automatically, just pass in the list of expressions:

P := Iterator:-Permute([a,b,c,d,e]):
for p in P do printf("%{}a\n",p); end do:

@Carl Love Another alternative, if you have access to the source code, is to insert a call to  DEBUG() at the point you want to stop at.

@Carl Love Keyword parameters can match more than one keyword, by enclosing the keywords in a list; the first element in the list is used internally.  So for the OP's purpose, a nice way to extend this is the following

PlotGraph:= proc(func::anything
                 , {[view,zoom] :: list({range(realcons), identical(DEFAULT)}) := [DEFAULT$2]}
                )

    plot(func, _options['view'], _rest)
end proc:

Now you call PlotGraph with either the view or zoom option, they do the same thing.

data := ExcelTools:-Import("rr.xlsx"):
amp := data[..,2]:
fsamp := 1/data[2,1];
with(SignalProcessing):
Periodogram(amp, 'samplerate'=fsamp, 'powerscale'="absolute");

Note that the frequency scale is linear, not log, as yours is. I couldn't find an option to use a log scale with the Peridogram function, however, you can always right click on the plot, select axes > properties and set the horizontal scale to log mode. Also note that your plot has a maximum frequency of 50 Hz, which is strange because the sampling frequency is 50 Hz, so the Nyquist limit is 25 Hz.

@kambiz1199 What is the first column?  Time in seconds?

@Christian Wolinski Good question.  I'd probably do something crude like
 

for n to 5 do
    'n'=n, Statistics:-Fit(y, data, x, 'output=[parametervalues,residualsumofsquares]');
end do;
      n = 1, [[m = 1.89016445809072], 0.04365213270]
      n = 2, [[m = 2.04708142901557], 0.002540629258]
      n = 3, [[m = 2.13911489423050], 0.001559320138]
      n = 4, [[m = 2.19055011428686], 0.009593451000]
      n = 5, [[m = 2.22152248102920], 0.01934052765]

Then pick the one with the smallest residual (n=3). Comparing plots would be useful.

@Carl Love Yes, SearchArray is a misnomer. Poorly named methods are a nuisance, they hide in the help. I chose to roll my own, with seq.  I wasn't clever enough to use your transposition trick to avoid some code duplication.

@Carl Love Some good ideas in there.  Profiling the routine reveals that, at least for the random matrix you provided, most of the time is spent in Tally.  I believe that can be reduced significantly by tallying once, for the original matrix, then updating the tally for subsequent calls by just checking omitted row/column.  Here's the basic idea, though I used number of zeros rather than number of non-zeros (haven't paid much attention to whether it is correct, though the result matches yours).

Determinant2 := module()

export
    ModuleApply := proc(A :: Matrix(square))
    local ZerosInCols, ZerosInRows, i, j, n;

        n := upperbound(A,1);
        if n=0 then
            return 1;
        elif n=1 then
            return A[1,1];
        end if;

        ZerosInCols := [seq(add(ifelse(A[i,j]=0,1,0), i=1..n), j=1..n)];
        ZerosInRows := [seq(add(ifelse(A[i,j]=0,1,0), j=1..n), i=1..n)];

        Det(A, n, ZerosInRows, ZerosInCols);

    end proc;

export
    Det := proc(A :: Matrix
                , n :: posint
                , ZerosInRows :: list
                , ZerosInCols :: list
               )
    local c, cols, i, j, mx, r, rows, zerosInCols, zerosInRows;

        if n=1 then
            return A[1,1];
        end if;

        # find row or column with most zeros
        mx := max(ZerosInCols);
        if mx = n then return 0; end if;
        member(mx, ZerosInCols, 'c');
        mx := max(ZerosInRows);
        member(mx, ZerosInRows, 'r');
        if mx = n then return 0; end if;

        if c >= r then
            # use the c column
            zerosInRows := [seq(ifelse(A[i,c] = 0
                                       , ZerosInRows[i] - 1
                                       , ZerosInRows[i]
                                      ), i = 1..n)];
            cols := [..c-1,c+1..];
            add(ifelse(A[i,c] = 0
                       , 0
                       , (-1)^(c+i)*A[i,c]*thisproc(A[[..i-1,i+1..],cols]
                                                    , n-1
                                                    , subsop(i=NULL, zerosInRows)
                                                    , subsop(c=NULL, [seq(ifelse(A[i,j] = 0
                                                                                 , ZerosInCols[j]-1
                                                                                 , ZerosInCols[j]
                                                                                ), j = 1..n)])
                                                   )
                      )
                , i = 1..n);
        else
            # use the r row
            zerosInCols := [seq(ifelse(A[r,j] = 0
                                       , ZerosInCols[j] - 1
                                       , ZerosInCols[j]
                                      ), j = 1..n)];
            rows := [..r-1,r+1..];
            add(ifelse(A[r,j] = 0
                       , 0
                       , (-1)^(r+j)*A[r,j]*thisproc(A[rows, [..j-1,j+1..]]
                                                    , n-1
                                                    , subsop(r=NULL, [seq(ifelse(A[i,j] = 0
                                                                                 , ZerosInRows[i]-1
                                                                                 , ZerosInRows[i]
                                                                                ), i = 1..n)])
                                                    , subsop(j=NULL, zerosInCols)
                                                   )
                      )
                , j = 1..n);
        end if;

    end proc;

end module:

@Carl Love While a numeric power is handled

simplify(polar(r,theta)^3);
       polar(r^3, 3*theta)

a symbolic power is not

simplify(polar(r,theta)^n) assuming n :: real;
          polar(r,theta)^n

While the behavior still appears in Maple 2019.2, it has been fixed in the development version of Maple.

First 16 17 18 19 20 21 22 Last Page 18 of 195