/** * Perform modulus against another polynom * * @param QR_Polynominal $e * * @return QR_Polynominal */ public function mod(QR_Polynominal $e) { if ($this->getLength() - $e->getLength() < 0) { return $this; } $ratio = QR_Math::getInstance()->glog($this->get(0)) - QR_Math::getInstance()->glog($e->get(0)); $num = QR_Util::getInstance()->createEmptyArray($this->getLength()); for ($i = 0; $i < $this->getLength(); $i++) { $num[$i] = $this->get($i); } for ($i = 0; $i < $e->getLength(); $i++) { $num[$i] ^= QR_Math::getInstance()->gexp(QR_Math::getInstance()->glog($e->get($i)) + $ratio); } $result = new QR_Polynominal($num, 0); $result = $result->mod($e); return $result; }