Examples of FastVector


Examples of com.exigen.ie.tools.FastVector

  } //~ ObserverCardValue


  public IntExpCardinality(Constrainer constrainer, Vector vars, int card_value) throws Failure
  {
    this(constrainer, new FastVector(vars), card_value);
  }
View Full Code Here

Examples of com.sun.j3d.internal.FastVector

/*  201 */       float[] tmpCoords = new float[6];
/*  202 */       float lastX = 0.0F; float lastY = 0.0F;
/*  203 */       float firstPntx = 3.4028235E+38F; float firstPnty = 3.4028235E+38F;
/*  204 */       GeometryInfo gi = null;
/*  205 */       NormalGenerator ng = new NormalGenerator();
/*  206 */       FastVector contours = new FastVector(10);
/*  207 */       float maxY = -3.402824E+038F;
/*  208 */       int maxYIndex = 0; int beginIdx = 0; int endIdx = 0; int start = 0;
/*      */
/*  210 */       boolean setMaxY = false;
/*      */
/*  213 */       while (!pIt.isDone()) {
/*  214 */         Point3f vertex = new Point3f();
/*  215 */         flag = pIt.currentSegment(tmpCoords);
/*  216 */         if (flag == 4) {
/*  217 */           if (num > 0) {
/*  218 */             if (setMaxY)
/*      */             {
/*  220 */               beginIdx = start;
/*  221 */               endIdx = numPoints - 1;
/*      */             }
/*  223 */             contours.addElement(num);
/*  224 */             num = 0;
/*  225 */             numContours++;
/*      */           }
/*      */         } else { if (flag == 0) {
/*  228 */             vertex.x = tmpCoords[0];
/*  229 */             vertex.y = tmpCoords[1];
/*  230 */             lastX = vertex.x;
/*  231 */             lastY = vertex.y;
/*      */
/*  233 */             if ((lastX == firstPntx) && (lastY == firstPnty)) {
/*  234 */               pIt.next();
/*  235 */               continue;
/*      */             }
/*  237 */             setMaxY = false;
/*  238 */             coords.add(vertex);
/*  239 */             firstPntx = lastX;
/*  240 */             firstPnty = lastY;
/*  241 */             if (num > 0) {
/*  242 */               contours.addElement(num);
/*  243 */               num = 0;
/*  244 */               numContours++;
/*      */             }
/*  246 */             num++;
/*  247 */             numPoints++;
/*      */
/*  250 */             start = numPoints; break label525;
/*  251 */           }if (flag == 1) {
/*  252 */             vertex.x = tmpCoords[0];
/*  253 */             vertex.y = tmpCoords[1];
/*      */
/*  258 */             if ((vertex.x == lastX) && (vertex.y == lastY)) {
/*  259 */               pIt.next();
/*  260 */               continue;
/*      */             }
/*  262 */             if (vertex.y > maxY) {
/*  263 */               maxY = vertex.y;
/*  264 */               maxYIndex = numPoints;
/*  265 */               setMaxY = true;
/*      */             }
/*  267 */             lastX = vertex.x;
/*  268 */             lastY = vertex.y;
/*  269 */             coords.add(vertex);
/*  270 */             num++;
/*  271 */             numPoints++;
/*      */           } }
/*  273 */         label525: pIt.next();
/*      */       }
/*      */
/*  278 */       if (numPoints == 0) {
/*  279 */         return null;
/*      */       }
/*      */
/*  285 */       Point3f p1 = new Point3f(); Point3f p2 = new Point3f(); Point3f p3 = new Point3f();
/*  286 */       boolean flip_side_orient = true;
/*  287 */       Point3f[] vertices = (Point3f[])coords.toArray(false);
/*      */
/*  289 */       if (endIdx - beginIdx > 0)
/*      */       {
/*  294 */         if (maxYIndex == beginIdx)
/*  295 */           p1.set(vertices[endIdx]);
/*      */         else {
/*  297 */           p1.set(vertices[(maxYIndex - 1)]);
/*      */         }
/*  299 */         p2.set(vertices[maxYIndex]);
/*  300 */         if (maxYIndex == endIdx)
/*  301 */           p3.set(vertices[beginIdx]);
/*      */         else {
/*  303 */           p3.set(vertices[(maxYIndex + 1)]);
/*      */         }
/*      */
/*  306 */         if (p3.x != p2.x) {
/*  307 */           if (p1.x != p2.x)
/*      */           {
/*  309 */             if (Math.abs((p2.y - p1.y) / (p2.x - p1.x)) > Math.abs((p3.y - p2.y) / (p3.x - p2.x)))
/*      */             {
/*  311 */               flip_side_orient = p3.x > p2.x;
/*      */             }
/*  313 */             else flip_side_orient = p2.x > p1.x;
/*      */           }
/*      */           else {
/*  316 */             flip_side_orient = p3.x > p2.x;
/*      */           }
/*      */
/*      */         }
/*      */         else
/*      */         {
/*  323 */           flip_side_orient = p2.x > p1.x;
/*      */         }
/*      */
/*      */       }
/*      */
/*  328 */       int startIdx = 0;
/*  329 */       IslandsNode islandsTree = new IslandsNode(-1, -1);
/*  330 */       int[] contourCounts = contours.getData();
/*      */
/*  333 */       for (int i = 0; i < contours.getSize(); i++) {
/*  334 */         endIdx = startIdx + contourCounts[i];
/*  335 */         islandsTree.insert(new IslandsNode(startIdx, endIdx), vertices);
/*  336 */         startIdx = endIdx;
/*      */       }
/*      */
View Full Code Here

Examples of net.sf.cpsolver.ifs.util.FastVector

    public void init() {
        setValues(computeValues());
    }

    public Vector<Value> computeValues() {
        Vector values = new FastVector();
        UniResource[] res = new UniResource[getResourceGroups().size()];
        for (int day = 0; day < days; day++) {
            for (int hour = 0; hour <= hours - getDuration(); hour++) {
                if (isProhibited(day, hour, getDuration()))
                    continue;
View Full Code Here

Examples of org.integratedmodelling.riskwiz.learning.data.FastVector

            } else {
                errorMessage("keyword " + Instances.ARFF_RELATION + " expected");
            }

            // Create vectors to hold information temporarily.
            FastVector attributes = new FastVector();
  
            // Get attribute declarations.
            getFirstToken();
            if (m_Tokenizer.ttype == StreamTokenizer.TT_EOF) {
                errorMessage("premature end of file");
            }

            while (Attribute.ARFF_ATTRIBUTE.equalsIgnoreCase(m_Tokenizer.sval)) {
                attributes = parseAttribute(attributes);
            }

            // Check if data part follows. We can't easily check for EOL.
            if (!Instances.ARFF_DATA.equalsIgnoreCase(m_Tokenizer.sval)) {
                errorMessage("keyword " + Instances.ARFF_DATA + " expected");
            }
     
            // Check if any attributes have been declared.
            if (attributes.size() == 0) {
                errorMessage("no attributes declared");
            }
     
            m_Data = new Instances(relationName, attributes, capacity);
        }
View Full Code Here

Examples of weka.core.FastVector

        pred = Utils.missingValue();
      }
      updateStatsForClassifier(dist, instance);
      if (storePredictions) {
        if (m_Predictions == null)
          m_Predictions = new FastVector();
        m_Predictions.addElement(new NominalPrediction(instance.classValue(), dist,
                                                       instance.weight()));
      }
    } else {
      pred = dist[0];
      updateStatsForPredictor(pred, instance);
      if (storePredictions) {
        if (m_Predictions == null)
          m_Predictions = new FastVector();
        m_Predictions.addElement(new NumericPrediction(instance.classValue(), pred,
                                                       instance.weight()));
      }
    }
View Full Code Here

Examples of weka.core.FastVector

   * Initializes the members.
   */
  protected void initialize() {
    super.initialize();
   
    m_PlotShapes             = new FastVector();
    m_PlotSizes              = new FastVector();
    m_Classifier             = null;
    m_ClassIndex             = -1;
    m_Evaluation             = null;
    m_SaveForVisualization   = true;
    m_MinimumPlotSizeNumeric = ExplorerDefaults.getClassifierErrorsMinimumPlotSizeNumeric();
View Full Code Here

Examples of weka.core.FastVector

   * if instances are not saved for visualization.
   *
   * @see #getSaveForVisualization()
   */
  protected void determineFormat() {
    FastVector   hv;
    Attribute   predictedClass;
    Attribute   classAt;
    FastVector   attVals;
    int    i;
   
    if (!m_SaveForVisualization) {
      m_PlotInstances = null;
      return;
    }
   
    hv = new FastVector();

    classAt = m_Instances.attribute(m_ClassIndex);
    if (classAt.isNominal()) {
      attVals = new FastVector();
      for (i = 0; i < classAt.numValues(); i++)
  attVals.addElement(classAt.value(i));
      predictedClass = new Attribute("predicted" + classAt.name(), attVals);
    }
    else {
      predictedClass = new Attribute("predicted" + classAt.name());
    }
View Full Code Here

Examples of weka.core.FastVector

  protected void addPredictionIntervals() {
    int    maxNum;
    int    num;
    int    i;
    int    n;
    FastVector  preds;
    FastVector  atts;
    Instances  data;
    Instance  inst;
    Instance  newInst;
    double[]  values;
    double[][]  predInt;
   
    // determine the maximum number of intervals
    maxNum = 0;
    preds  = m_Evaluation.predictions();
    for (i = 0; i < preds.size(); i++) {
      num = ((NumericPrediction) preds.elementAt(i)).predictionIntervals().length;
      if (num > maxNum)
  maxNum = num;
    }
   
    // create new header
    atts = new FastVector();
    for (i = 0; i < m_PlotInstances.numAttributes(); i++)
      atts.addElement(m_PlotInstances.attribute(i));
    for (i = 0; i < maxNum; i++) {
      atts.addElement(new Attribute("predictionInterval_" + (i+1) + "-lowerBoundary"));
      atts.addElement(new Attribute("predictionInterval_" + (i+1) + "-upperBoundary"));
      atts.addElement(new Attribute("predictionInterval_" + (i+1) + "-width"));
    }
    data = new Instances(m_PlotInstances.relationName(), atts, m_PlotInstances.numInstances());
    data.setClassIndex(m_PlotInstances.classIndex());
   
    // update data
View Full Code Here

Examples of weka.core.FastVector

      m_ClassFilters = null;

    } else if (m_Method == METHOD_1_AGAINST_1) {
      // generate fastvector of pairs
      FastVector pairs = new FastVector();
      for (int i=0; i<insts.numClasses(); i++) {
  for (int j=0; j<insts.numClasses(); j++) {
    if (j<=i) continue;
    int[] pair = new int[2];
    pair[0] = i; pair[1] = j;
    pairs.addElement(pair);
  }
      }

      numClassifiers = pairs.size();
      m_Classifiers = AbstractClassifier.makeCopies(m_Classifier, numClassifiers);
      m_ClassFilters = new Filter[numClassifiers];
      m_SumOfWeights = new double[numClassifiers];

      // generate the classifiers
      for (int i=0; i<numClassifiers; i++) {
  RemoveWithValues classFilter = new RemoveWithValues();
  classFilter.setAttributeIndex("" + (insts.classIndex() + 1));
  classFilter.setModifyHeader(true);
  classFilter.setInvertSelection(true);
  classFilter.setNominalIndicesArr((int[])pairs.elementAt(i));
  Instances tempInstances = new Instances(insts, 0);
  tempInstances.setClassIndex(-1);
  classFilter.setInputFormat(tempInstances);
  newInsts = Filter.useFilter(insts, classFilter);
  if (newInsts.numInstances() > 0) {
    newInsts.setClassIndex(insts.classIndex());
    m_Classifiers[i].buildClassifier(newInsts);
    m_ClassFilters[i] = classFilter;
          m_SumOfWeights[i] = newInsts.sumOfWeights();
  } else {
    m_Classifiers[i] = null;
    m_ClassFilters[i] = null;
  }
      }

      // construct a two-class header version of the dataset
      m_TwoClassDataset = new Instances(insts, 0);
      int classIndex = m_TwoClassDataset.classIndex();
      m_TwoClassDataset.setClassIndex(-1);
      m_TwoClassDataset.deleteAttributeAt(classIndex);
      FastVector classLabels = new FastVector();
      classLabels.addElement("class0");
      classLabels.addElement("class1");
      m_TwoClassDataset.insertAttributeAt(new Attribute("class", classLabels),
            classIndex);
      m_TwoClassDataset.setClassIndex(classIndex);

    } else { // use error correcting code style methods
View Full Code Here

Examples of weka.core.FastVector

 
      case STRING :
  //System.err.println("String --> nominal");
  attributeTypes[i - 1] = Attribute.NOMINAL;
  nominalIndexes[i - 1] = new Hashtable();
  nominalStrings[i - 1] = new FastVector();
  break;
      case TEXT:
  //System.err.println("Text --> string");
  attributeTypes[i - 1] = Attribute.STRING;
  nominalIndexes[i - 1] = new Hashtable();
  nominalStrings[i - 1] = new FastVector();
  break;
      case BOOL:
  //System.err.println("boolean --> nominal");
  attributeTypes[i - 1] = Attribute.NOMINAL;
  nominalIndexes[i - 1] = new Hashtable();
  nominalIndexes[i - 1].put("false", new Double(0));
  nominalIndexes[i - 1].put("true", new Double(1));
  nominalStrings[i - 1] = new FastVector();
  nominalStrings[i - 1].addElement("false");
  nominalStrings[i - 1].addElement("true");
  break;
      case DOUBLE:
  //System.err.println("BigDecimal --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case BYTE:
  //System.err.println("byte --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case SHORT:
  //System.err.println("short --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case INTEGER:
  //System.err.println("int --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case LONG:
  //System.err.println("long --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case FLOAT:
  //System.err.println("float --> numeric");
  attributeTypes[i - 1] = Attribute.NUMERIC;
  break;
      case DATE:
  attributeTypes[i - 1] = Attribute.DATE;
  break;
      case TIME:
  attributeTypes[i - 1] = Attribute.DATE;
  break;
      default:
  //System.err.println("Unknown column type");
  attributeTypes[i - 1] = Attribute.STRING;
      }
    }

    // For sqlite
    // cache column names because the last while(rs.next()) { iteration for
    // the tuples below will close the md object: 
    Vector<String> columnNames = new Vector<String>();
    for (int i = 0; i < numAttributes; i++) {
      columnNames.add(md.getColumnLabel(i + 1));
    }

    // Step through the tuples
    if (m_Debug)
      System.err.println("Creating instances...");
    FastVector instances = new FastVector();
    int rowCount = 0;
    while(rs.next()) {
      if (rowCount % 100 == 0) {
        if (m_Debug)  {
    System.err.print("read " + rowCount + " instances \r");
    System.err.flush();
        }
      }
      double[] vals = new double[numAttributes];
      for(int i = 1; i <= numAttributes; i++) {
  /*switch (md.getColumnType(i)) {
  case Types.CHAR:
  case Types.VARCHAR:
  case Types.LONGVARCHAR:
  case Types.BINARY:
  case Types.VARBINARY:
  case Types.LONGVARBINARY:*/
  switch (translateDBColumnType(md.getColumnTypeName(i))) {
  case STRING :
    String str = rs.getString(i);
   
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      Double index = (Double)nominalIndexes[i - 1].get(str);
      if (index == null) {
        index = new Double(nominalStrings[i - 1].size());
        nominalIndexes[i - 1].put(str, index);
        nominalStrings[i - 1].addElement(str);
      }
      vals[i - 1] = index.doubleValue();
    }
    break;
  case TEXT:
    String txt = rs.getString(i);
   
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      Double index = (Double)nominalIndexes[i - 1].get(txt);
      if (index == null) {
        index = new Double(nominalStrings[i - 1].size());
        nominalIndexes[i - 1].put(txt, index);
        nominalStrings[i - 1].addElement(txt);
      }
      vals[i - 1] = index.doubleValue();
    }
    break;
  case BOOL:
    boolean boo = rs.getBoolean(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (boo ? 1.0 : 0.0);
    }
    break;
  case DOUBLE:
    //    BigDecimal bd = rs.getBigDecimal(i, 4);
    double dd = rs.getDouble(i);
    // Use the column precision instead of 4?
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      //      newInst.setValue(i - 1, bd.doubleValue());
      vals[i - 1] =  dd;
    }
    break;
  case BYTE:
    byte by = rs.getByte(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (double)by;
    }
    break;
  case SHORT:
    short sh = rs.getShort(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (double)sh;
    }
    break;
  case INTEGER:
    int in = rs.getInt(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (double)in;
    }
    break;
  case LONG:
    long lo = rs.getLong(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (double)lo;
    }
    break;
  case FLOAT:
    float fl = rs.getFloat(i);
    if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
      vals[i - 1] = (double)fl;
    }
    break;
  case DATE:
          Date date = rs.getDate(i);
          if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
            // TODO: Do a value check here.
            vals[i - 1] = (double)date.getTime();
          }
          break;
  case TIME:
          Time time = rs.getTime(i);
          if (rs.wasNull()) {
      vals[i - 1] = Utils.missingValue();
    } else {
            // TODO: Do a value check here.
            vals[i - 1] = (double) time.getTime();
          }
          break;
  default:
    vals[i - 1] = Utils.missingValue();
  }
      }
      Instance newInst;
      if (m_CreateSparseData) {
  newInst = new SparseInstance(1.0, vals);
      } else {
  newInst = new DenseInstance(1.0, vals);
      }
      instances.addElement(newInst);
      rowCount++;
    }
    //disconnectFromDatabase();  (perhaps other queries might be made)
   
    // Create the header and add the instances to the dataset
    if (m_Debug)
      System.err.println("Creating header...");
    FastVector attribInfo = new FastVector();
    for (int i = 0; i < numAttributes; i++) {
      /* Fix for databases that uppercase column names */
      // String attribName = attributeCaseFix(md.getColumnName(i + 1));
      String attribName = attributeCaseFix(columnNames.get(i));
      switch (attributeTypes[i]) {
      case Attribute.NOMINAL:
  attribInfo.addElement(new Attribute(attribName, nominalStrings[i]));
  break;
      case Attribute.NUMERIC:
  attribInfo.addElement(new Attribute(attribName));
  break;
      case Attribute.STRING:
  Attribute att = new Attribute(attribName, (FastVector) null);
  attribInfo.addElement(att);
  for (int n = 0; n < nominalStrings[i].size(); n++) {
    att.addStringValue((String) nominalStrings[i].elementAt(n));
  }
  break;
      case Attribute.DATE:
  attribInfo.addElement(new Attribute(attribName, (String)null));
  break;
      default:
  throw new Exception("Unknown attribute type");
      }
    }
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.