35 Reputation

4 Badges

4 years, 328 days

MaplePrimes Activity

These are replies submitted by liushunyi

@Kitonum Thank you very for your help.

@Carl Love Thanks.

@John Fredsted Thank you very much for your kind help.

@Joe Riel I have installed the Iterator package updated, and it works well. Thank you very much.

@Joe Riel Thank you for your code. I don't know why I cannot implement the code correctly. My Maple is of version 17. The error is "(in permanentRyser4) `Iterator` does not evaluate to a module". Again, thank you for your time, patience and help.

@Preben Alsholm Thank you very much for your help.

@Joe Riel Thanks Joe. Thank you for your reply. It seems that I cannot obtain the correct result from you procedure. The following is my procedure:


Count := proc (file::string)
   local line, line1, total, maxi, cnt;
   total := 0;
   maxi := 1;
   cnt := 0;
   line := readline(file);
   while line <> 0 do
       line1 := readline(file);
       if line1 = 0 then
       end if;
      if StringTools:-Compare(line, line1) = true and StringTools:-Compare(line1, line) = true then
          cnt := cnt+1;
          maxi := max(maxi, cnt+1)
          line := line1;
          if cnt>0 then
             total := total+cnt+1;
         end if;
         cnt := 0;
      end if
  end do;
  if cnt>0 then
      total := total+cnt+1;
 end if;
 (total, maxi);

end proc:

@Carl Love Thanks Carl. Concerning the second question, I mean to search for the whole lines only.

@Carl Love Thank you very much for your help. 

@Markiyan Hirnyk Thanks for your answer. I have seen the page you pointed out, but it cannot be applied to my question.

@Joe Riel Thank you very much for your kind help.

@Carl Love Thank you very much for your kind help. The program can be executed without error  according to your advice.

@Joe Riel Thank you very much for your kind reply. I am sorry that I still don't understand the parameter declarations of data and ofile. In my opinion, data is just the file name of input and ofile is the file name of output. Could we remove the declarations data := "read-data-compute-charpoly.dat" and ofile := "read-data-compute-charpoly.poly"? Unfortunately, the program cannot be executed in my notebook computer. It alway returns the error:

Error, (in Compute) invalid subscript selector.

Maple I used is of version 17.00 and the operating system of my computer is Win 7. Because the files data.txt and ofile.txt are stored in the directory: d:\Program Files\Maple 17, I changed the statements fd1 := fopen(data,'READ') and fd2 := fopen(ofile, 'WRITE') to fd1 := fopen("d:\\Program Files\\Maple 17\\data.txt",'READ') and fd2 := fopen("d:\\Program Files\\Maple 17\\ofile.txt", 'WRITE'), respectively. I don't know why the procedure cannot be executed in my computer. Whether the procedure is executed correctly in your computer? I would appreciate if you could check whether the procedure can be executed correctly of this text file (data.txt).

Thanks a lot.

@Joe Riel Thank you very much for your kind help. I don't understand the following statements in your code.

1. In the statement "Compute := proc( data :: string, cols :: posint, ofile :: string )", cols denotes the number of columns. What happens when you delete "data::string" , "ofile:string" and the correspongding "read-data-compute-charpoly.dat" and "read-data-compute-charpoly.poly" in the last statement?

2. What does "A := Matrix(0,1..cols);"  mean? Is the order of A cols+1?

3. What does "B := A[1..i,..];" mean? Is B an i*cols submatrix of A?

I cannot implement the procedure you given in my computer, and it always returns the error information:

Error, (in Compute) invalid subscript selector

Here I want to compute the characteristic polynomials of some 5*5 matrices. The data can be seen in attachment (data.txt) and the procedure is as follows (

Compute := proc (data::string, cols::posint, ofile::string)

local A, B, cnt, fd1, fd2, fmt, i, j, line, p, row, x;

    fd1 := fopen("d:\\Program Files\\Maple 17\\data.txt", 'READ');

    fd2 := fopen("d:\\Program Files\\Maple 17\\ofile.txt", 'WRITE');

    fmt := StringTools:-Repeat("%f", cols);

    A := Matrix(0, 1 .. cols);

    cnt := 0;

    i := 0;


          line := readline(fd1);

          if line = 0 or line = "" or line[1] = "#" then

               if i>0 then

                   cnt := cnt+1;

                    B := A[1..i,..];

                    p := LinearAlgebra:-CharacteristicPolynomial(B, x);

                    p := PolynomialTools:-CoefficientVector(p, x, 'termorder = reverse');

                    fprintf(fd2, "%{c,}a\n", p);

                    i := 0;

                end if;

                if line = 0 then


                 end if;


                 i := i+1;

                 row := sscanf(line, fmt);

                 for j to cols do

                     A(i, j) := row[j];

                 end do;

           end if;

      end do;

      fclose(fd1, fd2);


      end proc:
Compute("read-data-compute-charpoly.dat", 5, "read-data-compute-charpoly.poly");

Best wishes.

1 2 Page 1 of 2