/** @param args */ public static void main(String[] args) throws Exception { File file = new File("input.txt"); if (file.exists()) { System.setIn(new BufferedInputStream(new FileInputStream("input.txt"))); } out = System.out; bw = new BufferedWriter(new PrintWriter(out)); // sc = new Scanner(System.in); br = new BufferedReader(new InputStreamReader(System.in)); C231 t = new C231(); t.solve(); bw.close(); }
public static void main(String[] args) { double[] sigma = {3E-4, 1E-6, 2.4E-2, 6.67E-5, 1E-6, 6E-3, 4.4E-4, 1E-2, 1E-6}; double[] mu = {0.42E9, 2.27}; double alpha = 0.0; Sampler sampler = new Sampler(mu, sigma, alpha); double[][] M = sampler.getCovMat(); System.out.println("The Covirance Matrix is:"); sampler.printMatrix(M); double[][] A = sampler.getCholDecompA(); System.out.println("The decomposed Matrix A is"); sampler.printMatrix(A); try { File file = new File("/Users/Weizheng/Documents/JavaWorkPlace/CLS_MCIntegrator/output.txt"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } else { file.delete(); file.createNewFile(); } PrintWriter fw = new PrintWriter(file); long startTime = System.currentTimeMillis(); for (int i = 0; i < 1E3; i++) { double[] MultiNormalVector = sampler.nextMultiNormalVector(); // for(double a:MultiNormalVector ){ // fw.printf("%4.2e ", a); // } // fw.println(""); } fw.close(); long endTime = System.currentTimeMillis(); System.out.println("That took " + (endTime - startTime) + " milliseconds"); } catch (IOException e) { e.printStackTrace(); } }
private void browseAction() { if (selectedPath == null) { selectedPath = System.getenv("ROPE_SOURCES_DIR"); if (selectedPath != null) { File dir = new File(selectedPath); if (!dir.exists() || !dir.isDirectory()) { String message = String.format( "The sources path set in environment variable ROPE_SOURCES_DIR is not avaliable.\n%s", selectedPath); JOptionPane.showMessageDialog(null, message, "ROPE", JOptionPane.WARNING_MESSAGE); selectedPath = null; } else { System.out.println("Source folder path set from ROPE_SOURCES_DIR: " + selectedPath); } } if (selectedPath == null) { selectedPath = System.getProperty("user.dir"); System.out.println("Source folder path set to current directory: " + selectedPath); } } Vector<RopeFileFilter> filters = new Vector<RopeFileFilter>(); filters.add( new RopeFileFilter( new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)")); filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)")); filters.add(new RopeFileFilter(new String[] {".lst"}, "List files (*.lst)")); filters.add(new RopeFileFilter(new String[] {".txt"}, "Text files (*.txt)")); RopeFileChooser chooser = new RopeFileChooser(selectedPath, null, filters); chooser.setDialogTitle("Source document selection"); chooser.setFileFilter(filters.firstElement()); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); File file = chooser.open(this, fileText); if (file != null) { if (loadSourceFile(file)) { mainFrame.showExecWindow(baseName); } } }
/** @param args */ public static void main(String[] args) throws Exception { File file = new File("B-small-practice.in"); if (file.exists()) { System.setIn(new BufferedInputStream(new FileInputStream(file))); } sc = new Scanner(System.in); FileWriter fw = new FileWriter(new File("output.txt")); out = new PrintWriter(fw); Bsmall b = new Bsmall(); int T = sc.nextInt(); int t = 1; while (t <= T) { out.print("Case #" + t + ": "); b.solve(); t++; } out.close(); fw.close(); }
/** @param args */ public static void main(String[] args) throws Exception { out = System.out; File file = new File("input.txt"); if (file.exists()) { System.setIn(new BufferedInputStream(new FileInputStream("input.txt"))); } sc = new Scanner(System.in); POJ3109 p = new POJ3109(); while (true) { try { N = sc.nextInt(); if (N == 0) { break; } } catch (Exception ex) { break; } p.solve(); } }
public boolean loadSourceFile(File file) { boolean result = false; selectedPath = file.getParent(); BufferedReader sourceFile = null; String directoryPath = file.getParent(); String sourceName = file.getName(); int idx = sourceName.lastIndexOf("."); fileExt = idx == -1 ? "" : sourceName.substring(idx + 1); baseName = idx == -1 ? sourceName.substring(0) : sourceName.substring(0, idx); String basePath = directoryPath + File.separator + baseName; DataOptions.directoryPath = directoryPath; sourcePath = file.getPath(); AssemblerOptions.sourcePath = sourcePath; AssemblerOptions.listingPath = basePath + ".lst"; AssemblerOptions.objectPath = basePath + ".cd"; String var = System.getenv("ROPE_MACROS_DIR"); if (var != null && !var.isEmpty()) { File dir = new File(var); if (dir.exists() && dir.isDirectory()) { AssemblerOptions.macroPath = var; } else { AssemblerOptions.macroPath = directoryPath; } } else { AssemblerOptions.macroPath = directoryPath; } DataOptions.inputPath = AssemblerOptions.objectPath; DataOptions.outputPath = basePath + ".out"; DataOptions.readerPath = null; DataOptions.punchPath = basePath + ".pch"; DataOptions.tape1Path = basePath + ".mt1"; DataOptions.tape2Path = basePath + ".mt2"; DataOptions.tape3Path = basePath + ".mt3"; DataOptions.tape4Path = basePath + ".mt4"; DataOptions.tape5Path = basePath + ".mt5"; DataOptions.tape6Path = basePath + ".mt6"; this.setTitle("EDIT: " + sourceName); fileText.setText(sourcePath); if (dialog == null) { dialog = new AssemblerDialog(mainFrame, "Assembler options"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension dialogSize = dialog.getSize(); dialog.setLocation( (screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2); } dialog.initialize(); AssemblerOptions.command = dialog.buildCommand(); sourceArea.setText(null); try { sourceFile = new BufferedReader(new FileReader(file)); String line; while ((line = sourceFile.readLine()) != null) { sourceArea.append(line + "\n"); } sourceArea.setCaretPosition(0); optionsButton.setEnabled(true); assembleButton.setEnabled(true); saveButton.setEnabled(true); setSourceChanged(false); undoMgr.discardAllEdits(); result = true; } catch (IOException ex) { ex.printStackTrace(); } finally { try { if (sourceFile != null) { sourceFile.close(); } } catch (IOException ignore) { } } return result; }