Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Double MIN_VALUE.

Prototype

double MIN_VALUE

To view the source code for java.lang Double MIN_VALUE.

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:org.jtrfp.trcl.gui.ConfigWindow.java

public ConfigWindow() {
    setTitle("Settings");
    setSize(340, 540);/*from  w ww.  ja  v a2  s. c o m*/
    if (config == null)
        config = new TRConfiguration();
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel generalTab = new JPanel();
    tabbedPane.addTab("General",
            new ImageIcon(ConfigWindow.class
                    .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")),
            generalTab, null);
    GridBagLayout gbl_generalTab = new GridBagLayout();
    gbl_generalTab.columnWidths = new int[] { 0, 0 };
    gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 };
    gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    generalTab.setLayout(gbl_generalTab);

    JPanel settingsLoadSavePanel = new JPanel();
    GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints();
    gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0);
    gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST;
    gbc_settingsLoadSavePanel.gridx = 0;
    gbc_settingsLoadSavePanel.gridy = 0;
    generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel);
    settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);

    JButton btnSave = new JButton("Export...");
    btnSave.setToolTipText("Export these settings to an external file");
    settingsLoadSavePanel.add(btnSave);
    btnSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            exportSettings();
        }
    });

    JButton btnLoad = new JButton("Import...");
    btnLoad.setToolTipText("Import an external settings file");
    settingsLoadSavePanel.add(btnLoad);
    btnLoad.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            importSettings();
        }
    });

    JButton btnConfigReset = new JButton("Reset");
    btnConfigReset.setToolTipText("Reset all settings to defaults");
    settingsLoadSavePanel.add(btnConfigReset);
    btnConfigReset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            defaultSettings();
        }
    });

    JPanel registeredPODsPanel = new JPanel();
    registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints();
    gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0);
    gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH;
    gbc_registeredPODsPanel.gridx = 0;
    gbc_registeredPODsPanel.gridy = 1;
    generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel);
    GridBagLayout gbl_registeredPODsPanel = new GridBagLayout();
    gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 };
    gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 };
    gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    registeredPODsPanel.setLayout(gbl_registeredPODsPanel);

    JPanel podListPanel = new JPanel();
    GridBagConstraints gbc_podListPanel = new GridBagConstraints();
    gbc_podListPanel.insets = new Insets(0, 0, 5, 0);
    gbc_podListPanel.fill = GridBagConstraints.BOTH;
    gbc_podListPanel.gridx = 0;
    gbc_podListPanel.gridy = 0;
    registeredPODsPanel.add(podListPanel, gbc_podListPanel);
    podListPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane podListScrollPane = new JScrollPane();
    podListPanel.add(podListScrollPane, BorderLayout.CENTER);

    podList = new JList(podLM);
    podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    podListScrollPane.setViewportView(podList);

    JPanel podListOpButtonPanel = new JPanel();
    podListOpButtonPanel.setBorder(null);
    GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints();
    gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_podListOpButtonPanel.gridx = 0;
    gbc_podListOpButtonPanel.gridy = 1;
    registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel);
    FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);

    JButton addPodButton = new JButton("Add...");
    addPodButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game.");
    podListOpButtonPanel.add(addPodButton);
    addPodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addPOD();
        }
    });

    JButton removePodButton = new JButton("Remove");
    removePodButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removePodButton.setToolTipText("Remove a POD file from being considered when playing a game");
    podListOpButtonPanel.add(removePodButton);
    removePodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            podLM.removeElement(podList.getSelectedValue());
        }
    });

    JButton podEditButton = new JButton("Edit...");
    podEditButton.setIcon(null);
    podEditButton.setToolTipText("Edit the selected POD path");
    podListOpButtonPanel.add(podEditButton);
    podEditButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editPODPath();
        }
    });

    JPanel missionPanel = new JPanel();
    GridBagConstraints gbc_missionPanel = new GridBagConstraints();
    gbc_missionPanel.fill = GridBagConstraints.BOTH;
    gbc_missionPanel.gridx = 0;
    gbc_missionPanel.gridy = 2;
    generalTab.add(missionPanel, gbc_missionPanel);
    missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_missionPanel = new GridBagLayout();
    gbl_missionPanel.columnWidths = new int[] { 0, 0 };
    gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE };
    missionPanel.setLayout(gbl_missionPanel);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 0;
    missionPanel.add(scrollPane, gbc_scrollPane);

    missionList = new JList(missionLM);
    missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(missionList);

    JPanel missionListOpButtonPanel = new JPanel();
    GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints();
    gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_missionListOpButtonPanel.gridx = 0;
    gbc_missionListOpButtonPanel.gridy = 1;
    missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel);

    JButton addVOXButton = new JButton("Add...");
    addVOXButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addVOXButton.setToolTipText("Add an external VOX file as a mission");
    missionListOpButtonPanel.add(addVOXButton);
    addVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addVOX();
        }
    });

    final JButton removeVOXButton = new JButton("Remove");
    removeVOXButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removeVOXButton.setToolTipText("Remove the selected mission");
    missionListOpButtonPanel.add(removeVOXButton);
    removeVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            missionLM.remove(missionList.getSelectedIndex());
        }
    });

    final JButton editVOXButton = new JButton("Edit...");
    editVOXButton.setToolTipText("Edit the selected Mission's VOX path");
    missionListOpButtonPanel.add(editVOXButton);
    editVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editVOXPath();
        }
    });

    missionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            final String val = (String) missionList.getSelectedValue();
            if (val == null)
                missionList.setSelectedIndex(0);
            else if (isBuiltinVOX(val)) {
                removeVOXButton.setEnabled(false);
                editVOXButton.setEnabled(false);
            } else {
                removeVOXButton.setEnabled(true);
                editVOXButton.setEnabled(true);
            }
        }
    });

    JPanel soundTab = new JPanel();
    tabbedPane.addTab("Sound",
            new ImageIcon(
                    ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")),
            soundTab, null);
    GridBagLayout gbl_soundTab = new GridBagLayout();
    gbl_soundTab.columnWidths = new int[] { 0, 0 };
    gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 };
    gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    soundTab.setLayout(gbl_soundTab);

    JPanel checkboxPanel = new JPanel();
    GridBagConstraints gbc_checkboxPanel = new GridBagConstraints();
    gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0);
    gbc_checkboxPanel.fill = GridBagConstraints.BOTH;
    gbc_checkboxPanel.gridx = 0;
    gbc_checkboxPanel.gridy = 0;
    soundTab.add(checkboxPanel, gbc_checkboxPanel);

    chckbxLinearInterpolation = new JCheckBox("Linear Filtering");
    chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples.");
    chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT);
    checkboxPanel.add(chckbxLinearInterpolation);

    chckbxLinearInterpolation.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            needRestart = true;
        }
    });

    chckbxBufferLag = new JCheckBox("Buffer Lag");
    chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency.");
    checkboxPanel.add(chckbxBufferLag);

    JPanel modStereoWidthPanel = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints();
    gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH;
    gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0);
    gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_modStereoWidthPanel.gridx = 0;
    gbc_modStereoWidthPanel.gridy = 1;
    soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel);

    modStereoWidthSlider = new JSlider();
    modStereoWidthSlider.setPaintTicks(true);
    modStereoWidthSlider.setMinorTickSpacing(25);
    modStereoWidthPanel.add(modStereoWidthSlider);

    final JLabel modStereoWidthLbl = new JLabel("NN%");
    modStereoWidthPanel.add(modStereoWidthLbl);

    JPanel bufferSizePanel = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    bufferSizePanel.setBorder(
            new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints();
    gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH;
    gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0);
    gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_bufferSizePanel.gridx = 0;
    gbc_bufferSizePanel.gridy = 2;
    soundTab.add(bufferSizePanel, gbc_bufferSizePanel);

    audioBufferSizeCB = new JComboBox();
    audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values()));
    bufferSizePanel.add(audioBufferSizeCB);

    soundOutputSelectorGUI = new SoundOutputSelectorGUI();
    soundOutputSelectorGUI.setBorder(
            new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints();
    gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH;
    gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0);
    gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL;
    gbc_soundOutputSelectorGUI.gridx = 0;
    gbc_soundOutputSelectorGUI.gridy = 3;
    soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI);

    modStereoWidthSlider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%");
            needRestart = true;
        }
    });

    JPanel okCancelPanel = new JPanel();
    getContentPane().add(okCancelPanel, BorderLayout.SOUTH);
    okCancelPanel.setLayout(new BorderLayout(0, 0));

    JButton btnOk = new JButton("OK");
    btnOk.setToolTipText("Apply these settings and close the window");
    okCancelPanel.add(btnOk, BorderLayout.WEST);
    btnOk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            applySettings();
            ConfigWindow.this.setVisible(false);
        }
    });

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Close the window without applying settings");
    okCancelPanel.add(btnCancel, BorderLayout.EAST);

    JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath());
    lblConfigpath.setIcon(null);
    lblConfigpath.setToolTipText("Default config file path");
    lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER);
    lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6));
    okCancelPanel.add(lblConfigpath, BorderLayout.CENTER);
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            ConfigWindow.this.setVisible(false);
        }
    });
}

From source file:org.apache.hadoop.hive.ql.exec.vector.ptf.VectorPTFEvaluatorDoubleMax.java

@Override
public void resetEvaluator() {
    isGroupResultNull = true;
    max = Double.MIN_VALUE;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.ClinicalPlot.java

/**
 * Get the range of values for a given clinical factor
 * @param dataPoints/*from   ww  w.j a v a 2  s.c o m*/
 * @param factor
 * @return
 */
private DataRange getDataRange(Collection<ClinicalDataPoint> dataPoints2,
        gov.nih.nci.caintegrator.enumeration.ClinicalFactorType factor, boolean onlyIncludePositveValues) {
    double maxValue = Double.MIN_VALUE;
    double minValue = Double.MAX_VALUE;
    double value;
    ClinicalDataPoint dataPoint;
    for (Iterator i = dataPoints.iterator(); i.hasNext();) {
        dataPoint = (ClinicalDataPoint) i.next();
        value = dataPoint.getFactorValue(factor);
        if ((value < minValue) && (value >= 0)) {
            minValue = value;
        }

        if ((value > maxValue) && (value >= 0)) {
            maxValue = value;
        }
    }

    DataRange range = new DataRange(minValue, maxValue);
    return range;
}

From source file:com.mobicage.rogerthat.FriendsLocationActivity.java

private void displayLocations() {
    T.UI();/*from w w  w. ja  v  a2s  .c o  m*/
    mLoadingProgressbar.setVisibility(View.GONE);
    mLoadingLayout.setVisibility(View.GONE);
    mFriendMap.setVisibility(View.VISIBLE);
    // Calculate bounds
    double maxLat = Double.MIN_VALUE;
    double minLat = Double.MAX_VALUE;
    double maxLon = Double.MIN_VALUE;
    double minLon = Double.MAX_VALUE;
    for (LocationResultRequestTO fl : mLocations) {
        if (fl.location.latitude > maxLat)
            maxLat = fl.location.latitude;
        if (fl.location.latitude < minLat)
            minLat = fl.location.latitude;
        if (fl.location.longitude > maxLon)
            maxLon = fl.location.longitude;
        if (fl.location.longitude < minLon)
            minLon = fl.location.longitude;
    }
    mFriendMap.getController().zoomToSpan((int) ((maxLat - minLat)), (int) ((maxLon - minLon)));
    GeoPoint center = new GeoPoint((int) ((maxLat + minLat) / 2), (int) ((maxLon + minLon) / 2));
    mFriendMap.getController().setCenter(center);
    for (LocationResultRequestTO fl : mLocations) {
        if (mAdded.contains(fl.friend))
            continue;
        mAdded.add(fl.friend);

        if (fl.friend.equals(mMyIdentity.getEmail())) {
            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(mMyIdentity), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, mMyIdentity.getName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        } else {
            Friend friend = mFriendsPlugin.getStore().getExistingFriend(fl.friend);

            DrawableItemizedOverlay overlay = new DrawableItemizedOverlay(getAvatar(friend), this);
            GeoPoint point = new GeoPoint((int) (fl.location.latitude), (int) (fl.location.longitude));
            Date date = new Date(fl.location.timestamp * 1000);
            OverlayItem overlayitem = new OverlayItem(point, friend.getDisplayName(),
                    getString(R.string.friend_map_marker,
                            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(date),
                            fl.location.accuracy));
            overlay.addOverlay(overlayitem);
            mFriendMap.getOverlays().add(overlay);
        }
    }
    if (mAdded.size() == 1 && mAdded.get(0).equals(mMyIdentity.getEmail()))
        UIUtils.showLongToast(this,
                getString(R.string.your_location_displayed_friend_have_contacted_for_their_location));
}

From source file:ffx.numerics.fft.Real3DCuda.java

/**
 * <p>/* w  w  w.  j av  a 2 s  .c  om*/
 * main</p>
 *
 * @param args an array of {@link java.lang.String} objects.
 * @throws java.lang.Exception if any.
 */
public static void main(String[] args) throws Exception {
    int dimNotFinal = 64;
    int reps = 10;
    if (args != null) {
        try {
            dimNotFinal = Integer.parseInt(args[0]);
            if (dimNotFinal < 1) {
                dimNotFinal = 64;
            }
            reps = Integer.parseInt(args[1]);
            if (reps < 1) {
                reps = 5;
            }
        } catch (Exception e) {
        }
    }
    if (dimNotFinal % 2 != 0) {
        dimNotFinal++;
    }
    final int dim = dimNotFinal;
    System.out.println(String.format(
            "Initializing a %d cubed grid.\n" + "The best timing out of %d repititions will be used.", dim,
            reps));

    final int dimCubed = dim * dim * dim;
    final int dimCubed2 = (dim + 2) * dim * dim;

    /**
     * Create an array to save the initial input and result.
     */
    final double orig[] = new double[dimCubed2];
    final double answer[] = new double[dimCubed2];
    final double data[] = new double[dimCubed2];
    final double recip[] = new double[dimCubed];

    final float origf[] = new float[dimCubed2];
    final float dataf[] = new float[dimCubed2];
    final float recipf[] = new float[dimCubed];

    Random randomNumberGenerator = new Random(1);
    int index = 0;
    int index2 = 0;

    /**
     * Row-major order.
     */
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                float randomNumber = randomNumberGenerator.nextFloat();
                orig[index] = randomNumber;
                origf[index] = randomNumber;
                index++;

                recip[index2] = 1.0;
                recipf[index2] = 1.0f;
                index2++;
            }
            // Padding
            index += 2;
        }
    }

    Real3D real3D = new Real3D(dim, dim, dim);
    Real3DParallel real3DParallel = new Real3DParallel(dim, dim, dim, new ParallelTeam(),
            IntegerSchedule.fixed());
    Real3DCuda real3DCUDA = new Real3DCuda(dim, dim, dim, dataf, recipf);

    Thread cudaThread = new Thread(real3DCUDA);
    cudaThread.setPriority(Thread.MAX_PRIORITY);
    cudaThread.start();

    double toSeconds = 0.000000001;
    long parTime = Long.MAX_VALUE;
    long seqTime = Long.MAX_VALUE;
    long clTime = Long.MAX_VALUE;

    real3D.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        System.arraycopy(orig, 0, data, 0, dimCubed2);
        long time = System.nanoTime();
        real3D.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d Sequential: %8.3f", i + 1, toSeconds * time));
        if (time < seqTime) {
            seqTime = time;
        }
    }
    System.arraycopy(data, 0, answer, 0, dimCubed2);

    real3DParallel.setRecip(recip);
    for (int i = 0; i < reps; i++) {
        System.arraycopy(orig, 0, data, 0, dimCubed2);
        long time = System.nanoTime();
        real3DParallel.convolution(data);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d Parallel:   %8.3f", i + 1, toSeconds * time));
        if (time < parTime) {
            parTime = time;
        }
    }
    double maxError = Double.MIN_VALUE;
    double rmse = 0.0;
    index = 0;
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                double error = Math.abs((orig[index] - data[index] / dimCubed));
                if (error > maxError) {
                    maxError = error;
                }
                rmse += error * error;
                index++;
            }
            index += 2;
        }
    }
    rmse /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format("Parallel RMSE:   %12.10f, Max: %12.10f", rmse, maxError));

    for (int i = 0; i < reps; i++) {
        System.arraycopy(origf, 0, dataf, 0, dimCubed2);
        long time = System.nanoTime();
        real3DCUDA.convolution(dataf);
        time = (System.nanoTime() - time);
        System.out.println(String.format("%2d CUDA:     %8.3f", i + 1, toSeconds * time));
        if (time < clTime) {
            clTime = time;
        }
    }
    real3DCUDA.free();
    real3DCUDA = null;

    maxError = Double.MIN_VALUE;
    double avg = 0.0;
    rmse = 0.0;
    index = 0;
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
            for (int z = 0; z < dim; z++) {
                if (Float.isNaN(dataf[index])) {
                    logger.info(String.format("Not a number %d %d %d", x, y, z));
                    System.exit(-1);
                }
                double error = Math.abs(origf[index] - dataf[index]);
                avg += error;
                if (error > maxError) {
                    maxError = error;
                }
                rmse += error * error;
                index++;
            }
            index += 2;
        }
    }
    rmse /= dimCubed;
    avg /= dimCubed;
    rmse = Math.sqrt(rmse);
    logger.info(String.format("CUDA RMSE:   %12.10f, Max: %12.10f, Avg: %12.10f", rmse, maxError, avg));

    System.out.println(String.format("Best Sequential Time:  %8.3f", toSeconds * seqTime));
    System.out.println(String.format("Best Parallel Time:    %8.3f", toSeconds * parTime));
    System.out.println(String.format("Best CUDA Time:        %8.3f", toSeconds * clTime));
    System.out.println(String.format("Parallel Speedup: %15.5f", (double) seqTime / parTime));
    System.out.println(String.format("CUDA Speedup:     %15.5f", (double) seqTime / clTime));
}

From source file:uk.ac.babraham.BamQC.Modules.ChromosomeReadDensity.java

@Deprecated
public JPanel getOldResultsPanel() {

    String title = "Chromosome Read Density";
    String[] xCategories;//from w  w  w.ja  va 2s . co m
    String xLabel = "Log Chromosome Length";
    String yLabel = "Log Read Number";
    double maxY = Double.MIN_VALUE, minY = Double.MAX_VALUE;

    if (readNumber.length < 1) {
        xCategories = new String[] { "Null" };
        //          Previously this was a bar graph
        //         return new BarGraph(new double[1], 0d, maxY, xLabel, yLabel, xCategories, title);
        return new CompactScatterGraph(new double[1], 0d, maxY, xLabel, yLabel, xCategories, title);
    }

    xCategories = new String[chromosomeLength.length];

    for (int i = 0; i < readNumber.length; i++) {
        if (maxY < readNumber[i]) {
            maxY = readNumber[i];
        } else if (minY > readNumber[i]) {
            minY = readNumber[i];
        }
        //System.out.println(chromosomeLength[i] + " " + readNumber[i]);
    }

    // temporarily replaced with 0
    minY = 0;

    for (int i = 0; i < chromosomeLength.length; i++) {
        xCategories[i] = String.valueOf(chromosomeLength[i]);
    }
    // Previously this was a bar graph
    //return new BarGraph(readNumber, minY, maxY, xLabel, yLabel, xCategories, title);
    // This just plots the data as it is, without empty non-represented points.
    return new CompactScatterGraph(readNumber, minY, maxY + maxY * 0.1, xLabel, yLabel, xCategories, title);
}

From source file:org.yccheok.jstock.charting.Utils.java

/**
 * Returns daily chart data based on given stock history server.
 *
 * @param stockHistoryServer the stock history server
 * @return list of daily chart data// w w w  . j  a  va  2 s  . c o  m
 */
public static List<ChartData> getDailyChartData(StockHistoryServer stockHistoryServer) {
    final int days = stockHistoryServer.size();

    List<ChartData> chartDatas = new ArrayList<ChartData>();

    double prevPrice = 0;
    double openPrice = 0;
    double lastPrice = 0;
    double highPrice = Double.MIN_VALUE;
    double lowPrice = Double.MAX_VALUE;
    long volume = 0;
    long timestamp = 0;

    // Just perform simple one to one copy, without performing any
    // filtering.
    for (int i = 0; i < days; i++) {
        final long t = stockHistoryServer.getTimestamp(i);
        Stock stock = stockHistoryServer.getStock(t);
        prevPrice = stock.getPrevPrice();
        openPrice = stock.getOpenPrice();
        lastPrice = stock.getLastPrice();
        highPrice = stock.getHighPrice();
        lowPrice = stock.getLowPrice();
        volume = stock.getVolume();
        timestamp = stock.getTimestamp();
        ChartData chartData = ChartData.newInstance(prevPrice, openPrice, lastPrice, highPrice, lowPrice,
                volume, timestamp);
        chartDatas.add(chartData);
    }
    return chartDatas;
}

From source file:gedi.util.math.stat.distributions.NormalMixtureDistribution.java

public static NormalMixtureDistribution fit(NormalMixtureDistribution initialMixture, double[] data,
        final int maxIterations, final double threshold) {

    if (maxIterations < 1) {
        throw new NotStrictlyPositiveException(maxIterations);
    }/* ww  w.j  a  v  a2s  .co  m*/

    if (threshold < Double.MIN_VALUE) {
        throw new NotStrictlyPositiveException(threshold);
    }

    final int n = data.length;

    final int k = initialMixture.getNumComponents();

    if (k == 1)
        return new NormalMixtureDistribution(new NormalDistribution[] {
                new NormalDistribution(new Mean().evaluate(data), new StandardDeviation().evaluate(data)) },
                new double[] { 1 });

    int numIterations = 0;
    double previousLogLikelihood = 0d;

    double logLikelihood = Double.NEGATIVE_INFINITY;

    // Initialize model to fit to initial mixture.
    NormalMixtureDistribution fittedModel = new NormalMixtureDistribution(initialMixture.components,
            initialMixture.mixing);

    while (numIterations++ <= maxIterations
            && FastMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
        previousLogLikelihood = logLikelihood;
        logLikelihood = 0d;

        // E-step: compute the data dependent parameters of the expectation
        // function.
        // The percentage of row's total density between a row and a
        // component
        final double[][] gamma = new double[n][k];
        // Sum of gamma for each component
        final double[] gammaSums = new double[k];

        for (int i = 0; i < n; i++) {
            final double rowDensity = fittedModel.density(data[i]);
            logLikelihood += FastMath.log(rowDensity);

            for (int j = 0; j < k; j++) {
                gamma[i][j] = fittedModel.mixing[j] * fittedModel.components[j].density(data[i]) / rowDensity;
                gammaSums[j] += gamma[i][j];
            }
        }
        logLikelihood /= n;
        //         System.out.println(logLikelihood);

        // M-step: compute the new parameters based on the expectation
        // function.
        final double[] newWeights = gammaSums.clone();
        ArrayUtils.mult(newWeights, 1.0 / n);

        NormalDistribution[] comp = new NormalDistribution[k];
        for (int j = 0; j < k; j++) {
            double m = 0;
            for (int i = 0; i < n; i++) {
                m += gamma[i][j] * data[i];
            }
            m /= gammaSums[j];

            double var = 0;
            for (int i = 0; i < n; i++) {
                double d = m - data[i];
                var += gamma[i][j] * d * d;
            }
            var /= gammaSums[j];

            comp[j] = new NormalDistribution(m, Math.sqrt(var));
        }

        // Update current model
        fittedModel = new NormalMixtureDistribution(comp, newWeights);
    }

    if (FastMath.abs(previousLogLikelihood - logLikelihood) > threshold) {
        // Did not converge before the maximum number of iterations
        throw new ConvergenceException();
    }

    return fittedModel;
}

From source file:com.yoctopuce.YoctoAPI.YDataSet.java

protected int _parse(String json_str) throws YAPI_Exception {
    JSONObject json;//from  w ww. jav  a2 s  .  co m
    JSONArray jstreams;
    double summaryMinVal = Double.MAX_VALUE;
    double summaryMaxVal = Double.MIN_VALUE;
    double summaryTotalTime = 0;
    double summaryTotalAvg = 0;
    long streamStartTime;
    long streamEndTime;
    long startTime = 0x7fffffff;
    long endTime = 0;

    try {
        json = new JSONObject(json_str);
        _functionId = json.getString("id");
        _unit = json.getString("unit");
        if (json.has("calib")) {
            _calib = YAPI._decodeFloats(json.getString("calib"));
            _calib.set(0, _calib.get(0) / 1000);
        } else {
            _calib = YAPI._decodeWords(json.getString("cal"));
        }
        _streams = new ArrayList<YDataStream>();
        _preview = new ArrayList<YMeasure>();
        _measures = new ArrayList<YMeasure>();
        jstreams = json.getJSONArray("streams");
        for (int i = 0; i < jstreams.length(); i++) {
            YDataStream stream = _parent._findDataStream(this, jstreams.getString(i));
            streamStartTime = stream.get_startTimeUTC() - stream.get_dataSamplesIntervalMs() / 1000;
            streamEndTime = stream.get_startTimeUTC() + stream.get_duration();
            if (_startTime > 0 && streamEndTime <= _startTime) {
                // this stream is too early, drop it
            } else if (_endTime > 0 && stream.get_startTimeUTC() > _endTime) {
                // this stream is too late, drop it
            } else {
                _streams.add(stream);
                if (startTime > streamStartTime) {
                    startTime = streamStartTime;
                }
                if (endTime < streamEndTime) {
                    endTime = streamEndTime;
                }

                if (stream.isClosed() && stream.get_startTimeUTC() >= _startTime
                        && (_endTime == 0 || streamEndTime <= _endTime)) {
                    if (summaryMinVal > stream.get_minValue())
                        summaryMinVal = stream.get_minValue();
                    if (summaryMaxVal < stream.get_maxValue())
                        summaryMaxVal = stream.get_maxValue();
                    summaryTotalAvg += stream.get_averageValue() * stream.get_duration();
                    summaryTotalTime += stream.get_duration();

                    YMeasure rec = new YMeasure(stream.get_startTimeUTC(), streamEndTime, stream.get_minValue(),
                            stream.get_averageValue(), stream.get_maxValue());
                    _preview.add(rec);
                }
            }
        }
        if ((_streams.size() > 0) && (summaryTotalTime > 0)) {
            // update time boundaries with actual data
            if (_startTime < startTime) {
                _startTime = startTime;
            }
            if (_endTime == 0 || _endTime > endTime) {
                _endTime = endTime;
            }
            _summary = new YMeasure(_startTime, _endTime, summaryMinVal, summaryTotalAvg / summaryTotalTime,
                    summaryMaxVal);
        }
    } catch (JSONException e) {
        throw new YAPI_Exception(YAPI.IO_ERROR, "invalid json structure for YDataSet: " + e.getMessage());
    }
    _progress = 0;
    return this.get_progress();
}

From source file:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java

/**
 * Get a value based on the DBR type. /*from   w w  w  .  j a v  a2s .c o  m*/
 * We should check for boundary conditions here and make sure PB does not throw exceptions when we come close to MIN_ and MAX_ values 
 * @param type
 * @param secondsIntoYear
 * @return
 */
public SampleValue getSampleValue(ArchDBRTypes type, int secondsIntoYear) {
    switch (type) {
    case DBR_SCALAR_STRING:
        return new ScalarStringSampleValue(Integer.toString(secondsIntoYear));
    case DBR_SCALAR_SHORT:
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            return new ScalarValue<Short>((short) (Short.MIN_VALUE + secondsIntoYear));
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            return new ScalarValue<Short>((short) (Short.MAX_VALUE - (secondsIntoYear - 1000)));
        } else {
            // Check for some numbers around 0
            return new ScalarValue<Short>((short) (secondsIntoYear - 2000));
        }
    case DBR_SCALAR_FLOAT:
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            return new ScalarValue<Float>(Float.MIN_VALUE + secondsIntoYear);
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            return new ScalarValue<Float>(Float.MAX_VALUE - (secondsIntoYear - 1000));
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            return new ScalarValue<Float>((secondsIntoYear - 2000.0f) / secondsIntoYear);
        }
    case DBR_SCALAR_ENUM:
        return new ScalarValue<Short>((short) secondsIntoYear);
    case DBR_SCALAR_BYTE:
        return new ScalarValue<Byte>(((byte) (secondsIntoYear % 255)));
    case DBR_SCALAR_INT:
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            return new ScalarValue<Integer>(Integer.MIN_VALUE + secondsIntoYear);
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            return new ScalarValue<Integer>(Integer.MAX_VALUE - (secondsIntoYear - 1000));
        } else {
            // Check for some numbers around 0
            return new ScalarValue<Integer>(secondsIntoYear - 2000);
        }
    case DBR_SCALAR_DOUBLE:
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            return new ScalarValue<Double>(Double.MIN_VALUE + secondsIntoYear);
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            return new ScalarValue<Double>(Double.MAX_VALUE - (secondsIntoYear - 1000));
        } else {
            // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits
            return new ScalarValue<Double>((secondsIntoYear - 2000.0) / (secondsIntoYear * 1000000));
        }
    case DBR_WAVEFORM_STRING:
        // Varying number of copies of a typical value
        return new VectorStringSampleValue(
                Collections.nCopies(secondsIntoYear, Integer.toString(secondsIntoYear)));
    case DBR_WAVEFORM_SHORT:
        return new VectorValue<Short>(Collections.nCopies(1, (short) secondsIntoYear));
    case DBR_WAVEFORM_FLOAT:
        // Varying number of copies of a typical value
        return new VectorValue<Float>(
                Collections.nCopies(secondsIntoYear, (float) Math.cos(secondsIntoYear * Math.PI / 3600)));
    case DBR_WAVEFORM_ENUM:
        return new VectorValue<Short>(Collections.nCopies(1024, (short) secondsIntoYear));
    case DBR_WAVEFORM_BYTE:
        // Large number of elements in the array
        return new VectorValue<Byte>(
                Collections.nCopies(65536 * secondsIntoYear, ((byte) (secondsIntoYear % 255))));
    case DBR_WAVEFORM_INT:
        // Varying number of copies of a typical value
        return new VectorValue<Integer>(
                Collections.nCopies(secondsIntoYear, secondsIntoYear * secondsIntoYear));
    case DBR_WAVEFORM_DOUBLE:
        // Varying number of copies of a typical value
        return new VectorValue<Double>(
                Collections.nCopies(secondsIntoYear, Math.sin(secondsIntoYear * Math.PI / 3600)));
    case DBR_V4_GENERIC_BYTES:
        // Varying number of copies of a typical value
        ByteBuffer buf = ByteBuffer.allocate(1024 * 10);
        buf.put(Integer.toString(secondsIntoYear).getBytes());
        buf.flip();
        return new ByteBufSampleValue(buf);
    default:
        throw new RuntimeException("We seemed to have missed a DBR type when generating sample data");
    }
}