Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - Problem with writelist and list of matrices
Author Message
  Post subject:  Re: Problem with writelist and list of matrices  Reply with quote
Thank you. It works now. To avoid defining the list every time I read the file, I added a declaration before your for loop:

write(fil, "list " + nam + ";");

Thanks again.

Ravi :)
Post Posted: Tue Sep 15, 2009 3:39 pm
  Post subject:  Re: Problem with writelist and list of matrices  Reply with quote
The cast matrix is incomplete, dimensions nrows and ncols are missing.

To fix the problem for the datataypes matrix and intmat,
change the for-loop as follows

Code:
for( i=1;i<=size(L);i=i+1 )
   {
     if (typeof(L[i]) == "intmat")
     {
       write(fil,"   "+nam+"["+string(i)+"]="+
              "intmat(intvec("+string(L[i])+
          "),"+string(nrows(L[i]))+","+string(ncols(L[i]))+");");
     }
     if ( typeof(L[i])== "matrix")
     {
        write(fil,"   "+nam+"["+string(i)+"]="+
              "matrix(ideal("+string(L[i])+
          "),"+string(nrows(L[i]))+","+string(ncols(L[i]))+");");
     }
     else
     {
       write(fil,"   "+nam+"["+string(i)+"]="+typeof(L[i])+"(",string(L[i])+");");
     }
   }


(Note: Other datatypes as string also do not work properly.)
Post Posted: Tue Sep 15, 2009 12:55 pm
  Post subject:  Problem with writelist and list of matrices  Reply with quote
I have a problem using the writelist function when I write a list of matrices to a file and want to recreate the list in memory by reading the file later on. Here is a simple example:

Code:
ring R = 0, (x,y,z), dp;
matrix A[3][3] = 0,1,0, -1,0,0, 0,0,1;      
matrix B[3][3] = 0,1,0,  0,0,1, 1,0,0;      
matrix C[3][3] = 0,1,0,  1,0,0, 0,0,1;
list L = A,B,C;
writelist("simple-write.txt", "simplist", L);


This creates the text file alright:
list simplist;
simplist[1]=matrix(
0,1,0,-1,0,0,0,0,1);
etc...

but when I try to read it and recreate simplist:

Code:
ring R = 0, (x,y,z), dp;
execute(read("simple-write.txt"));  // does not create the list simplist in memory


The error I get is:
Code:
? error occurred in Read-Oh.sing line 10: `0,1,0,-1,0,0,0,0,1);`
? wrong type declaration. type 'help matrix;'
? last reserved name was `matrix`
skipping text from `-` error at token `)`

According to the help files (D.2.4.9), this should create the object simplist. It works for other objects, but not for lists of matrices.
If someone can tell me what is going wrong, I shall be most grateful...

Ravi
Post Posted: Sat Sep 12, 2009 8:55 am


It is currently Fri May 13, 2022 11:06 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group