List of usage examples for java.util Arrays fill
public static void fill(Object[] a, Object val)
From source file:de.tuberlin.uebb.jdae.solvers.OptimalitySolver.java
public double[] solve(int maxEval, MultivariateVectorFunction residual, MultivariateMatrixFunction jacobian, double[] startValue) { final double[] zeros = startValue.clone(); final double[] ones = startValue.clone(); Arrays.fill(zeros, 0.0); Arrays.fill(ones, 1.0);//from w w w . j av a 2s. c om return optim.optimize(new MaxEval(maxEval), new InitialGuess(startValue), new Target(zeros), new Weight(ones), new ModelFunction(residual), new ModelFunctionJacobian(jacobian)).getPoint(); }
From source file:com.milaboratory.core.io.sequence.fasta.FastaReaderTest.java
private static TestItem createTestData(long seed, int readsCount, boolean withWildcards) throws IOException { Well1024a rnd = new Well1024a(seed); File tempFile = File.createTempFile("temp" + seed, ".fasta"); tempFile.deleteOnExit();// w ww. j a v a 2 s .c o m FileOutputStream output = new FileOutputStream(tempFile); SingleRead[] reads = new SingleRead[readsCount]; WildcardSymbol[] wildcards = NucleotideSequence.ALPHABET.getAllWildcards().toArray(new WildcardSymbol[0]); long id = 0; for (int i = 0; i < readsCount; ++i) { char[] seq = new char[50 + rnd.nextInt(100)]; char[] seqExp = new char[seq.length]; int qPointer = 0; byte[] qualityData = new byte[seq.length]; Arrays.fill(qualityData, SequenceQuality.GOOD_QUALITY_VALUE); for (int j = 0; j < seq.length; ++j) { seq[j] = seqExp[j] = NucleotideSequence.ALPHABET.symbolFromCode((byte) rnd.nextInt(4)); if (j != 0 && j != seq.length - 1 && ((4 * j) % seq.length == 0) && rnd.nextBoolean()) { //next line for sequence seq[j] = seqExp[j] = '\n'; --qPointer; } else if (withWildcards && j % 5 == 0) {//wildcard WildcardSymbol wildcard = wildcards[rnd.nextInt(wildcards.length)]; if (NucleotideSequence.ALPHABET.codeFromSymbol(wildcard.getSymbol()) == -1) { seq[j] = wildcard.getSymbol(); seqExp[j] = NucleotideSequence.ALPHABET .symbolFromCode(wildcard.getUniformlyDistributedSymbol(id ^ (j + qPointer)));//as used in FastaReader#getSequenceWithQuality(..) qualityData[j + qPointer] = SequenceQuality.BAD_QUALITY_VALUE; } } } String description = ">seq" + i; String sequenceString = new String(seq); output.write(description.getBytes()); output.write('\n'); output.write(sequenceString.getBytes()); output.write('\n'); reads[i] = new SingleReadImpl(id, new NSequenceWithQuality(new NucleotideSequence(new String(seqExp).replace("\n", "")), new SequenceQuality(Arrays.copyOfRange(qualityData, 0, seq.length + qPointer))), description.substring(1)); ++id; } output.close(); return new TestItem(tempFile, reads); }
From source file:com.blockwithme.hacktors.Chunk.java
/** Creates an empty Chunk. */ public Chunk() { Arrays.fill(blocks, Block.EMPTY); Arrays.fill(items, Item.EMPTY); }
From source file:com.gc.iotools.stream.os.TeeOutputStream.java
/** * <p>/*from w ww . j a va2 s . c om*/ * Creates a <code>TeeOutputStream</code> and saves its arguments, the * <code>destinations</code> for later use. * </p> * <p> * This constructor allow to specify multiple <code>OutputStream</code> to * which the data will be copied. * </p> * * @since 1.2.4 * @param destinations * Data written to this <code>OutputStream</code> are copied to * all the <code>destinations</code>. */ public TeeOutputStream(final OutputStream... destinations) { checkDestinations(destinations); this.writeTime = new long[destinations.length]; this.destinations = destinations; this.copyEnabled = new boolean[destinations.length]; Arrays.fill(this.copyEnabled, true); }
From source file:io.stallion.dataAccess.BeanListHandler.java
private String[] makeColumnToProperty(ResultSetMetaData rsmd, List<String> propertyNames) throws SQLException { int cols = rsmd.getColumnCount(); String[] columnToProperty = new String[cols + 1]; Arrays.fill(columnToProperty, ""); for (int col = 1; col <= cols; ++col) { String columnName = rsmd.getColumnLabel(col); if (null == columnName || 0 == columnName.length()) { columnName = rsmd.getColumnName(col); }/*from ww w . j av a 2 s . c o m*/ for (int i = 0; i < propertyNames.size(); ++i) { String propertyName = propertyNames.get(i); if (propertyName.equalsIgnoreCase(columnName)) { columnToProperty[col] = propertyName; break; } } } return columnToProperty; }
From source file:net.myrrix.common.collection.FastIDSet.java
public FastIDSet(int size) { Preconditions.checkArgument(size >= 0, "size must be at least 0"); Preconditions.checkArgument(size < MAX_SIZE, "size must be less than %d", MAX_SIZE); int hashSize = RandomUtils.nextTwinPrime((int) (DEFAULT_LOAD_FACTOR * size) + 1); keys = new long[hashSize]; Arrays.fill(keys, NULL); }
From source file:com.lightboxtechnologies.spectrum.FsEntryUtilsTest.java
@Test public void nextFsEntryKeyTestLast() { final byte[] expected = new byte[36]; final byte[] key = new byte[36]; Arrays.fill(key, (byte) 0xFF); assertArrayEquals(expected, nextFsEntryKey(key)); }
From source file:com.owncloud.android.lib.common.network.RedirectionPath.java
/** * Public constructor.//from www . ja va 2 s. c om * * @param status Status code resulting of executing a request on the original URL. * @param maxRedirections Maximum number of redirections that will be contained. * @throws IllegalArgumentException If 'maxRedirections' is < 0 */ public RedirectionPath(int status, int maxRedirections) { if (maxRedirections < 0) { throw new IllegalArgumentException("maxRedirections MUST BE zero or greater"); } mStatuses = new int[maxRedirections + 1]; Arrays.fill(mStatuses, -1); mStatuses[++mLastStatus] = status; }
From source file:craterdog.security.MessageCryptex.java
@Override public void encryptStream(SecretKey sharedKey, InputStream input, OutputStream output) throws IOException { logger.entry();//from w ww. j a v a2s. c o m CipherOutputStream cipherOutput = null; byte[] buffer = new byte[2048]; try { logger.debug("Creating a special output stream to do the work..."); cipherOutput = encryptionOutputStream(sharedKey, output); logger.debug("Reading from the input and writing to the encrypting output stream..."); // Can't use IOUtils.copy(input, cipherOutput) here because need to purge buffer later... int bytesRead; while ((bytesRead = input.read(buffer)) != -1) { cipherOutput.write(buffer, 0, bytesRead); } cipherOutput.flush(); } finally { logger.debug("Purging any plaintext hanging around in memory..."); Arrays.fill(buffer, (byte) 0); if (cipherOutput != null) cipherOutput.close(); } logger.exit(); }
From source file:juicebox.tools.utils.common.ArrayTools.java
public static float[] newValueInitializedFloatArray(int n, float val) { float[] array = new float[n]; Arrays.fill(array, val); return array; }