/** * Returns an double array containing all of the elements in this chromosome * in proper sequence. * * @since 3.0 * * @return an array containing the elements of this chromosome */ public double[] toArray() { return toArray(new double[length()]); }
/** * Return a vector {@code Codec} for the given range. All vector values * are restricted by the same domain. * * @param domain the domain of the vector values * @param length the vector length * @return a new vector {@code Codec} * @throws NullPointerException if the given {@code domain} is {@code null} * @throws IllegalArgumentException if the {@code length} is smaller than * one. */ public static Codec<double[], DoubleGene> ofVector( final DoubleRange domain, final int length ) { requireNonNull(domain); require.positive(length); return Codec.of( Genotype.of(DoubleChromosome.of(domain, length)), gt -> gt.getChromosome().as(DoubleChromosome.class).toArray() ); }