Package ket.math

Examples of ket.math.Function


public class BoxFactory {
  // Don't create Box instances.
  private BoxFactory() {}

  public static Box verticalContainer(Argument argument, ColourScheme colourScheme) {
    Function function = argument.getFunction();
    if (argument instanceof Branch) {
      String name = function!=null ? function.getName() : "?" ;
      Vector<Argument> args = ((Branch) argument).getChildren();
      return verticalContainer((Branch) argument, name, args, colourScheme, true);
    } else {
      String text = argument.toPrefixNotation();
      return new BoxWord(argument, text, 0L);
View Full Code Here


    }
  }

  public static Box horizontalContainer(Argument argument, ColourScheme colourScheme) {
    if (argument instanceof Branch) {
      Function function = argument.getFunction();
      String name = function!=null ? function.getName() : "?" ;
      Vector<Argument> args = ((Branch) argument).getChildren();
      return horizontalContainer((Branch) argument, name, args, colourScheme, true);
    } else {
      return new BoxWord(argument, argument.toPrefixNotation(), 0L);
    }
View Full Code Here

   * For a given argument, look for all desendents with the same function.
   * TODO: Move this to argument range?
   */
  public static Vector<Branch> getSimilarDescendents(Branch branch) {
    Vector<Branch> matches = new Vector<Branch>();
    Function function = branch.getFunction();
    for (Argument child : branch.getChildren()) {
      if (child.getFunction()==function) {
        matches.add((Branch) child);
        matches.addAll(getSimilarDescendents((Branch) child));
      }
View Full Code Here

    }
    return matches;
  }

  public static Branch getSameFunctionAncestor(Branch branch) { // dangerous for non-branches.
    Function function = branch.getFunction();
    Vector<Branch> ancestors = branch.getAncestors();
    Branch root = branch;
    for (Branch a : ancestors) {
      if (a.getFunction()==function) {
        root = a;
View Full Code Here

  public static Function effectiveUnitaryAncestorOperation(Argument target, Branch top) {
    //D Ket.out.println("Route:");
    //D Ket.out.println("\targument: " + (target!=null?target:null));
    //D Ket.out.println("\ttop: " + (top!=null?top:null));
    Branch parent = target.getParentBranch();
    Function unitary = Type.getUnitaryFunction(target);
    if (unitary==null) {
      //D Ket.out.println("\t !!! Null unitary function !!! ");
      return null;
    }
    //D Ket.out.println("\tunitary function = '" + unitary.getName() + "'");
    Function composition=unitary;
    while (parent!=null && parent!=top) {
      //D Ket.out.println("\tparent = '" + parent + "'");
      target = parent;
      parent = parent.getParentBranch();
      if (parent==null || parent==top) {
View Full Code Here

    if (!invert) {
      Ket.out.println(" !!! Can't invert: common function ("+common.getFunction()+") must be an assign or [in]equality.");
      return null;
    }
    // TODO: Use or remove getRelativeOperation().invert
    Function sourceOperation = source.getPathOperation(common);
    Function destinationOperation = destination.getPathOperation(common);
    Ket.out.println("> source = " + source + " -> " + sourceOperation);
    Ket.out.println("> destination = " + destination + " -> " + destinationOperation);
    return getRelativeOperation(sourceOperation, destinationOperation, invert);
  }
View Full Code Here

    };

    Map<Character, Function> charToFunctionMap = new HashMap<Character, Function>();
    for (int i=0; i<charsArray.length; i++) {
      char character = charsArray[i];
      Function function = functionsArray[i];
      charToFunctionMap.put(character, function);
    }
    return charToFunctionMap;
  }
View Full Code Here

   * minus/plus and return it.
   */
  public static Function getUnitaryFunction(Argument subject) { //x: x+a -> +, x-a -> +, a-x -> -
    Branch parentBranch = subject.getParentBranch();
    int size = parentBranch!=null ? parentBranch.size() : -1;
    Function parentFunction = subject.getParentFunction();
    if (parentFunction==null) {
      return null;
    } else if (parentFunction==Function.MINUS && size==1) { // Special case!
      // -x is minus and not positive.
      return Function.MINUS;
View Full Code Here

  }
  */

  public static Argument[][] asTable(Vector<Argument> args, boolean transpose)  {
    if (!isRectangle(args)) return null;
    Function commonFunction = getCommonFunction(args);
    if (!Type.sequenceType(commonFunction)) return null;
    Argument[][] table = toTable(args);
    if (table==null) return null;
    return transpose ? calcTranspose(table) : table;
  }
View Full Code Here

   */
  public static Function getCommonFunction(Vector<Argument> args) {
    if (args.size()==0) {
      return null;
    }
    Function commonFunction = args.firstElement().getFunction();
    if (commonFunction==null) {
      return null;
    }
    for (int i=1; i<args.size(); i++) {
      Argument next = args.get(i);
      Function function = next.getFunction();
      if (commonFunction!=function) {
        return null;
      }
    }
    return commonFunction;
View Full Code Here

TOP

Related Classes of ket.math.Function

Copyright © 2018 www.massapicom. 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.