001 /* 002 * $Id: ModGroebnerBaseAbstract.java 3445 2010-12-25 17:24:04Z kredel $ 003 */ 004 005 package edu.jas.gbmod; 006 007 008 import java.util.List; 009 010 import edu.jas.gb.GroebnerBase; 011 import edu.jas.gbufd.GBFactory; 012 import edu.jas.poly.GenPolynomial; 013 import edu.jas.poly.ModuleList; 014 import edu.jas.poly.PolynomialList; 015 import edu.jas.structure.GcdRingElem; 016 import edu.jas.structure.RingFactory; 017 018 019 /** 020 * Module Groebner Bases abstract class. Implements Groebner bases and GB test. 021 * @author Heinz Kredel 022 */ 023 024 public class ModGroebnerBaseAbstract<C extends GcdRingElem<C>> implements ModGroebnerBase<C> { 025 026 027 //private static final Logger logger = Logger.getLogger(ModGroebnerBase.class); 028 029 030 /** 031 * Used Groebner base algorithm. 032 */ 033 protected final GroebnerBase<C> bb; 034 035 036 /** 037 * Constructor. 038 */ 039 public ModGroebnerBaseAbstract() { 040 bb = GBFactory.getImplementation(); 041 } 042 043 044 /** 045 * Constructor. 046 */ 047 public ModGroebnerBaseAbstract(RingFactory<C> cf) { 048 bb = GBFactory.getImplementation(cf); 049 } 050 051 052 /** 053 * Module Groebner base test. 054 */ 055 public boolean isGB(int modv, List<GenPolynomial<C>> F) { 056 return bb.isGB(modv, F); 057 } 058 059 060 /** 061 * isGB. 062 * @param M a module basis. 063 * @return true, if M is a Groebner base, else false. 064 */ 065 public boolean isGB(ModuleList<C> M) { 066 if (M == null || M.list == null) { 067 return true; 068 } 069 if (M.rows == 0 || M.cols == 0) { 070 return true; 071 } 072 PolynomialList<C> F = M.getPolynomialList(); 073 int modv = M.cols; // > 0 074 return bb.isGB(modv, F.list); 075 } 076 077 078 /** 079 * Groebner base using pairlist class. 080 */ 081 public List<GenPolynomial<C>> GB(int modv, List<GenPolynomial<C>> F) { 082 return bb.GB(modv, F); 083 } 084 085 086 /** 087 * GB. 088 * @param M a module basis. 089 * @return GB(M), a Groebner base of M. 090 */ 091 public ModuleList<C> GB(ModuleList<C> M) { 092 ModuleList<C> N = M; 093 if (M == null || M.list == null) { 094 return N; 095 } 096 if (M.rows == 0 || M.cols == 0) { 097 return N; 098 } 099 100 PolynomialList<C> F = M.getPolynomialList(); 101 int modv = M.cols; 102 List<GenPolynomial<C>> G = bb.GB(modv, F.list); 103 F = new PolynomialList<C>(F.ring, G); 104 N = F.getModuleList(modv); 105 return N; 106 } 107 108 }