Example usage for org.apache.commons.math.util DoubleArray getNumElements

List of usage examples for org.apache.commons.math.util DoubleArray getNumElements

Introduction

In this page you can find the example usage for org.apache.commons.math.util DoubleArray getNumElements.

Prototype

int getNumElements();

Source Link

Document

Returns the number of elements currently in the array.

Usage

From source file:es.udc.gii.common.eaf.algorithm.population.Individual.java

/**
 * Returns the dimension of this individual as the sum of the dimensions of all its chromosomes.
 * @return the dimension of this individual.
 *//*  w ww.jav  a2  s. c  o  m*/
public int getDimension() {

    int dimension = 0;

    for (DoubleArray d : this.chromosomes) {
        dimension += d.getNumElements();
    }

    return dimension;

}

From source file:es.udc.gii.common.eaf.algorithm.population.Individual.java

private boolean checkChromosomes(DoubleArray[] c_1, DoubleArray[] c_2) {

    DoubleArray d_1, d_2;

    if (c_1.length != c_2.length) {
        return false;
    }/* w  ww . j a  v a  2s  .  c o  m*/

    for (int i = 0; i < c_1.length; i++) {

        d_1 = c_1[i];
        d_2 = c_2[i];

        if (d_1.getNumElements() != d_2.getNumElements()) {
            return false;
        }

        if (!Arrays.equals(d_1.getElements(), d_2.getElements())) {
            return false;
        }

    }

    return true;
}