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

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

Introduction

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

Prototype

public static double[] addAll(double[] array1, double[] array2) 

Source Link

Document

Adds all the elements of the given arrays into a new array.

Usage

From source file:com.rapidminer.operator.postprocessing.SimpleUncertainPredictionsTransformation.java

@Override
public OperatorVersion[] getIncompatibleVersionChanges() {
    return (OperatorVersion[]) ArrayUtils.addAll(super.getIncompatibleVersionChanges(),
            new OperatorVersion[] { VERSION_MAY_WRITE_INTO_DATA });
}

From source file:net.itransformers.idiscover.discoverylisteners.XmlTopologyDeviceLogger.java

public void handleDevice(String deviceName, RawDeviceData rawData, DiscoveredDeviceData discoveredDeviceData,
        Resource resource) {/*from   ww w. j a v  a2s .  c o m*/
    ByteArrayOutputStream graphMLOutputStream = new ByteArrayOutputStream();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        JaxbMarshalar.marshal(discoveredDeviceData, os, "DiscoveredDevice");
    } catch (JAXBException e) {
        logger.error(e.getMessage(), e);
    }
    XsltTransformer transformer = new XsltTransformer();
    try {
        transformer.transformXML(new ByteArrayInputStream(os.toByteArray()), xsltFileName, graphMLOutputStream,
                null, null);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

    try {
        final String fileName = "node-" + deviceName + ".graphml";
        //            String fullFileName = path + File.separator + fileName;
        final File nodeFile = new File(deviceCentricPath, fileName);
        String graphml = null;
        try {
            graphml = new XmlFormatter().format(new String(graphMLOutputStream.toByteArray()));
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        }
        FileUtils.writeStringToFile(nodeFile, graphml);

        try {
            final File networkGraphml = new File(networkCentricPath + File.separator + "network.graphml");
            if (networkGraphml.exists()) {
                Map<String, String> edgesTypes = new HashMap<String, String>();
                edgesTypes.put("name", "string");
                edgesTypes.put("method", "string");
                edgesTypes.put("dataLink", "string");
                edgesTypes.put("ipLink", "string");
                edgesTypes.put("IPv4Forwarding", "string");
                edgesTypes.put("IPv6Forwarding", "string");
                edgesTypes.put("InterfaceNameA", "string");
                edgesTypes.put("InterfaceNameB", "string");
                edgesTypes.put("IPv4AddressA", "string");
                edgesTypes.put("IPv4AddressB", "string");
                edgesTypes.put("edgeTooltip", "string");
                edgesTypes.put("diff", "string");
                edgesTypes.put("diffs", "string");
                edgesTypes.put("bgpAutonomousSystemA", "string");
                edgesTypes.put("bgpAutonomousSystemB", "string");

                Map<String, String> vertexTypes = new HashMap<String, String>();
                vertexTypes.put("deviceModel", "string");
                vertexTypes.put("deviceType", "string");
                vertexTypes.put("nodeInfo", "string");
                vertexTypes.put("hostname", "string");
                vertexTypes.put("deviceStatus", "string");
                vertexTypes.put("DiscoveredIPv4Address", "string");
                vertexTypes.put("geoCoordinates", "string");
                vertexTypes.put("SubnetPrefix", "string");
                vertexTypes.put("site", "string");
                vertexTypes.put("diff", "string");
                vertexTypes.put("diffs", "string");
                vertexTypes.put("diffs", "string");
                vertexTypes.put("IPv6Forwarding", "string");
                vertexTypes.put("IPv4Forwarding", "string");
                vertexTypes.put("bgpLocalAS", "string");

                Map<String, MergeConflictResolver> edgeConflictResolver = new HashMap<String, MergeConflictResolver>();
                Map<String, MergeConflictResolver> nodeConflictResolver = new HashMap<String, MergeConflictResolver>();
                edgeConflictResolver.put("method", new MergeConflictResolver() {
                    @Override
                    public Object resolveConflict(Object srcValue, Object targetValue) {
                        // if (srcValue instanceof String && targetValue instanceof String) {
                        String[] srcArray = ((String) srcValue).split(",");
                        String[] targetArray = ((String) targetValue).split(",");

                        String[] both = (String[]) ArrayUtils.addAll(srcArray, targetArray);
                        Arrays.sort(both);
                        LinkedHashSet<String> m = new LinkedHashSet<String>();
                        Collections.addAll(m, both);

                        return StringUtils.join(m, ',');

                    }
                });
                new GrahmlMerge(nodeConflictResolver, edgeConflictResolver).merge(nodeFile, networkGraphml,
                        networkGraphml, vertexTypes, edgesTypes, graphtType);
            } else {
                //networkGraphml.createNewFile();
                FileUtils.writeStringToFile(networkGraphml, graphml);
                // new GrahmlMerge().merge(nodeFile, networkGraphml, networkGraphml);
            }
            //TODO remove when you have some time and do the diff in the correct way!
            //                File networkGraphmls = new File(labelPath,graphtType+".graphmls");
            //                if (!networkGraphmls.exists()){
            //                     FileWriter writer = new FileWriter(networkGraphmls);
            //                     writer.write("network.graphml\n");
            //                     writer.close();
            //                }

        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.inflation.ParameterSensitivityInflationUnderlyingMatrixCalculator.java

/**
 * Computes the sensitivity with respect to the parameters from the point sensitivities to the continuously compounded rate.
 * @param sensitivity The point sensitivity.
 * @param inflation The inflation provider. Not null.
 * @param curvesSet The set of curves for which the sensitivity will be computed. Not null.
 * @return The sensitivity (as a ParameterSensitivity). ??The order of the sensitivity is by curve as provided by the curvesSet??
 *//*w w w.ja v a 2 s.c  om*/
@Override
public DoubleMatrix1D pointToParameterSensitivity(final InflationSensitivity sensitivity,
        final InflationProviderInterface inflation, final Set<String> curvesSet) {
    // TODO: The first part depends only of the multicurves and curvesSet, not the sensitivity. Should it be refactored and done only once?
    final Set<String> curveNamesSet = inflation.getAllNames(); // curvesSet; //
    final int nbCurve = curveNamesSet.size();
    final String[] curveNamesArray = new String[nbCurve];
    int loopname = 0;
    final LinkedHashMap<String, Integer> curveNum = new LinkedHashMap<>();
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        curveNamesArray[loopname] = name;
        curveNum.put(name, loopname++);
    }
    final int[] nbNewParameters = new int[nbCurve];
    // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle.
    final int[][] indexOther = new int[nbCurve][];
    // Implementation note: indexOther - the index of the underlying curves, if any.
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        nbNewParameters[loopname] = inflation.getNumberOfParameters(name);
        loopname++;
    }
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        final List<String> underlyingCurveNames = inflation.getUnderlyingCurvesNames(name);
        final IntArrayList indexOtherList = new IntArrayList();
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                indexOtherList.add(i);
                nbNewParameters[loopname] -= nbNewParameters[i]; // Only one level: a curve used as an underlying can not have an underlying itself.
            }
        }
        indexOther[loopname] = indexOtherList.toIntArray();
        loopname++;
    }
    final int nbSensiCurve = curvesSet.size();
    //    for (final String name : curveNamesSet) { // loop over all curves (by name)
    //      if (curvesSet.contains(name)) {
    //        nbSensiCurve++;
    //      }
    //    }
    final int[] nbNewParamSensiCurve = new int[nbSensiCurve];
    // Implementation note: nbNewParamSensiCurve
    final int[][] indexOtherSensiCurve = new int[nbSensiCurve][];
    // Implementation note: indexOtherSensiCurve -
    final int[] startCleanParameter = new int[nbSensiCurve];
    // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start.
    final int[][] startDirtyParameter = new int[nbSensiCurve][];
    // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
    int nbSensitivityCurve = 0;
    int nbCleanParameters = 0;
    int currentDirtyStart = 0;
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int num = curveNum.get(name);
        final IntArrayList startDirtyParameterList = new IntArrayList();
        final List<String> underlyingCurveNames = inflation.getUnderlyingCurvesNames(name);
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                startDirtyParameterList.add(currentDirtyStart);
                currentDirtyStart += nbNewParameters[i];
            }
        }
        startDirtyParameterList.add(currentDirtyStart);
        currentDirtyStart += nbNewParameters[num];
        startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray();
        nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num];
        indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num];
        startCleanParameter[nbSensitivityCurve] = nbCleanParameters;
        nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve];
        nbSensitivityCurve++;
        //      }
    }
    // Implementation note: Compute the "dirty" sensitivity, i.e. the sensitivity where the underlying curves are not taken into account.
    double[] sensiDirty = new double[0];
    final Map<String, List<DoublesPair>> sensitivityPriceIndex = sensitivity.getPriceCurveSensitivities();
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int nbParam = inflation.getNumberOfParameters(name);
        final double[] s1Name = new double[nbParam];
        final double[] sDsc1Name = inflation.parameterInflationSensitivity(name,
                sensitivityPriceIndex.get(name));

        //        if ((sDsc1Name != null) && (sFwd1Name == null)) {
        //          s1Name = sDsc1Name;
        //        }
        //        if ((sDsc1Name == null) && (sFwd1Name != null)) {
        //          s1Name = sFwd1Name;
        //        }
        //        if ((sDsc1Name != null) && (sFwd1Name != null)) {
        for (int loopp = 0; loopp < nbParam; loopp++) {
            s1Name[loopp] = sDsc1Name[loopp];
        }
        //        }
        sensiDirty = ArrayUtils.addAll(sensiDirty, s1Name);
        //      }
    }
    // Implementation note: "clean" the sensitivity, i.e. add the underlying curve parts.
    final double[] sensiClean = new double[nbCleanParameters];
    for (int loopcurve = 0; loopcurve < nbSensiCurve; loopcurve++) {
        for (int loopo = 0; loopo < indexOtherSensiCurve[loopcurve].length; loopo++) {
            if (curvesSet.contains(curveNamesArray[indexOtherSensiCurve[loopcurve][loopo]])) {
                for (int loops = 0; loops < nbNewParamSensiCurve[indexOtherSensiCurve[loopcurve][loopo]]; loops++) {
                    sensiClean[startCleanParameter[indexOtherSensiCurve[loopcurve][loopo]]
                            + loops] += sensiDirty[startDirtyParameter[loopcurve][loopo] + loops];
                }
            }
        }
        for (int loops = 0; loops < nbNewParamSensiCurve[loopcurve]; loops++) {
            sensiClean[startCleanParameter[loopcurve]
                    + loops] += sensiDirty[startDirtyParameter[loopcurve][indexOtherSensiCurve[loopcurve].length]
                            + loops];
        }
    }
    return new DoubleMatrix1D(sensiClean);
}

From source file:ips1ap101.lib.core.jsf.JSF.java

public static void upload(Upload upload, String carpeta, EnumOpcionUpload opcion) throws Exception {
    Bitacora.trace(JSF.class, "upload", upload, carpeta, opcion);
    if (upload == null) {
        return;/*from www.jav  a  2s  .  c  o  m*/
    }
    CampoArchivo campoArchivo = upload instanceof CampoArchivo ? (CampoArchivo) upload : null;
    if (campoArchivo != null) {
        campoArchivo.setClientFileName(null);
        campoArchivo.setServerFileName(null);
    }
    UploadedFile uploadedFile = upload.getUploadedFile();
    if (uploadedFile == null) {
        return;
    }
    /**/
    Bitacora.trace(JSF.class, "upload", "name=" + uploadedFile.getOriginalName());
    Bitacora.trace(JSF.class, "upload", "path=" + uploadedFile.getClientFilePath());
    Bitacora.trace(JSF.class, "upload", "type=" + uploadedFile.getContentType());
    Bitacora.trace(JSF.class, "upload", "size=" + uploadedFile.getSize());
    /**/
    if (uploadedFile.getSize() == 0) {
        return;
    }
    /**/
    String sep = System.getProperties().getProperty("file.separator");
    String validChars = StrUtils.VALID_CHARS;
    String filepath = null;
    if (STP.esIdentificadorArchivoValido(carpeta)) {
        filepath = carpeta.replace(".", sep);
    }
    long id = LongUtils.getNewId();
    //      String filename = STP.getRandomString();
    String filename = id + "";
    String pathname = Utils.getAttachedFilesDir(filepath) + filename;
    String ext = Utils.getExtensionArchivo(uploadedFile.getOriginalName());
    if (StringUtils.isNotBlank(ext)) {
        String str = ext.toLowerCase();
        if (StringUtils.containsOnly(str, validChars)) {
            filename += "." + str;
            pathname += "." + str;
        }
    }
    //      if (!EnumOpcionUpload.FILA.equals(opcion)) {
    //          File file = new File(pathname);
    //          uploadedFile.write(file);
    //      }
    int bytesRead;
    int bufferSize = 8192;
    byte[] bytes = null;
    byte[] buffer = new byte[bufferSize];
    try (InputStream input = uploadedFile.getInputStream();
            OutputStream output = new FileOutputStream(pathname)) {
        while ((bytesRead = input.read(buffer)) != -1) {
            if (!EnumOpcionUpload.FILA.equals(opcion)) {
                output.write(buffer, 0, bytesRead);
            }
            if (!EnumOpcionUpload.ARCHIVO.equals(opcion)) {
                if (bytesRead < bufferSize) {
                    bytes = ArrayUtils.addAll(bytes, ArrayUtils.subarray(buffer, 0, bytesRead));
                } else {
                    bytes = ArrayUtils.addAll(bytes, buffer);
                }
            }
        }
    }
    /**/
    String clientFilePath = uploadedFile.getClientFilePath();
    String originalName = uploadedFile.getOriginalName();
    String clientFileName = clientFilePath == null ? originalName : clientFilePath + originalName;
    String serverFileName = Utils.getWebServerRelativePath(pathname);
    if (!EnumOpcionUpload.ARCHIVO.equals(opcion)) {
        String contentType = uploadedFile.getContentType();
        long size = uploadedFile.getSize();
        //          byte[] bytes = uploadedFile.getBytes();
        insert(id, clientFileName, serverFileName, contentType, size, bytes);
    }
    if (campoArchivo != null) {
        campoArchivo.setClientFileName(clientFileName);
        campoArchivo.setServerFileName(serverFileName);
    }
}

From source file:msi.gama.util.matrix.GamaIntMatrix.java

/**
 * Take two matrices (with the same number of columns) and create a big matrix putting the second matrix on the
 * right side of the first matrix/* w ww  .jav  a 2  s.  c o  m*/
 *
 * @param two
 *            matrix to concatenate
 * @return the matrix concatenated
 */
// @Override
// @operator(value = IKeyword.APPEND_VERTICALLY, content_type =
// ITypeProvider.BOTH,
// category={IOperatorCategory.MATRIX})
public IMatrix _opAppendVertically(final IScope scope, final IMatrix b) {
    final GamaIntMatrix a = this;
    final int[] ma = a.getMatrix();
    final int[] mb = ((GamaIntMatrix) b).getMatrix();
    final int[] mab = ArrayUtils.addAll(ma, mb);

    final GamaIntMatrix fl = new GamaIntMatrix(a.getCols(scope), a.getRows(scope) + b.getRows(scope), mab);

    // throw GamaRuntimeException.error("ATTENTION : Matrix additions not
    // implemented. Returns nil for the moment");
    return fl;
}

From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java

@Override
public void update(final Object source, final Object arg) {

    try {/*from  ww  w  .ja va 2  s  . co  m*/
        if (arg instanceof ScriptControllerLogResults && updateViewLock.tryLock(10, TimeUnit.MILLISECONDS)) {
            final ScriptControllerLogResults temp = (ScriptControllerLogResults) arg;
            try {
                addToKnownScripts(temp.getScriptName());
                if (haveSeenBefore(temp)) {
                    if (!results[0].getUniqueID().equals(temp.getUniqueID())) {
                        return;
                    }
                    results[0].setUpdated(temp.getUpdated());
                    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            view.getTreeViewer().refresh(results[0]);
                        }
                    });
                } else {
                    mapID2Controller.put(temp.getUniqueID(), (ILoggingScriptController) source);
                    results = (ScriptControllerLogResults[]) ArrayUtils
                            .addAll(new ScriptControllerLogResults[] { temp }, results);

                    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {

                            Object[] expandedElements = view.getTreeViewer().getExpandedElements();
                            expandedElements = ArrayUtils.add(expandedElements, temp);

                            view.getTreeViewer()
                                    .setInput(ScriptControllerLogContentProvider.this.getElements(null));
                            view.getTreeViewer().refresh(results[0]);

                            view.getTreeViewer().setExpandedElements(expandedElements);
                        }
                    });
                }
            } finally {
                updateViewLock.unlock();
            }

        }
    } catch (InterruptedException e) {
        // ignore as this will only ultimately return to the server
    }
}

From source file:msi.gama.util.matrix.GamaFloatMatrix.java

/**
 * Take two matrices (with the same number of columns) and create a big matrix putting the second matrix on the
 * right side of the first matrix/*from  w w w  .ja  v a2  s.c o m*/
 *
 * @param two
 *            matrix to concatenate
 * @return the matrix concatenated
 */
// @Override
// @operator(value = IKeyword.APPEND_VERTICALLY, content_type =
// ITypeProvider.BOTH, category={IOperatorCategory.MATRIX})
public IMatrix _opAppendVertically(final IScope scope, final IMatrix b) {
    final GamaFloatMatrix a = this;
    final double[] ma = a.getMatrix();
    final double[] mb = ((GamaFloatMatrix) b).getMatrix();
    final double[] mab = ArrayUtils.addAll(ma, mb);

    final GamaFloatMatrix fl = new GamaFloatMatrix(a.getCols(scope), a.getRows(scope) + b.getRows(scope), mab);

    // throw GamaRuntimeException.error("ATTENTION : Matrix additions not
    // implemented. Returns nil for the moment");
    return fl;
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.ParameterSensitivityMulticurveUnderlyingMatrixCalculator.java

/**
 * Computes the sensitivity with respect to the parameters from the point sensitivities to the continuously compounded rate.
 * @param sensitivity The point sensitivity.
 * @param multicurves The multi-curve provider. Not null.
 * @param curvesSet The set of curves for which the sensitivity will be computed. Not null.
 * @return The sensitivity (as a ParameterSensitivity). ??The order of the sensitivity is by curve as provided by the curvesSet??
 *//*from w w  w  .j a  v a  2 s . c  o m*/
@Override
public DoubleMatrix1D pointToParameterSensitivity(final MulticurveSensitivity sensitivity,
        final MulticurveProviderInterface multicurves, final Set<String> curvesSet) {
    // TODO: The first part depends only of the multicurves and curvesSet, not the sensitivity. Should it be refactored and done only once?
    final Set<String> curveNamesSet = multicurves.getAllNames(); // curvesSet; //
    final int nbCurve = curveNamesSet.size();
    final String[] curveNamesArray = new String[nbCurve];
    int loopname = 0;
    final LinkedHashMap<String, Integer> curveNum = new LinkedHashMap<>();
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        curveNamesArray[loopname] = name;
        curveNum.put(name, loopname++);
    }
    final int[] nbNewParameters = new int[nbCurve];
    // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle.
    final int[][] indexOther = new int[nbCurve][];
    // Implementation note: indexOther - the index of the underlying curves, if any.
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        nbNewParameters[loopname] = multicurves.getNumberOfParameters(name);
        loopname++;
    }
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name);
        final IntArrayList indexOtherList = new IntArrayList();
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                indexOtherList.add(i);
                nbNewParameters[loopname] -= nbNewParameters[i]; // Only one level: a curve used as an underlying can not have an underlying itself.
            }
        }
        indexOther[loopname] = indexOtherList.toIntArray();
        loopname++;
    }
    final int nbSensiCurve = curvesSet.size();
    //    for (final String name : curveNamesSet) { // loop over all curves (by name)
    //      if (curvesSet.contains(name)) {
    //        nbSensiCurve++;
    //      }
    //    }
    final int[] nbNewParamSensiCurve = new int[nbSensiCurve];
    // Implementation note: nbNewParamSensiCurve
    final int[][] indexOtherSensiCurve = new int[nbSensiCurve][];
    // Implementation note: indexOtherSensiCurve -
    final int[] startCleanParameter = new int[nbSensiCurve];
    // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start.
    final int[][] startDirtyParameter = new int[nbSensiCurve][];
    // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
    int nbSensitivityCurve = 0;
    int nbCleanParameters = 0;
    int currentDirtyStart = 0;
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int num = curveNum.get(name);
        final IntArrayList startDirtyParameterList = new IntArrayList();
        final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name);
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                startDirtyParameterList.add(currentDirtyStart);
                currentDirtyStart += nbNewParameters[i];
            }
        }
        startDirtyParameterList.add(currentDirtyStart);
        currentDirtyStart += nbNewParameters[num];
        startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray();
        nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num];
        indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num];
        startCleanParameter[nbSensitivityCurve] = nbCleanParameters;
        nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve];
        nbSensitivityCurve++;
        //      }
    }
    // Implementation note: Compute the "dirty" sensitivity, i.e. the sensitivity where the underlying curves are not taken into account.
    double[] sensiDirty = new double[0];
    final Map<String, List<DoublesPair>> sensitivityDsc = sensitivity.getYieldDiscountingSensitivities();
    final Map<String, List<ForwardSensitivity>> sensitivityFwd = sensitivity.getForwardSensitivities();
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int nbParam = multicurves.getNumberOfParameters(name);
        final double[] s1Name = new double[nbParam];
        final double[] sDsc1Name = multicurves.parameterSensitivity(name, sensitivityDsc.get(name));
        final double[] sFwd1Name = multicurves.parameterForwardSensitivity(name, sensitivityFwd.get(name));
        //        if ((sDsc1Name != null) && (sFwd1Name == null)) {
        //          s1Name = sDsc1Name;
        //        }
        //        if ((sDsc1Name == null) && (sFwd1Name != null)) {
        //          s1Name = sFwd1Name;
        //        }
        //        if ((sDsc1Name != null) && (sFwd1Name != null)) {
        for (int loopp = 0; loopp < nbParam; loopp++) {
            s1Name[loopp] = sDsc1Name[loopp] + sFwd1Name[loopp];
        }
        //        }
        sensiDirty = ArrayUtils.addAll(sensiDirty, s1Name);
        //      }
    }
    // Implementation note: "clean" the sensitivity, i.e. add the underlying curve parts.
    final double[] sensiClean = new double[nbCleanParameters];
    for (int loopcurve = 0; loopcurve < nbSensiCurve; loopcurve++) {
        for (int loopo = 0; loopo < indexOtherSensiCurve[loopcurve].length; loopo++) {
            if (curvesSet.contains(curveNamesArray[indexOtherSensiCurve[loopcurve][loopo]])) {
                for (int loops = 0; loops < nbNewParamSensiCurve[indexOtherSensiCurve[loopcurve][loopo]]; loops++) {
                    sensiClean[startCleanParameter[indexOtherSensiCurve[loopcurve][loopo]]
                            + loops] += sensiDirty[startDirtyParameter[loopcurve][loopo] + loops];
                }
            }
        }
        for (int loops = 0; loops < nbNewParamSensiCurve[loopcurve]; loops++) {
            sensiClean[startCleanParameter[loopcurve]
                    + loops] += sensiDirty[startDirtyParameter[loopcurve][indexOtherSensiCurve[loopcurve].length]
                            + loops];
        }
    }
    return new DoubleMatrix1D(sensiClean);
}

From source file:fitnesse.testsystems.slim.SlimCommandRunningClient.java

private List<Object> toList(List<Instruction> instructions) {
    final List<Object> statementsAsList = new ArrayList<Object>(instructions.size());
    for (final Instruction instruction : instructions) {
        ToListExecutor executor = new ToListExecutor() {
            @Override// www.ja  v a 2 s .c  o  m
            public void addPath(String path) throws SlimException {
                statementsAsList.add(asList(instruction.getId(), ImportInstruction.INSTRUCTION, path));
            }

            @Override
            public Object callAndAssign(String symbolName, String instanceName, String methodsName,
                    Object... arguments) throws SlimException {
                Object[] list = new Object[] { instruction.getId(), CallAndAssignInstruction.INSTRUCTION,
                        symbolName, instanceName, methodsName };
                statementsAsList.add(asList(ArrayUtils.addAll(list, arguments)));
                return null;
            }

            @Override
            public Object call(String instanceName, String methodName, Object... arguments)
                    throws SlimException {
                Object[] list = new Object[] { instruction.getId(), CallInstruction.INSTRUCTION, instanceName,
                        methodName };
                statementsAsList.add(asList(ArrayUtils.addAll(list, arguments)));
                return null;
            }

            @Override
            public void create(String instanceName, String className, Object... constructorArgs)
                    throws SlimException {
                Object[] list = new Object[] { instruction.getId(), MakeInstruction.INSTRUCTION, instanceName,
                        className };
                statementsAsList.add(asList(ArrayUtils.addAll(list, constructorArgs)));
            }

            @Override
            public void assign(String symbolName, Object value) {
                if (slimServerVersion < 0.4) {
                    throw new SlimError("The assign instruction is available as of SLIM protocol version 0.4");
                }
                Object[] list = new Object[] { instruction.getId(), AssignInstruction.INSTRUCTION, symbolName,
                        value };
                statementsAsList.add(asList(list));
            }
        };

        instruction.execute(executor);
    }
    return statementsAsList;
}

From source file:gda.device.detector.countertimer.TFGTriggeredScaler.java

public void setReturnCountRates(Boolean returnCountRates) {

    if (!timeChannelRequired && returnCountRates) {
        timeChannelRequired = true;//from   w w  w . jav  a2  s  .  c  o  m
        this.extraNames = (String[]) ArrayUtils.addAll(new String[] { "time" }, this.extraNames);
        this.outputFormat = (String[]) ArrayUtils.addAll(new String[] { this.outputFormat[0] },
                this.outputFormat);
    } else if (timeChannelRequired && this.returnCountRates && !returnCountRates) {
        timeChannelRequired = false;
        this.extraNames = (String[]) ArrayUtils.remove(this.extraNames, 0);
        this.outputFormat = (String[]) ArrayUtils.remove(this.outputFormat, 0);
    }

    this.returnCountRates = returnCountRates;
}