Examples of BinaryFunction


Examples of javaff.data.metric.BinaryFunction

  {
    if (f instanceof NamedFunction) return (PGNamedFunction) PGFuncMap.get(f);
    else if (f instanceof NumberFunction) return new PGNumberFunction(f.getValue(null));
    else if (f instanceof BinaryFunction)
    {
      BinaryFunction bf = (BinaryFunction) f;
      PGFunction f1 = makeFunction(bf.first);
      PGFunction s2 = makeFunction(bf.second);
      return new PGBinaryFunction(f1,s2,bf.type);
    }
    else return null;
View Full Code Here

Examples of nexj.core.meta.BinaryFunction

      Type type = first.getType();

      if (type.isPrimitive())
      {
         Primitive primitiveType = (Primitive)type;
         BinaryFunction f = primitiveType.getEQFunction(primitiveType);

         for (int i = 1; i < m_nOperandCount; ++i)
         {
            if (((Boolean)f.invoke(firstValue, m_operandArray[i].getValue())).booleanValue())
            {
               return Boolean.TRUE;
            }
         }
View Full Code Here

Examples of nexj.core.meta.BinaryFunction

            if (left != null)
            {
               Primitive leftType = Primitive.primitiveOf(left);
               Primitive rightType, resultType;
               BinaryFunction fun;
               Object right;

               for (int i = 1; i < nArgCount; ++i)
               {
                  right = machine.getArg(i, nArgCount);

                  if (right == null)
                  {
                     left = null;

                     break;
                  }

                  rightType = Primitive.primitiveOf(right);
                  resultType = getCoercedType(leftType, rightType);

                  if (leftType != resultType)
                  {
                     left = resultType.getConverter(leftType).invoke(left);
                     leftType = resultType;
                  }

                  if (rightType != resultType)
                  {
                     right = resultType.getConverter(rightType).invoke(right);
                  }

                  if ((fun = m_functionArray[resultType.getOrdinal()]) == null)
                  {
                     throw new TypeMismatchException(getSymbol());
                  }

                  left = fun.invoke(left, right);
               }
            }

            machine.returnValue(left, nArgCount);
         }
View Full Code Here

Examples of nexj.core.meta.BinaryFunction

         Object left = machine.getArg(0, nArgCount);

         Primitive leftType = Primitive.primitiveOf(left);
         Primitive rightType, coercedType = null;
         BinaryFunction fun;
         Object right;

         for (int i = 1; i < nArgCount; ++i)
         {
            right = machine.getArg(i, nArgCount);
            rightType = Primitive.primitiveOf(right);

            if (leftType == null)
            {
               if (rightType != null)
               {
                  coercedType = rightType;
               }
            }
            else if (rightType == null)
            {
               coercedType = leftType;
            }
            else
            {
               coercedType = getCoercedType(leftType, rightType);
            }

            if (coercedType != null)
            {
               if (leftType != coercedType)
               {
                  left = coercedType.getConverter(leftType).invoke(left);
                  leftType = coercedType;
               }

               if (rightType != coercedType)
               {
                  right = coercedType.getConverter(rightType).invoke(right);
               }

               if ((fun = m_functionArray[coercedType.getOrdinal()]) == null)
               {
                  throw new TypeMismatchException(getSymbol());
               }

               if (fun.invoke(left, right) == m_stopResult)
               {
                  machine.returnValue(m_stopResult, nArgCount);

                  return false;
               }
View Full Code Here

Examples of nexj.core.meta.BinaryFunction

         verifyMinArgCount(nArgCount, 1);

         Object left = machine.getArg(0, nArgCount);
         Primitive leftType = Primitive.primitiveOf(left);
         Primitive rightType, coercedType = null;
         BinaryFunction fun;
         Object right;

         for (int i = 1; i < nArgCount; ++i)
         {
            right = machine.getArg(i, nArgCount);
            rightType = Primitive.primitiveOf(right);

            if (leftType == null)
            {
               if (rightType != null)
               {
                  coercedType = rightType;
               }
            }
            else if (rightType == null)
            {
               coercedType = leftType;
            }
            else
            {
               coercedType = getCoercedType(leftType, rightType);
            }

            if (coercedType != null)
            {
               if (leftType != coercedType)
               {
                  left = coercedType.getConverter(leftType).invoke(left);
                  leftType = coercedType;
               }

               if (rightType != coercedType)
               {
                  right = coercedType.getConverter(rightType).invoke(right);
               }

               if ((fun = m_functionArray[coercedType.getOrdinal()]) == null)
               {
                  throw new TypeMismatchException(getSymbol());
               }

               if (fun.invoke(left, right) == Boolean.TRUE)
               {
                  left = right;
               }
            }
            else
View Full Code Here

Examples of org.apache.mahout.math.function.BinaryFunction

    return r;
  }

  /** Returns sqrt(a^2 + b^2) without under/overflow. */
  private static BinaryFunction hypotFunction() {
    return new BinaryFunction() {
      public double apply(double a, double b) {
        return hypot(a, b);
      }
    };
  }
View Full Code Here

Examples of org.apache.mahout.math.function.BinaryFunction

    return phi;
  }
 
  private static Vector digamma(Vector v) {
    Vector digammaGamma = new DenseVector(v.size());
    digammaGamma.assign(v, new BinaryFunction() {
      @Override
      public double apply(double unused, double g) {
        return digamma(g);
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.BinaryFunction

    return phi;
  }
 
  private static Vector digamma(Vector v) {
    Vector digammaGamma = new DenseVector(v.size());
    digammaGamma.assign(v, new BinaryFunction() {
      @Override
      public double apply(double unused, double g) {
        return digamma(g);
      }
    });
View Full Code Here

Examples of org.apache.mahout.math.function.BinaryFunction

  // -------- classification methods

  @Override
  public Vector classify(Vector instance) {
    Vector r = new DenseVector(numCategories() - 1);
    BinaryFunction scale = Functions.plusMult(1.0 / models.size());
    for (OnlineLogisticRegression model : models) {
      r.assign(model.classify(instance), scale);
    }
    return r;
  }
View Full Code Here

Examples of org.apache.mahout.math.function.BinaryFunction

  }

  @Override
  public Vector classifyNoLink(Vector instance) {
    Vector r = new DenseVector(numCategories() - 1);
    BinaryFunction scale = Functions.plusMult(1.0 / models.size());
    for (OnlineLogisticRegression model : models) {
      r.assign(model.classifyNoLink(instance), scale);
    }
    return r;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.