Package wycs.core

Examples of wycs.core.Code$Variable


    //H4header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H4header/linked"));

    //TestAll.readAll("E:/problem/MAC021S0.A2007287.1920.002.2007289002404.hdf");

    NetcdfFile ncfile = NetcdfFile.open("R:\\testdata\\hdf4\\c402_rp_02.diag.sfc.20020122_0130z.hdf");
    Variable v = ncfile.findVariable("MOD_Grid_MOD17A2/Data Fields/PsnNet_1km");
    assert v != null;
    v.read();
    ncfile.close();
  }
View Full Code Here


  public void testUnsigned() throws IOException, InvalidRangeException {
    String filename = testDir + "MOD021KM.A2004328.1735.004.2004329164007.hdf";
    NetcdfFile ncfile = NetcdfFile.open(filename);
    String vname = "/MODIS_SWATH_Type_L1B/Data Fields/EV_250_Aggr1km_RefSB";
    Variable v = ncfile.findVariable(vname);
    assert v != null : filename+" "+vname;

    Array data = v.read();
    System.out.printf(" sum =          %f%n", MAMath.sumDouble(data));

    double sum2 = 0;
    double sum3 = 0;
    int[] varShape = v.getShape();
    int[] origin = new int[3];
    int[] size = new int[]{1, varShape[1], varShape[2]};
    for (int i = 0; i < varShape[0]; i++) {
      origin[0] = i;
      Array data2D = v.read(origin, size);

      double sum = MAMath.sumDouble(data2D);
      System.out.printf("  %d sum3D =        %f%n", i, sum);
      sum2 += sum;
View Full Code Here

     * @param code the tuple load code to simplify.
     * @return the (if possible) simplified code.
     */
    private Code simplify(Code.Load code) {
        // Recurse into the operand first
        Code operand = simplify(code.operands[0]);

        // Simplify known tuples
        if (operand.opcode == Code.Op.TUPLE) {
            operand = operand.operands[code.index];
        }
View Full Code Here

                // Create a binding that replaces the named return variable with the function call
                Map<Integer, Code> binding = new HashMap();
                binding.put(0, Code.FunCall(type, Code.Variable(type.from(), 1), code.nid));

                // Substitute and instantiate to get the new operand for the assertion
                Code operand = function.constraint.substitute(binding).instantiate(generics);
                Pair<SemanticType, Integer>[] types = new Pair[] {new Pair(type.from(), 1)};
                // TODO: What type should a quantifier have?
                Code assertion = Code.Quantifier(SemanticType.Bool, Code.Op.FORALL, operand, types);

                block.append(new Stmt.Assert(translate(assertion)));
            }
        }
View Full Code Here

        return "(" + id + " " + translate(code.operands[0]) + ")";
    }

    private String translate(Code.Load code) {
        Code operand = simplify(code.operands[0]);

        // Check to see if we can simplify this expression
        if (operand.opcode == Code.Op.CONST) {
            Value.Tuple tuple = (Value.Tuple) ((Code.Constant) operand).value;
View Full Code Here

    return Code.Load(e.type, transform(e.operands[0]), e.index,
        e.attributes());
  }

  private Code transform(Code.FunCall e) {
    Code r = e;
    try {
      WycsFile module = builder.getModule(e.nid.module());
      // In principle, module should not be null if TypePropagation has
      // already passed. However, in the case of a function call inserted
      // during code generation, there is no guarantee that it was
View Full Code Here

    long startMemory = runtime.freeMemory();

    Automaton automaton = new Automaton();
    Automaton original = null;

    Code neg = Code.Unary(SemanticType.Bool,
        Code.Op.NOT, stmt.condition);
    // The following conversion is potentially very expensive, but is
    // currently necessary for the instantiate axioms phase.
    Code nnf = NormalForms.negationNormalForm(neg);

    ///debug(nnf,filename);
    int maxVar = findLargestVariable(nnf);

    Code vc = instantiateAxioms(nnf, maxVar + 1);

    //debug(vc,filename);

    int assertion = translate(vc,automaton,new HashMap<String,Integer>());
    automaton.setRoot(0, assertion);
View Full Code Here

        WycsFile.Function fn = (WycsFile.Function) d;
        if(fn.constraint != null) {
          // There are some axioms we can instantiate. First, we need to
          // construct the generic binding for this function.
          HashMap<String,SemanticType> generics = buildGenericBinding(fn.type.generics(),condition.type.generics());
          Code axiom = renameToAvoidCapture(fn.constraint,freeVariable);
          HashMap<Integer,Code> binding = new HashMap<Integer,Code>();
          binding.put(1, condition.operands[0]);
          binding.put(0, condition);
          axiom = axiom.substitute(binding).instantiate(
              generics);
          axioms.add(axiom);
        }
      } else if(d instanceof WycsFile.Macro){
        // we can ignore macros, because they are inlined separately by
View Full Code Here

  private void instantiateFromExpression(Code.Unary expression, ArrayList<Code> axioms, int freeVariable) {
    instantiateFromExpression(expression.operands[0],axioms, freeVariable);

    if(expression.opcode == Code.Op.LENGTH) {
      Code lez = Code.Binary(SemanticType.Int, Code.Op.LTEQ,
          Code.Constant(Value.Integer(BigInteger.ZERO)), expression);
      axioms.add(lez);
    }
  }
View Full Code Here

      if (fn.constraint != null) {
        // There are some axioms we can instantiate. First, we need to
        // construct the generic binding for this function.
        HashMap<String, SemanticType> generics = buildGenericBinding(
            fn.type.generics(), expression.type.generics());
        Code axiom = renameToAvoidCapture(fn.constraint,freeVariable);
        HashMap<Integer,Code> binding = new HashMap<Integer,Code>();
        binding.put(1, expression.operands[0]);
        binding.put(0, expression);
        axiom = axiom.substitute(binding).instantiate(
            generics);
        axioms.add(axiom);
      }
    } catch (Exception ex) {
      internalFailure(ex.getMessage(), filename, expression, ex);
View Full Code Here

TOP

Related Classes of wycs.core.Code$Variable

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.