Package org.sbml.jsbml

Examples of org.sbml.jsbml.Unit


        right.getUnits().simplify();
        int mean, scale1, scale2;
        double v1 = left.toNumber().doubleValue(), v2 = right
            .toNumber().doubleValue();
        for (int i = 0; i < left.getUnits().getNumUnits(); i++) {
          Unit u1 = left.getUnits().getUnit(i);
          Unit u2 = right.getUnits().getUnit(i);
          if ((u1.getMultiplier() != 0d)
              && (u2.getMultiplier() != 0d)) {

            mean = (Math.abs(u1.getScale()) + Math.abs(u2
                .getScale())) / 2;

            if (u1.getScale() > mean) {
              scale1 = Math.abs(u1.getScale()) - mean;
              scale2 = mean - u2.getScale();

            } else {
              scale2 = Math.abs(u2.getScale()) - mean;
              scale1 = mean - u1.getScale();
            }

            if (u1.getExponent() < 0) {
              scale1 = -scale1;
              scale2 = -scale2;
            }

            if (scale1 > mean) {
              v1 = v1
                  * Math.pow(10.0, -scale1 * u1.getExponent());
              v2 = v2
                  * Math.pow(10.0, -scale2 * u2.getExponent());

            } else {
              v1 = v1 * Math.pow(10.0, scale1 * u1.getExponent());
              v2 = v2 * Math.pow(10.0, scale2 * u2.getExponent());
            }

            if (u1.getMultiplier() > 1d) {
              v1 = v1 * u1.getMultiplier();
              u1.setMultiplier(1d);
            }

            if (u2.getMultiplier() > 1d) {
              v2 = v2 * u2.getMultiplier();
              u2.setMultiplier(1d);
            }

            u1.setScale(mean);
            u2.setScale(mean);

          }

        }
        left.setValue(v1);
 
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Unit

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.