Changeset e68029 in git
- Timestamp:
- Jan 19, 2022, 9:40:11 AM (17 months ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '23b0a9c07070b684aa12355009488dc00d9501e3')
- Children:
- 3882094d003ecd5487dfad0aa941dee9d650a30e
- Parents:
- 844f3006400f1bbcfdb84aa86a873413a954da98
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
r844f30 re68029 1239 1239 #endif 1240 1240 /* ====== rref ============================*/ 1241 #if def HAVE_FLINT1241 #if defined(HAVE_FLINT) || defined(HAVE_NTL) 1242 1242 if(strcmp(sys_cmd,"rref")==0) 1243 1243 { 1244 1244 const short t1[]={1,MATRIX_CMD}; 1245 if (iiCheckTypes(h,t1,1)) 1245 const short t2[]={1,SMATRIX_CMD}; 1246 if (iiCheckTypes(h,t1,0)) 1246 1247 { 1247 1248 matrix M=(matrix)h->Data(); 1249 #if defined(HAVE_FLINT) 1248 1250 res->data=(void*)singflint_rref(M,currRing); 1251 #elif defined(HAVE_NTL) 1252 res->data=(void*)singntl_rref(M,currRing); 1253 #endif 1249 1254 res->rtyp=MATRIX_CMD; 1250 1255 return FALSE; 1251 1256 } 1252 else 1253 { 1254 WerrorS("expected system(\"rref\",<matrix>)"); 1257 else if (iiCheckTypes(h,t2,1)) 1258 { 1259 ideal M=(ideal)h->Data(); 1260 #if defined(HAVE_FLINT) 1261 res->data=(void*)singflint_rref(M,currRing); 1262 #elif defined(HAVE_NTL) 1263 res->data=(void*)singntl_rref(M,currRing); 1264 #endif 1265 res->rtyp=SMATRIX_CMD; 1266 return FALSE; 1267 } 1268 else 1269 { 1270 WerrorS("expected system(\"rref\",<matrix>/<smatrix>)"); 1255 1271 return TRUE; 1256 1272 } -
libpolys/polys/clapsing.cc
r844f30 re68029 24 24 #include "polys/flint_mpoly.h" 25 25 26 #ifdef HAVE_NTL 27 #include <NTL/config.h> 28 #ifdef NTL_STD_CXX 29 #ifdef NOSTREAMIO 30 # ifdef HAVE_IOSTREAM 31 # include <iostream> 32 # define OSTREAM std::ostream 33 # define ISTREAM std::istream 34 # elif defined(HAVE_IOSTREAM_H) 35 # include <iostream.h> 36 # define OSTREAM ostream 37 # define ISTREAM istream 38 # endif 39 #endif /* ! NOSTREAMIO */ 40 #endif 41 #include <NTL/mat_ZZ.h> 42 #include <NTL/mat_lzz_p.h> 43 44 #ifdef NTL_CLIENT // in <NTL/tools.h>: using of name space NTL 45 NTL_CLIENT 46 #endif 47 48 #endif 26 49 27 50 //#include "polys.h" … … 1971 1994 #endif 1972 1995 1996 #ifdef HAVE_NTL 1997 matrix singntl_rref(matrix m, const ring R) 1998 { 1999 int r=m->rows(); 2000 int c=m->cols(); 2001 int i,j; 2002 matrix M=mpNew(r,c); 2003 if (rField_is_Zp(R)) 2004 { 2005 zz_p::init(rChar(R)); 2006 mat_zz_p *NTLM=new mat_zz_p; 2007 NTLM->SetDims(r,c); 2008 for(i=r;i>0;i--) 2009 { 2010 for(j=c;j>0;j--) 2011 { 2012 poly h=MATELEM(m,i,j); 2013 if ((h!=NULL) 2014 && (p_Totaldegree(h,R)==0)) 2015 { 2016 (*NTLM)(i,j)=(long)p_GetCoeff(h,R); 2017 } 2018 else 2019 { 2020 WerrorS("smatrix for rref is not constant"); 2021 return M; 2022 } 2023 } 2024 } 2025 gauss(*NTLM); 2026 for(i=r;i>0;i--) 2027 { 2028 for(j=c;j>0;j--) 2029 { 2030 number n=n_Init(rep((*NTLM)(i,j)),R->cf); 2031 if(!n_IsZero(n,R->cf)) 2032 { 2033 poly p=p_NSet(n,R); 2034 p_SetComp(p,i,R); 2035 M->m[j]=p_Add_q(M->m[j],p,R); 2036 } 2037 } 2038 } 2039 delete NTLM; 2040 } 2041 else 2042 { 2043 WerrorS("not implemented for these coefficients"); 2044 } 2045 return M; 2046 } 2047 #endif 2048 2049 #ifdef HAVE_NTL 2050 ideal singntl_rref(ideal m, const ring R) /*assume smatrix m*/ 2051 { 2052 int r=m->rank; 2053 int c=m->ncols; 2054 int i,j; 2055 ideal M=idInit(c,r); 2056 if (rField_is_Zp(R)) 2057 { 2058 zz_p::init(rChar(R)); 2059 mat_zz_p *NTLM=new mat_zz_p; 2060 NTLM->SetDims(r,c); 2061 for(j=c;j>0;j--) 2062 { 2063 poly h=m->m[j]; 2064 while(h!=NULL) 2065 { 2066 i=p_GetComp(h,R); 2067 if (p_Totaldegree(h,R)==0) 2068 (*NTLM)(i,j)=(long)p_GetCoeff(h,R); 2069 else 2070 { 2071 WerrorS("smatrix for rref is not constant"); 2072 return M; 2073 } 2074 pIter(h); 2075 } 2076 } 2077 gauss(*NTLM); 2078 for(i=r;i>0;i--) 2079 { 2080 for(j=c;j>0;j--) 2081 { 2082 number n=n_Init(rep((*NTLM)(i,j)),R->cf); 2083 if(!n_IsZero(n,R->cf)) 2084 { 2085 poly p=p_NSet(n,R); 2086 p_SetComp(p,i,R); 2087 M->m[j]=p_Add_q(M->m[j],p,R); 2088 } 2089 } 2090 } 2091 delete NTLM; 2092 } 2093 else 2094 { 2095 WerrorS("not implemented for these coefficients"); 2096 } 2097 return M; 2098 } 2099 #endif 2100 1973 2101 #if defined(HAVE_NTL) || defined(HAVE_FLINT) 1974 2102 ideal singclap_absFactorize ( poly f, ideal & mipos, intvec ** exps, int & numFactors, const ring r) -
libpolys/polys/clapsing.h
r844f30 re68029 44 44 intvec* singntl_LLL(intvec* A); 45 45 46 #ifdef HAVE_NTL 47 ideal singntl_rref(ideal m, const ring R) /*assume smatrix m*/; 48 matrix singntl_rref(matrix m, const ring R); 49 #endif 50 46 51 ideal singclap_absFactorize ( poly f, ideal & mipos, intvec ** exps, int & n, const ring r); 47 52 -
libpolys/polys/flintconv.cc
r844f30 re68029 391 391 { 392 392 poly h=MATELEM(m,i,j); 393 if (h==NULL) 394 convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j-1),n,R->cf); 395 else if (p_Totaldegree(h,R)==0) 393 if ((h!=NULL) 394 && (p_Totaldegree(h,R)==0)) 396 395 convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j-1),pGetCoeff(h),R->cf); 397 398 399 WerrorS("matrix for rref is norconstant");400 401 396 else 397 { 398 WerrorS("matrix for rref is not constant"); 399 return M; 400 } 402 401 } 403 402 } … … 447 446 } 448 447 448 ideal singflint_rref(ideal m, const ring R) /*assume smatrix m*/ 449 { 450 int r=m->rank; 451 int c=m->ncols; 452 int i,j; 453 ideal M=idInit(c,r); 454 if (rField_is_Q(R)) 455 { 456 fmpq_mat_t FLINTM; 457 fmpq_mat_init(FLINTM,r,c); 458 for(j=c;j>0;j--) 459 { 460 poly h=m->m[j]; 461 while(h!=NULL) 462 { 463 i=p_GetComp(h,R); 464 if (p_Totaldegree(h,R)==0) 465 convSingNFlintN(fmpq_mat_entry(FLINTM,i-1,j-1),p_GetCoeff(h,R),R->cf); 466 else 467 { 468 WerrorS("smatrix for rref is not constant"); 469 return M; 470 } 471 pIter(h); 472 } 473 } 474 fmpq_mat_rref(FLINTM,FLINTM); 475 for(i=r;i>0;i--) 476 { 477 for(j=c;j>0;j--) 478 { 479 number n=convFlintNSingN(fmpq_mat_entry(FLINTM,i-1,j-1),R->cf); 480 if(!n_IsZero(n,R->cf)) 481 { 482 poly p=p_NSet(n,R); 483 p_SetComp(p,i,R); 484 M->m[j]=p_Add_q(M->m[j],p,R); 485 } 486 } 487 } 488 fmpq_mat_clear(FLINTM); 489 } 490 else if (rField_is_Zp(R)) 491 { 492 nmod_mat_t FLINTM; 493 nmod_mat_init(FLINTM,r,c,rChar(R)); 494 for(j=c;j>0;j--) 495 { 496 poly h=m->m[j]; 497 while(h!=NULL) 498 { 499 i=p_GetComp(h,R); 500 if (p_Totaldegree(h,R)==0) 501 nmod_mat_entry(FLINTM,i-1,j-1)=(long)p_GetCoeff(h,R); 502 else 503 { 504 WerrorS("smatrix for rref is not constant"); 505 return M; 506 } 507 pIter(h); 508 } 509 } 510 nmod_mat_rref(FLINTM); 511 for(i=r;i>0;i--) 512 { 513 for(j=c;j>0;j--) 514 { 515 number n=n_Init(nmod_mat_entry(FLINTM,i-1,j-1),R->cf); 516 if(!n_IsZero(n,R->cf)) 517 { 518 poly p=p_NSet(n,R); 519 p_SetComp(p,i,R); 520 M->m[j]=p_Add_q(M->m[j],p,R); 521 } 522 } 523 } 524 nmod_mat_clear(FLINTM); 525 } 526 else 527 { 528 #if 0 529 fmpz_t p; 530 convSingIFlintI(p,rChar(currRing)); 531 fq_nmod_ctx_init(ctx,p,1,"t"); 532 fq_nmod_mat_t FLINTM; 533 // convert matrix 534 convSingMFlintFq_nmod_mat(M,FLINTM,ctx,currRing); 535 // rank 536 long rk= fq_nmod_mat_rref (FLINTM,ctx); 537 res->data=(void*)convFlintFq_nmod_matSingM(FLINTM,ctx,currRing); 538 // clean up 539 fq_nmod_mat_clear (FLINTM,ctx); 540 fq_nmod_ctx_clear(ctx); 541 fmpz_clear(p); 542 #endif 543 WerrorS("not implemented for these coefficients"); 544 } 545 return M; 546 } 547 449 548 bigintmat* singflint_LLL(bigintmat* m, bigintmat* T) 450 549 { -
libpolys/polys/flintconv.h
r844f30 re68029 67 67 68 68 matrix singflint_rref(matrix m, const ring R); 69 ideal singflint_rref(ideal m, const ring R); 69 70 #if __FLINT_RELEASE >= 20500 70 71 void convSingPFlintnmod_poly_t(nmod_poly_t result, const poly p, const ring r);
Note: See TracChangeset
for help on using the changeset viewer.