Changeset 70b4f4 in git for HOWTO-libsingular
- Timestamp:
- May 20, 2011, 1:07:47 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
- Children:
- f6c50d15094fcdfe9d9f134bb3b061760aa62b3e
- Parents:
- b5cd25f4f43ce3d4a37ddaab1030082d1f09c0b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
HOWTO-libsingular
rb5cd25f r70b4f4 26 26 the example: 27 27 #include <libsingular.h> 28 voidmain()28 main() 29 29 { 30 30 // init path names etc. 31 siInit((char *)"/ home/hannes/singular-gap/Singular/p_Procs_FieldZp.so");31 siInit((char *)"/...Singular-3-1-3/Singular/libsingular.so"); 32 32 33 33 // construct the ring Z/32003[x,y,z] … … 36 36 n[0]=omStrDup("x"); 37 37 n[1]=omStrDup("y"); 38 n[2]=omStrDup("z ");38 n[2]=omStrDup("z2"); 39 39 40 40 ring R=rDefault(32003,3,n); … … 58 58 pWrite(p1); 59 59 60 // clean up:60 // clean up: 61 61 pDelete(&p1); 62 62 rKill(R); 63 64 currentVoice=feInitStdin(NULL); 65 // hook for error handling: 66 // WerrorS_callback=......; of type p(const char *) 67 int err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL); 68 if (err) errorreported = 0; // reset error handling 69 printf("interpreter returns %d\n",err); 70 idhdl h=ggetid("ver"); 71 if (h!=NULL) 72 printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h)); 73 else 74 printf("variable ver does not exist\n"); 75 76 // calling a singular-library function 77 idhdl datetime=ggetid("datetime"); 78 if (datetime==NULL) 79 printf("datetime not found\n"); 80 else 81 { 82 leftv res=iiMake_proc(datetime,NULL,NULL); 83 if (res==NULL) { printf("datetime return an error\n"); errorreported = 0; } 84 else printf("datetime returned type %d, >>%s<<\n",res->Typ(),(char *)res->Data()); 85 } 86 87 // calling a kernel function via the interpreter interface 88 sleftv r1; memset(&r1,0,sizeof(r1)); 89 sleftv arg; memset(&arg,0,sizeof(r1)); 90 arg.rtyp=STRING_CMD; 91 arg.data=omStrDup("huhu"); 92 err=iiExprArith1(&r1,&arg,TYPEOF_CMD); 93 printf("interpreter returns %d\n",err); 94 if (err) errorreported = 0; // reset error handling 95 else printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data()); 96 // clean up r1: 97 r1.CleanUp(); 63 98 }
Note: See TracChangeset
for help on using the changeset viewer.