Changeset 4508b59 in git for Singular/LIB/ring.lib
- Timestamp:
- May 18, 2005, 8:07:51 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 1fdee99658b607d182587d2a784cf9de89f5db6d
- Parents:
- 681d3d8000f4e53193c36f55c66b160df94096f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ring.lib
r681d3d r4508b59 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: ring.lib,v 1.2 5 2005-05-06 14:39:08 hannesExp $";2 version="$Id: ring.lib,v 1.26 2005-05-18 18:07:51 levandov Exp $"; 3 3 category="General purpose"; 4 4 info=" … … 21 21 preimageLoc(R,phi,Q) computes preimage for non-global orderings 22 22 (parameters in square brackets [] are optional) 23 rootofUnity(n); the minimal polynomial for the n-th primitive root of unity 23 24 "; 24 25 … … 863 864 nu; 864 865 } 866 867 ////////////////////////////////////////////////////////////////////////////// 868 /* moved here from the nctools.lib */ 869 /////////////////////////////////////////////////////////////////////////////// 870 proc rootofUnity(int n) 871 "USAGE: rootofUnity(n); n an integer 872 RETURN: number 873 PURPOSE: compute the minimal polynomial for the n-th primitive root of unity 874 NOTE: works only in field extensions by one element 875 EXAMPLE: example rootofUnity; shows examples 876 " 877 { 878 if ( npars(basering) !=1 ) 879 { 880 "the procedure works only with one parameter"; 881 return(0); 882 } 883 if (n<1) { return(0); } 884 number mp = par(1); 885 if (n==1) { return(mp-1); } 886 if (n==2) { return(mp+1); } 887 def OldRing = basering; 888 string CH = charstr(basering); 889 string MCH; 890 int j=1; 891 while ( (CH[j] !=",") && (j<=size(CH))) 892 { 893 MCH=MCH+CH[j]; j++; 894 } 895 string SR = "ring @@rR="+MCH+","+parstr(basering)+",dp;"; 896 execute(SR); 897 poly @t=var(1)^n-1; // (x^2i-1)=(x^i-1)(x^i+1) 898 list l=factorize(@t); 899 ideal @l=l[1]; 900 list @d; 901 int s=size(@l); 902 int d=deg(@l[s]); 903 int cnt=1; 904 poly res; 905 for (j=s-1; j>=1; j--) 906 { 907 if ( deg(@l[j]) > d) { d=deg(@l[j]); } 908 } 909 for (j=1; j<=s; j++) 910 { 911 if ( deg(@l[j]) == d) { @d[cnt]=@l[j]; cnt++; } 912 } 913 if ( size(@d)==1 ) 914 { 915 res = poly(@d[1]); 916 } 917 else 918 { 919 j=1; 920 while ( j <= size(@d) ) 921 { 922 res = @d[j]-lead(@d[j]); 923 if ( leadcoef(res) >=0 ) { j++; } 924 else { break; } 925 } 926 res = @d[j]; 927 } 928 setring OldRing; 929 poly I = imap(@@rR,res); 930 mp = leadcoef(I); 931 kill @@rR; 932 return(mp); 933 } 934 example 935 { 936 "EXAMPLE:";echo=2; 937 ring r = (0,q),(x,y,z),dp; 938 rootofUnity(6); 939 rootofUnity(7); 940 minpoly = rootofUnity(8); 941 r; 942 }
Note: See TracChangeset
for help on using the changeset viewer.