Example usage for org.apache.commons.lang ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

Usage

From source file:aldenjava.opticalmapping.data.data.OptMapDataReader.java

private DataNode parseSPOT() throws IOException {
    if (nextline == null)
        return null;
    if (singleRecord) {
        System.err.println("There is only one reference in spot file.");
        return null;
    }//from www.j  ava 2s  .co  m
    singleRecord = true;
    String s;
    long refsize = 0;
    br.reset();
    while ((s = br.readLine()).startsWith("#")) {
        if (s.contains("Reference Size")) {
            String[] l = s.split("\t");
            refsize = Long.parseLong(l[l.length - 1]);
        }
    }
    while (s.startsWith("NickID"))
        s = br.readLine();
    List<Long> refl = new ArrayList<Long>();
    List<Long> refp = new ArrayList<Long>();

    while (s != null) {
        String[] line = s.split("\\s+");
        refp.add(Long.parseLong(line[line.length - 1]));
        s = br.readLine();
    }
    br.close();
    refl.add(refp.get(0));
    for (int i = 0; i < refp.size() - 1; i++)
        refl.add(refp.get(i + 1) - refp.get(i));
    refl.add(refsize - refp.get(refp.size() - 1));

    return new DataNode(new File(filename).getName(), refsize,
            ArrayUtils.toPrimitive(refp.toArray(new Long[refp.size()])));
}

From source file:com.opengamma.analytics.financial.model.volatility.smile.fitting.sabr.StandardSmileSurfaceDataBundleTest.java

@Test
public void testObject() {
    assertArrayEquals(FORWARDS, DATA.getForwards(), EPS);
    assertArrayEquals(EXPIRIES, DATA.getExpiries(), 0);
    for (int i = 0; i < STRIKES.length; i++) {
        assertArrayEquals(STRIKES[i], DATA.getStrikes()[i], 0);
        assertArrayEquals(VOLS[i], DATA.getVolatilities()[i], 0);
    }//  ww w. ja v a 2 s.  c  o m
    assertEquals(FORWARD_CURVE, DATA.getForwardCurve());
    //   assertEquals(IS_CALL_DATA, DATA.isCallData());
    StandardSmileSurfaceDataBundle other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, STRIKES,
            VOLS);
    assertEquals(DATA, other);
    assertEquals(DATA.hashCode(), other.hashCode());
    other = new StandardSmileSurfaceDataBundle(SPOT, FORWARDS, EXPIRIES, STRIKES, VOLS, INTERPOLATOR);
    assertArrayEquals(DATA.getExpiries(), other.getExpiries(), 0);
    for (int i = 0; i < STRIKES.length; i++) {
        assertArrayEquals(DATA.getStrikes()[i], other.getStrikes()[i], 0);
        assertArrayEquals(DATA.getVolatilities()[i], other.getVolatilities()[i], 0);
    }

    assertArrayEquals(ArrayUtils.toPrimitive(DATA.getForwardCurve().getForwardCurve().getXData()),
            ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getXData()), 0);
    assertArrayEquals(ArrayUtils.toPrimitive(DATA.getForwardCurve().getForwardCurve().getYData()),
            ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getYData()), 0);
    assertEquals(((InterpolatedDoublesCurve) DATA.getForwardCurve().getForwardCurve()).getInterpolator(),
            ((InterpolatedDoublesCurve) other.getForwardCurve().getForwardCurve()).getInterpolator());
    final ForwardCurve otherCurve = new ForwardCurve(InterpolatedDoublesCurve
            .from(ArrayUtils.add(EXPIRIES, 0, 0), ArrayUtils.add(EXPIRIES, 0, SPOT), INTERPOLATOR));
    other = new StandardSmileSurfaceDataBundle(otherCurve, EXPIRIES, STRIKES, VOLS);
    assertFalse(DATA.equals(other));
    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, new double[] { 0, 0.01, 0.02 }, STRIKES, VOLS);
    assertFalse(DATA.equals(other));
    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, VOLS, VOLS);
    assertFalse(DATA.equals(other));
    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, STRIKES, STRIKES);
    assertFalse(DATA.equals(other));
    //    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, STRIKES, VOLS, !IS_CALL_DATA);
    //    assertFalse(DATA.equals(other));
}

From source file:de.unioninvestment.eai.portal.portlet.crud.domain.model.AbstractDataContainer.java

/**
 * Setzt eine Default-Sortierung aus den Angaben der Konfiguration.
 *//*from   w w w  .j a v  a 2  s .com*/
public void applyDefaultOrder() {
    if (defaultOrder != null && !defaultOrder.isEmpty()) {
        if (!(container instanceof Container.Sortable)) {
            throw new TechnicalCrudPortletException(
                    "Error applying default order to container. Container is not sortable");
        } else {
            List<String> orderCols = new ArrayList<String>();
            List<Boolean> asc = new ArrayList<Boolean>();
            for (ContainerOrder order : defaultOrder) {
                orderCols.add(order.getColumnName());
                asc.add(order.isAscending());
            }
            boolean[] ascending = ArrayUtils.toPrimitive(asc.toArray(new Boolean[asc.size()]));

            ((Container.Sortable) container).sort(orderCols.toArray(), ascending);
        }
    }
}

From source file:com.palantir.atlasdb.keyvalue.impl.partition.FailableKeyValueServices.java

public static DynamicPartitionMap createInMemoryMap(Collection<? extends KeyValueService> services,
        QuorumParameters parameters) {//from www  .  java 2  s. c om
    ArrayList<Byte> keyList = new ArrayList<>();
    NavigableMap<byte[], KeyValueEndpoint> ring = Maps.newTreeMap(UnsignedBytes.lexicographicalComparator());
    keyList.add((byte) 0);
    for (KeyValueService kvs : services) {
        KeyValueEndpoint endpoint = InMemoryKeyValueEndpoint.create(kvs,
                InMemoryPartitionMapService.createEmpty());
        byte[] key = ArrayUtils.toPrimitive(keyList.toArray(new Byte[keyList.size()]));
        ring.put(key, endpoint);
        keyList.add((byte) 0);
    }
    DynamicPartitionMap partitionMap = DynamicPartitionMapImpl.create(parameters, ring,
            PTExecutors.newCachedThreadPool());
    for (KeyValueEndpoint endpoint : ring.values()) {
        endpoint.partitionMapService().updateMap(partitionMap);
    }
    return partitionMap;
}

From source file:com.opengamma.financial.analytics.model.credit.isdanew.ISDACompliantCDSFunction.java

@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs,
        final ComputationTarget target, final Set<ValueRequirement> desiredValues)
        throws AsynchronousExecution {
    final ZonedDateTime now = ZonedDateTime.now(executionContext.getValuationClock());
    final ValueRequirement requirement = desiredValues.iterator().next();
    final ValueProperties properties = requirement.getConstraints().copy().get();

    final LegacyVanillaCDSSecurity security = (LegacyVanillaCDSSecurity) target.getSecurity();
    //LegacyVanillaCreditDefaultSwapDefinition cds = _converter.visitLegacyVanillaCDSSecurity(security);
    final ValueRequirement desiredValue = desiredValues.iterator().next(); // all same constraints

    final String quoteConventionString = desiredValue.getConstraint(ISDAFunctionConstants.CDS_QUOTE_CONVENTION);
    final StandardCDSQuotingConvention quoteConvention = StandardCDSQuotingConvention
            .parse(quoteConventionString);

    final CdsRecoveryRateIdentifier recoveryRateIdentifier = security
            .accept(new CreditSecurityToRecoveryRateVisitor(executionContext.getSecuritySource()));
    Object recoveryRateObject = inputs.getValue(new ValueRequirement("PX_LAST", ComputationTargetType.PRIMITIVE,
            recoveryRateIdentifier.getExternalId()));
    if (recoveryRateObject == null) {
        throw new OpenGammaRuntimeException("Could not get recovery rate");
        //s_logger.warn("Could not get recovery rate, defaulting to 0.4: " + recoveryRateIdentifier);
        //recoveryRateObject = 0.4;
    }/*from  w ww .j  a  v a 2  s  . com*/
    final double recoveryRate = (Double) recoveryRateObject;

    // get the isda curve
    final Object isdaObject = inputs.getValue(ValueRequirementNames.YIELD_CURVE);
    if (isdaObject == null) {
        throw new OpenGammaRuntimeException("Couldn't get isda curve");
    }
    final ISDACompliantYieldCurve yieldCurve = (ISDACompliantYieldCurve) isdaObject;

    // spreads
    NodalTenorDoubleCurve spreadObject = (NodalTenorDoubleCurve) inputs
            .getValue(ValueRequirementNames.BUCKETED_SPREADS);
    if (spreadObject == null) {
        throw new OpenGammaRuntimeException("Unable to get spreads");
    }
    final double[] spreads = ArrayUtils.toPrimitive(spreadObject.getYData());
    //final String pillarString = IMMDateGenerator.isIMMDate(security.getMaturityDate()) ? requirement.getConstraint(ISDAFunctionConstants.ISDA_BUCKET_TENORS) : ISDACompliantCreditCurveFunction.NON_IMM_PILLAR_TENORS;
    final ZonedDateTime[] bucketDates = SpreadCurveFunctions.getPillarDates(now, spreadObject.getXData());
    final CDSQuoteConvention[] quotes = SpreadCurveFunctions.getQuotes(security.getMaturityDate(), spreads,
            security.getParSpread(), quoteConvention, false);

    // spreads
    NodalTenorDoubleCurve pillarObject = (NodalTenorDoubleCurve) inputs
            .getValue(ValueRequirementNames.PILLAR_SPREADS);
    if (pillarObject == null) {
        throw new OpenGammaRuntimeException("Unable to get pillars");
    }

    // CDS analytics for credit curve (possible performance improvement if earlier result obtained)
    //final LegacyVanillaCreditDefaultSwapDefinition curveCDS = cds.withStartDate(now);
    //security.setStartDate(now); // needed for curve instruments
    final CDSAnalytic[] bucketCDSs = new CDSAnalytic[bucketDates.length];
    for (int i = 0; i < bucketCDSs.length; i++) {
        //security.setMaturityDate(bucketDates[i]);
        final CDSAnalyticVisitor visitor = new CDSAnalyticVisitor(now.toLocalDate(), _holidaySource,
                _regionSource, security.getStartDate().toLocalDate(), bucketDates[i].toLocalDate(),
                recoveryRate);
        bucketCDSs[i] = security.accept(visitor);
    }

    final ZonedDateTime[] pillarDates = SpreadCurveFunctions.getPillarDates(now, pillarObject.getXData());
    final CDSAnalytic[] pillarCDSs = new CDSAnalytic[pillarDates.length];
    for (int i = 0; i < pillarCDSs.length; i++) {
        //security.setMaturityDate(bucketDates[i]);
        final CDSAnalyticVisitor visitor = new CDSAnalyticVisitor(now.toLocalDate(), _holidaySource,
                _regionSource, security.getStartDate().toLocalDate(), pillarDates[i].toLocalDate(),
                recoveryRate);
        pillarCDSs[i] = security.accept(visitor);
    }

    final ISDACompliantCreditCurve creditCurve = (ISDACompliantCreditCurve) inputs
            .getValue(ValueRequirementNames.HAZARD_RATE_CURVE);
    if (creditCurve == null) {
        throw new OpenGammaRuntimeException("Couldnt get credit curve");
    }

    //final CDSAnalytic analytic = CDSAnalyticConverter.create(cds, now.toLocalDate());
    final CDSAnalyticVisitor visitor = new CDSAnalyticVisitor(now.toLocalDate(), _holidaySource, _regionSource,
            recoveryRate);
    final CDSAnalytic analytic = security.accept(visitor);
    final BuySellProtection buySellProtection = security.isBuy() ? BuySellProtection.BUY
            : BuySellProtection.SELL;
    final Double cdsQuoteDouble = (Double) inputs.getValue(MarketDataRequirementNames.MARKET_VALUE);
    if (cdsQuoteDouble == null) {
        throw new OpenGammaRuntimeException("Couldn't get spread for " + security);
    }
    final CDSQuoteConvention quote = SpreadCurveFunctions.getQuotes(security.getMaturityDate(),
            new double[] { cdsQuoteDouble }, security.getParSpread(), quoteConvention, true)[0];

    final double notional = security.getNotional().getAmount();
    final double coupon = security.getParSpread() * ONE_BPS;
    final PointsUpFront puf = getPointsUpfront(quote, buySellProtection, yieldCurve, analytic, creditCurve);
    final double accruedPremium = analytic.getAccruedPremium(coupon) * notional;
    final int accruedDays = analytic.getAccuredDays();
    final double quotedSpread = getQuotedSpread(quote, puf, buySellProtection, yieldCurve, analytic)
            .getQuotedSpread();
    final double upfrontAmount = getUpfrontAmount(analytic, puf, notional, buySellProtection);
    final double cleanPV = puf.getPointsUpFront() * notional;
    final double cleanPrice = getCleanPrice(puf);
    final TenorLabelledMatrix1D bucketedCS01 = getBucketedCS01(analytic, bucketCDSs, spreadObject.getXData(),
            quote, notional, yieldCurve, creditCurve);
    final double parallelCS01 = getParallelCS01(quote, analytic, yieldCurve, notional, pillarCDSs,
            ArrayUtils.toPrimitive(pillarObject.getYData()));

    final Set<ComputedValue> results = Sets.newHashSetWithExpectedSize(_valueRequirements.length);
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.ACCRUED_PREMIUM, target.toSpecification(), properties),
            accruedPremium));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.ACCRUED_DAYS, target.toSpecification(), properties),
            accruedDays));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.QUOTED_SPREAD, target.toSpecification(), properties),
            quotedSpread / ONE_BPS));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.UPFRONT_AMOUNT, target.toSpecification(), properties),
            upfrontAmount));
    results.add(new ComputedValue(new ValueSpecification(ValueRequirementNames.DIRTY_PRESENT_VALUE,
            target.toSpecification(), properties), upfrontAmount));
    results.add(new ComputedValue(new ValueSpecification(ValueRequirementNames.CLEAN_PRESENT_VALUE,
            target.toSpecification(), properties), cleanPV));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.PRINCIPAL, target.toSpecification(), properties),
            cleanPV));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.CLEAN_PRICE, target.toSpecification(), properties),
            cleanPrice));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.BUCKETED_CS01, target.toSpecification(), properties),
            bucketedCS01));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.PARALLEL_CS01, target.toSpecification(), properties),
            parallelCS01));
    results.add(new ComputedValue(
            new ValueSpecification(ValueRequirementNames.POINTS_UPFRONT, target.toSpecification(), properties),
            puf.getPointsUpFront()));
    return results;
}

From source file:com.stoxx.service.business.registration.RegistrationServiceImpl.java

private void assignRolesForReRegisteredUser(UserProfileDetails userProfileDetails, ThemeDisplay themeDisplay,
        ServiceContext serviceContext, TranslatorAgency translatorAgency, User user) throws STOXXException {
    try {//ww  w .  j  av a  2 s . c o m
        if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) {
            if (null != userProfileDetails.getSalesEntryId()) {

                List<Long> roleList = new ArrayList<Long>();
                Long salesEntryID = userProfileDetails.getSalesEntryId();
                SalesEntry salesEntry = SalesEntryLocalServiceUtil.getSalesEntry(salesEntryID);
                if (!(salesEntry.getPackageNames().contains(StringPool.COMMA))) {
                    Role packageRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),
                            salesEntry.getPackageNames().trim());
                    long packageRoleId = packageRole.getRoleId();
                    roleList.add(packageRoleId);
                } else {
                    for (String packageName : salesEntry.getPackageNames().split(StringPool.COMMA)) {
                        Role packageRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),
                                packageName.trim());
                        long packageRoleId = packageRole.getRoleId();
                        roleList.add(packageRoleId);
                    }
                }

                if (StringUtils.isNotBlank(salesEntry.getKeyEmailAddress()) && salesEntry.getKeyEmailAddress()
                        .trim().equalsIgnoreCase(userProfileDetails.getEmailAddress())) {
                    if (isLicensedUser(userProfileDetails.getEmailAddress())) {
                        Role keyAccntHolderUserRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),
                                STOXXConstants.STOXX_KEY_ACCOUNT_HOLDER_ROLE);
                        long roleKeyAccntHolder = keyAccntHolderUserRole.getRoleId();
                        roleList.add(roleKeyAccntHolder);
                    }
                }

                long roleLicensed[] = ArrayUtils.toPrimitive(roleList.toArray(new Long[roleList.size()]));
                RoleLocalServiceUtil.addUserRoles(user.getUserId(), roleLicensed);
            }
        } else if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) {
            if (translatorAgency != null) {

                StringBuilder userGroupNameTemp = new StringBuilder();
                String userGroupName = StringPool.BLANK;
                List<Long> translatorRoles = null;
                if (translatorAgency.getCompanyName().trim().contains(StringPool.SPACE)) {

                    for (String word : translatorAgency.getCompanyName().trim().split(StringPool.SPACE)) {
                        userGroupNameTemp.append(word).append(StringPool.UNDERLINE);
                    }
                    userGroupName = userGroupNameTemp.substring(0, userGroupNameTemp.length() - 1);
                    translatorRoles = assignTranslatorRole(userGroupName, translatorAgency, themeDisplay);
                } else {
                    userGroupName = translatorAgency.getCompanyName().trim();
                    translatorRoles = assignTranslatorRole(userGroupName, translatorAgency, themeDisplay);
                }
                UserGroup translatorGroup = UserGroupLocalServiceUtil.getUserGroup(themeDisplay.getCompanyId(),
                        userGroupName);
                long translatorGroupId[] = { translatorGroup.getUserGroupId() };
                long translatorRoleId[] = ArrayUtils
                        .toPrimitive(translatorRoles.toArray(new Long[translatorRoles.size()]));
                if (translatorAgency.getAgencyManagerEmailId()
                        .equalsIgnoreCase(userProfileDetails.getEmailAddress())) {
                    RoleLocalServiceUtil.addUserRoles(user.getUserId(), translatorRoleId);
                    UserGroupLocalServiceUtil.addUserUserGroups(user.getUserId(),
                            UserGroupLocalServiceUtil.getUserGroups(translatorGroupId));
                }

            }
        }

        Role powerUserRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),
                RoleConstants.POWER_USER);
        if (Validator.isNotNull(powerUserRole)) {
            long rolePower[] = { powerUserRole.getRoleId() };
            if (Validator.isNotNull(user) && rolePower.length > 0) {
                RoleLocalServiceUtil.unsetUserRoles(user.getUserId(), rolePower);
            }
        }
    } catch (PortalException e) {
        logger.error(e.getMessage(), e);
        throw new STOXXException(e.getMessage(), e);
    } catch (SystemException e) {
        logger.error(e.getMessage(), e);
        throw new STOXXException(e.getMessage(), e);
    }

}

From source file:aldenjava.opticalmapping.data.data.OptMapDataReader.java

private DataNode parseOPT() throws IOException {
    if (nextline == null)
        return null;
    if (singleRecord) {
        System.err.println("There is only one reference in opt file.");
        return null;
    }// w  w w. j ava2  s. c om
    singleRecord = true;

    List<Long> refl = new ArrayList<Long>();
    String s = br.readLine();
    while (s != null) {
        String[] line = s.split("\\s+");
        refl.add((long) (Double.parseDouble(line[0]) * 1000));
        s = br.readLine();
    }
    return new DataNode(new File(filename).getName(),
            ArrayUtils.toPrimitive(refl.toArray(new Long[refl.size()])));
}

From source file:com.opengamma.analytics.financial.interestrate.payments.method.CouponIborCompoundedDiscountingMethodTest.java

@Test
/**/* w  w  w  .  ja v  a2s  .  co  m*/
 * Tests the present value curve sensitivity vs a finite difference calculation.
 */
public void parSpreadCurveSensitivity() {
    InterestRateCurveSensitivity pscsComputed = METHOD_COMPOUNDED.presentValueCurveSensitivity(CPN_BEFORE,
            CURVES_BUNDLE);
    pscsComputed = pscsComputed.cleaned();
    assertEquals("CouponIborCompounded Discounting: present value curve sensitivity", 2,
            pscsComputed.getSensitivities().size()); // 2 curves
    assertEquals("CouponIborCompounded Discounting: present value curve sensitivity", 1,
            pscsComputed.getSensitivities().get(CURVES_NAMES[0]).size()); // 1 discounting
    //Testing note: Sensitivity is for a movement of 1. 1E+2 = 0.01 unit for a 1 bp move.
    final double deltaShift = 1.0E-6;
    // Credit curve sensitivity
    final String bumpedCurveName = "Bumped Curve";
    final CouponIborCompounding cpnBumped = CPN_DEFINITION.toDerivative(REFERENCE_DATE_BEFORE, CURVES_NAMES[0],
            bumpedCurveName);
    final double[] nodeTimesDsc = new double[] { cpnBumped.getPaymentTime() };
    final List<DoublesPair> sensiDscFD = FDCurveSensitivityCalculator.curveSensitvityFDCalculator(CPN_BEFORE,
            PVC, CURVES_BUNDLE, CURVES_NAMES[0], nodeTimesDsc, deltaShift);
    final List<DoublesPair> sensiDscComputed = pscsComputed.getSensitivities().get(CURVES_NAMES[0]);
    assertTrue("parSpread: curve sensitivity - dsc",
            InterestRateCurveSensitivityUtils.compare(sensiDscFD, sensiDscComputed, TOLERANCE_SENSI_2));
    final Set<Double> nodeTimesFwdSet = new TreeSet<>();
    final int nbSub = CPN_BEFORE.getFixingTimes().length;
    nodeTimesFwdSet.add(CPN_BEFORE.getFixingPeriodStartTimes()[0]);
    for (int loopsub = 1; loopsub < nbSub; loopsub++) {
        nodeTimesFwdSet.add(CPN_BEFORE.getFixingPeriodEndTimes()[loopsub - 1]);
        nodeTimesFwdSet.add(CPN_BEFORE.getFixingPeriodStartTimes()[loopsub]);
    }
    nodeTimesFwdSet.add(CPN_BEFORE.getFixingPeriodEndTimes()[nbSub - 1]);
    final double[] nodeTimesFwd = ArrayUtils
            .toPrimitive(nodeTimesFwdSet.toArray(new Double[nodeTimesFwdSet.size()]));
    final List<DoublesPair> sensiFwdFD = FDCurveSensitivityCalculator.curveSensitvityFDCalculator(CPN_BEFORE,
            PVC, CURVES_BUNDLE, CURVES_NAMES[1], nodeTimesFwd, deltaShift);
    final List<DoublesPair> sensiFwdComputed = pscsComputed.getSensitivities().get(CURVES_NAMES[1]);
    assertTrue("parSpread: curve sensitivity - fwd",
            InterestRateCurveSensitivityUtils.compare(sensiFwdFD, sensiFwdComputed, TOLERANCE_SENSI_2 * 10));
}

From source file:aldenjava.opticalmapping.data.data.DataNode.java

/**
 * Returns the signal density along <code>DataNode</code> using a sliding window of size {@code regionSize}.
 * //ww  w.ja va 2  s  .co  m
 * @param regionSize
 *            size of the sliding window
 * @return An array of signal density
 */
public double[] getSignalDensityAcrossRegion(long regionSize) {
    int startSig = 0;
    int stopSig = 0;
    List<Double> densityList = new ArrayList<Double>();
    while (startSig < refp.length - 1 && stopSig < refp.length - 1) {
        if (getSignalLength(startSig, stopSig) + 2 > regionSize) {
            startSig++;
            continue;
        }

        if (getSignalLength(startSig, stopSig) + 2 + getRefl(startSig) + getRefl(stopSig + 1) < regionSize) {
            stopSig++;
            continue;
        }

        // Must be in this way
        double density = (stopSig - startSig + 1) / (double) regionSize;
        densityList.add(density);
        startSig++;
        stopSig++;
    }
    return ArrayUtils.toPrimitive(densityList.toArray(new Double[densityList.size()]));
}

From source file:com.flexive.core.security.UserTicketStore.java

public static UserTicket getUserTicket(String loginName) throws FxApplicationException {
    FxContext ri = FxContext.get();/*from ww  w . j  a  v a2 s . com*/
    ri.runAsSystem();
    try {
        AccountEngine ae = EJBLookup.getAccountEngine();
        Account acc = ae.load(loginName);
        final List<UserGroup> groups = ae.getGroups(acc.getId());
        final List<Role> roleList = ae.getRoles(acc.getId(), RoleLoadMode.ALL);
        final Role[] roles = roleList.toArray(new Role[roleList.size()]);
        final List<ACLAssignment> assignmentList = ae.loadAccountAssignments(acc.getId());
        ACLAssignment[] aad = assignmentList.toArray(new ACLAssignment[assignmentList.size()]);
        final List<Long> groupIds = FxSharedUtils.getSelectableObjectIdList(groups);
        return new UserTicketImpl(ri.getApplicationId(), ri.isWebDAV(), acc,
                ArrayUtils.toPrimitive(groupIds.toArray(new Long[groupIds.size()])), roles, aad,
                acc.getLanguage());
    } catch (FxNoAccessException exc) {
        // This should NEVER happen since we are running as system
        throw new FxLoadException(LOG, exc);
    } finally {
        ri.stopRunAsSystem();
    }
}