Examples of Fraction


Examples of org.apache.commons.math3.fraction.Fraction

    @Test
    public void testGetSetColumnVectorLarge() {
        int n = 3 * BlockFieldMatrix.BLOCK_SIZE;
        FieldMatrix<Fraction> m = new BlockFieldMatrix<Fraction>(FractionField.getInstance(), n, n);
        FieldVector<Fraction> sub = new ArrayFieldVector<Fraction>(n, new Fraction(1));

        m.setColumnVector(2, sub);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (j != 2) {
                    Assert.assertEquals(new Fraction(0), m.getEntry(i, j));
                } else {
                    Assert.assertEquals(new Fraction(1), m.getEntry(i, j));
                }
            }
        }
        Assert.assertEquals(sub, m.getColumnVector(2));

View Full Code Here

Examples of org.apache.commons.math3.fraction.Fraction

    @Test
    public void testGetSetRowLarge() {
        int n = 3 * BlockFieldMatrix.BLOCK_SIZE;
        FieldMatrix<Fraction> m = new BlockFieldMatrix<Fraction>(FractionField.getInstance(), n, n);
        Fraction[] sub = new Fraction[n];
        Arrays.fill(sub, new Fraction(1));

        m.setRow(2, sub);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (i != 2) {
                    Assert.assertEquals(new Fraction(0), m.getEntry(i, j));
                } else {
                    Assert.assertEquals(new Fraction(1), m.getEntry(i, j));
                }
            }
        }
        checkArrays(sub, m.getRow(2));

View Full Code Here

Examples of org.gstreamer.Fraction

     *         available
     */
    public double getVideoSinkFrameRate() {
      for (Element sink : getSinks()) {
        for (Pad pad : sink.getPads()) {
          Fraction frameRate = Video.getVideoFrameRate(pad);
          if (frameRate != null) {
            return frameRate.toDouble();
          }
        }
      }
      return 0;
    }
View Full Code Here

Examples of org.gstreamer.Fraction

            if (keepAspect) {
                // Scale width according to pixel aspect ratio.
                Caps videoCaps = videoPad.getNegotiatedCaps();
                Structure capsStruct = videoCaps.getStructure(0);
                if (capsStruct.hasField("pixel-aspect-ratio")) {
                    Fraction pixelAspectRatio = capsStruct.getFraction("pixel-aspect-ratio");
                    scaledWidth = scaledWidth * pixelAspectRatio.getNumerator() / pixelAspectRatio.getDenominator();
                }
            }

            // Tell swing to use the new buffer
            update(scaledWidth, currentImage.getHeight());
View Full Code Here

Examples of org.gstreamer.Fraction

   *         available
   */
  public double getVideoSinkFrameRate() {
    for (Element sink : getSinks()) {
      for (Pad pad : sink.getPads()) {
        Fraction frameRate = Video.getVideoFrameRate(pad);
        if (frameRate != null) {
          return frameRate.toDouble();
        }
      }
    }
    return 0;
  }
View Full Code Here

Examples of org.kocakosm.pitaya.math.Fraction

  }

  @Test
  public void testInstanciation()
  {
    assertEquals(ONE_QUARTER, new Fraction(1, 4));
  }
View Full Code Here

Examples of org.kocakosm.pitaya.math.Fraction

  }

  @Test(expected = IllegalArgumentException.class)
  public void testInstanciationWithInvalidDenominator()
  {
    new Fraction(42, 0);
  }
View Full Code Here

Examples of org.kocakosm.pitaya.math.Fraction

  }

  @Test
  public void testNumerator()
  {
    Fraction f = valueOf("42 / 16");
    assertEquals(42, f.numerator().intValue());
  }
View Full Code Here

Examples of org.kocakosm.pitaya.math.Fraction

  }

  @Test
  public void testDenominator()
  {
    Fraction f = valueOf("42 / 16");
    assertEquals(16, f.denominator().intValue());
  }
View Full Code Here

Examples of ptolemy.math.Fraction

                remainingActors.remove(actor);
            }

            clusteredActors.add(actor);

            entityToFiringsPerIteration.put(actor, new Fraction(1));
            pendingActors.addLast(actor);

            while (!pendingActors.isEmpty()) {
                Actor currentActor = (Actor) pendingActors.removeFirst();
                Iterator actorPorts = ((ComponentEntity) currentActor)
                        .portList().iterator();

                while (actorPorts.hasNext()) {
                    IOPort currentPort = (IOPort) actorPorts.next();
                    _propagatePort(container, currentPort,
                            entityToFiringsPerIteration, externalRates,
                            remainingActors, pendingActors, clusteredActors,
                            clusteredExternalPorts);
                }
            }

            // Now we have _clusteredActors, which contains actors in
            // one cluster (they are connected). Find the LCM of their
            // denominator and normalize their firings. This means firings
            // of actors are only normalized within their cluster.
            int lcm = 1;

            for (Iterator actors = clusteredActors.iterator(); actors.hasNext();) {
                Actor currentActor = (Actor) actors.next();
                Fraction fraction = (Fraction) entityToFiringsPerIteration
                        .get(currentActor);
                int denominator = fraction.getDenominator();
                lcm = Fraction.lcm(lcm, denominator);
            }

            // Got the normalizing factor.
            Fraction lcmFraction = new Fraction(lcm);

            for (Iterator actors = clusteredActors.iterator(); actors.hasNext();) {
                Actor currentActor = (Actor) actors.next();
                Fraction repetitions = ((Fraction) entityToFiringsPerIteration
                        .get(currentActor)).multiply(lcmFraction);

                if (repetitions.getDenominator() != 1) {
                    throw new InternalErrorException(
                            "Failed to properly perform"
                                    + " fraction normalization.");
                }

                entityToFiringsPerIteration.put(currentActor, repetitions);
            }

            for (Iterator externalPorts = clusteredExternalPorts.iterator(); externalPorts
                    .hasNext();) {
                IOPort port = (IOPort) externalPorts.next();
                Fraction rate = ((Fraction) externalRates.get(port))
                        .multiply(lcmFraction);

                if (rate.getDenominator() != 1) {
                    throw new InternalErrorException(
                            "Failed to properly perform"
                                    + " fraction normalization.");
                }
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.