src/Joli/JoliCi/Matrix.php
public function compute()
    {
        $dimensions = $this->dimensions;

        if (empty($dimensions)) {
            return array();
        }

        // Pop first dimension
        $values = reset($dimensions);
        $name   = key($dimensions);
        unset($dimensions[$name]);

        // Create all possiblites for the first dimension
        $posibilities = array();

        foreach ($values as $v) {
            $posibilities[] = array($name => $v);
        }

        // If only one dimension return simple all the possibilites created (break point of recursivity)
        if (empty($dimensions)) {
            return $posibilities;
        }

        // If not create a new matrix with remaining dimension
        $matrix = new Matrix();

        foreach ($dimensions as $name => $values) {
            $matrix->setDimension($name, $values);
        }

        $result    = $matrix->compute();
        $newResult = array();

        foreach ($result as $value) {
            foreach ($posibilities as $possiblity) {
                $newResult[] = $value + $possiblity;
            }
        }

        return $newResult;
    }
public function compute()
    {
        $dimensions = $this->dimensions;

        if (empty($dimensions)) {
            return array();
        }

        // Pop first dimension
        $values = reset($dimensions);
        $name   = key($dimensions);
        unset($dimensions[$name]);

        // Create all possiblites for the first dimension
        $posibilities = array();

        foreach ($values as $v) {
            $posibilities[] = array($name => $v);
        }

        // If only one dimension return simple all the possibilites created (break point of recursivity)
        if (empty($dimensions)) {
            return $posibilities;
        }

        // If not create a new matrix with remaining dimension
        $matrix = new Matrix();

        foreach ($dimensions as $name => $values) {
            $matrix->setDimension($name, $values);
        }

        $result    = $matrix->compute();
        $newResult = array();

        foreach ($result as $value) {
            foreach ($posibilities as $possiblity) {
                $newResult[] = $value + $possiblity;
            }
        }

        return $newResult;
    }
Return all possibility for the matrix

@return array