001/* 002 * $Id: GBTransportMess.java 4239 2012-10-07 08:40:06Z kredel $ 003 */ 004 005package edu.jas.gb; 006 007 008import java.io.Serializable; 009 010import edu.jas.poly.GenPolynomial; 011import edu.jas.structure.RingElem; 012 013 014/** 015 * Distributed GB transport message. This class and its subclasses 016 * are used for transport of polynomials and pairs and as markers in 017 * distributed GB algorithms. 018 */ 019 020public class GBTransportMess implements Serializable { 021 022 023 public GBTransportMess() { 024 } 025 026 027 /** 028 * toString. 029 */ 030 @Override 031 public String toString() { 032 return this.getClass().getName(); 033 } 034} 035 036 037/** 038 * Distributed GB transport message for requests. 039 */ 040 041final class GBTransportMessReq extends GBTransportMess { 042 043 044 public GBTransportMessReq() { 045 } 046} 047 048 049/** 050 * Distributed GB transport message for termination. 051 */ 052 053final class GBTransportMessEnd extends GBTransportMess { 054 055 056 public GBTransportMessEnd() { 057 } 058} 059 060 061/** 062 * Distributed GB transport message for polynomial. 063 */ 064 065final class GBTransportMessPoly<C extends RingElem<C>> extends GBTransportMess { 066 067 068 /** 069 * The polynomial to transport. 070 */ 071 public final GenPolynomial<C> pol; 072 073 074 /** 075 * GBTransportMessPoly. 076 * @param p polynomial to transfered. 077 */ 078 public GBTransportMessPoly(GenPolynomial<C> p) { 079 this.pol = p; 080 } 081 082 083 /** 084 * toString. 085 */ 086 @Override 087 public String toString() { 088 return super.toString() + "( " + pol + " )"; 089 } 090} 091 092 093/** 094 * Distributed GB transport message for pairs. 095 */ 096 097final class GBTransportMessPair<C extends RingElem<C>> extends GBTransportMess { 098 099 100 public final Pair<C> pair; 101 102 103 /** 104 * GBTransportMessPair. 105 * @param p pair for transfer. 106 */ 107 public GBTransportMessPair(Pair<C> p) { 108 this.pair = p; 109 } 110 111 112 /** 113 * toString. 114 */ 115 @Override 116 public String toString() { 117 return super.toString() + "( " + pair + " )"; 118 } 119} 120 121 122/** 123 * Distributed GB transport message for index pairs. 124 */ 125 126final class GBTransportMessPairIndex extends GBTransportMess { 127 128 129 public final int i; 130 131 132 public final int j; 133 134 135 public final int s; // last polynomial in list, unused 136 137 138 /** 139 * GBTransportMessPairIndex. 140 * @param p pair for transport. 141 */ 142 public GBTransportMessPairIndex(Pair p) { 143 this(p.i,p.j,0); 144 } 145 146 147 /** 148 * GBTransportMessPairIndex. 149 * @param p pair for transport. 150 * @param s list size. 151 */ 152 public GBTransportMessPairIndex(Pair p, int s) { 153 this(p.i,p.j,s); 154 } 155 156 157 /** 158 * GBTransportMessPairIndex. 159 * @param i first index. 160 * @param j second index. 161 */ 162 public GBTransportMessPairIndex(int i, int j) { 163 this(i,j,0); 164 } 165 166 167 /** 168 * GBTransportMessPairIndex. 169 * @param i first index. 170 * @param j second index. 171 * @param s list size. 172 */ 173 public GBTransportMessPairIndex(int i, int j, int s) { 174 this.i = i; 175 this.j = j; 176 if ( s < i ) { 177 s = i; 178 } 179 if ( s < j ) { 180 s = j; 181 } 182 this.s = s; 183 } 184 185 186 /** 187 * GBTransportMessPairIndex. 188 * @param i first index. 189 * @param j second index. 190 * @param s list size. 191 */ 192 public GBTransportMessPairIndex(Integer i, Integer j, Integer s) { 193 this(i.intValue(),j.intValue(),s.intValue()); 194 } 195 196 197 /** 198 * toString. 199 */ 200 @Override 201 public String toString() { 202 return super.toString() + "( " + i + "," + j + " )[" + s + "]"; 203 } 204 205}