コード例 #1
0
 @Override
 public SimplePolynomialFunction compose(SimplePolynomialFunction inner) {
   for (CompoundPolynomialFunction pipeline : pipelines) {
     pipeline.composeHeadDirectly(inner);
   }
   SimplePolynomialFunction newBase;
   if (!inner.isParameterized()) {
     SimplePolynomialFunction extended =
         ParameterizedPolynomialFunctions.extend(inner.getInputLength() << 1, inner);
     newBase =
         super.compose(
             new OptimizedPolynomialFunctionGF2(
                 inner.getInputLength(),
                 inner.getOutputLength(),
                 extended.getMonomials(),
                 extended.getContributions()));
   } else {
     newBase = super.compose(inner);
   }
   return new ParameterizedPolynomialFunctionGF2(
       inner.getInputLength(),
       outputLength,
       newBase.getMonomials(),
       newBase.getContributions(),
       pipelines);
 }
コード例 #2
0
 @Override
 public boolean equals(Object obj) {
   if (obj instanceof SimplePolynomialFunction) {
     SimplePolynomialFunction other = (SimplePolynomialFunction) obj;
     if (this.getInputLength() != other.getInputLength()) {
       return false;
     }
     for (int i = 0; i < 10000; ++i) {
       BitVector input = BitVectors.randomVector(getInputLength());
       if (!this.apply(input).equals(other.apply(input))) {
         return false;
       }
     }
   }
   return true;
 }