Build a matrix by stacking an array of vectors.

@param \Rubix\Tensor\Vector[] $vectors
@throws \InvalidArgumentException
@return self
176966
public static function stack(array $vectors) : self
    {
        $a = [];

        foreach ($vectors as $vector) {
            if (!$vector instanceof Vector) {
                throw new InvalidArgumentException('Cannot stack a non'
                    . ' vector, ' . gettype($vector) . ' found.');
            }

            $a[] = $vector->asArray();
        }

        return self::quick($a);
    }
257487
public function addVariables($variables)
    {
        if ($variables instanceof stdClass) {
            $variables = (array) $variables;
        } elseif ($variables instanceof Traversable) {
            $variables = iterator_to_array($variables);
        } elseif (! is_array($variables)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid variables provided; must be an array or Traversable '
                . 'or instance of stdClass, "%s" received.',
                is_object($variables) ? get_class($variables) : gettype($variables)
            ));
        }
        $this->container = array_merge($this->container, $variables);

        return $this;
    }
1275229
protected function multiplyMatrix(Matrix $b) : Matrix
    {
        if ($this->n !== $b->m()) {
            throw new DimensionalityMismatchException('Vector A requires'
                . " $this->n rows but Matrix B has {$b->m()}.");
        }

        $c = [];

        foreach ($b as $i => $row) {
            $valueA = $this->a[$i];

            $temp = [];

            foreach ($row as $valueB) {
                $temp[] = $valueA * $valueB;
            }

            $c[] = $temp;
        }

        return Matrix::quick($c);
    }
1087005
public function pushAll(array $items) : Vector
    {
        $values = $this->_pushAll($items);
        $this->setValues($values);
        return $this;
    }
1152115
public function build(array $setTuples, $isRecursiveStep = false)
    {
        $countTuples = count($setTuples);

        if (1 === $countTuples) {
            return reset($setTuples);
        }

        if (0 === $countTuples) {
            throw new \InvalidArgumentException('The set builder requires a single array of one or more array sets.');
        }

        foreach ($setTuples as $tuple) {
            if (!is_array($tuple)) {
                throw new \InvalidArgumentException('The set builder requires a single array of one or more array sets.');
            }
        }

        $keys = array_keys($setTuples);

        $a = array_shift($setTuples);
        $k = array_shift($keys);

        $b = $this->build($setTuples, true);

        $result = [];

        foreach ($a as $valueA) {
            if ($valueA) {
                foreach ($b as $valueB) {
                    if ($isRecursiveStep) {
                        $result[] = array_merge([$valueA], (array) $valueB);
                    } else {
                        $result[] = [$k => $valueA] + array_combine($keys, (array) $valueB);
                    }
                }
            }
        }

        return $result;
    }
968952
public function merge(array $data) : Vector
    {
        $values = $this->_merge($data);
        $this->setValues($values);
        return $this;
    }
14908
public static function initialize(Dimension $dimension, Number $value): self
    {
        $rows = [];
        $count = $dimension->rows()->value();

        for ($i = 0; $i < $count; ++$i) {
            $rows[] = new RowVector(
                ...array_fill(
                    0,
                    $dimension->columns()->value(),
                    $value
                )
            );
        }

        return new self(...$rows);
    }
366479
public function pow($b)
    {
        switch (true) {
            case $b instanceof Vector:
                $c = $this->powVector($b);
                break;

            case $b instanceof Matrix:
                $c = $this->powMatrix($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->powScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot raise vector'
                    . ' to a power of a ' . gettype($b) . '.');
        }

        return $c;
    }
917448
public function push(... $items) : Vector
    {
        $values = $this->_pushAll($items);
        $this->setValues($values);
        return $this;
    }
655245
public function setVector($vector)
    {
        if (empty($vector)) {
            throw new \InvalidArgumentException(sprintf('Cvss vector "%s" is not valid.', $vector));
        }

        if (!preg_match('/^' . self::$vectorHead . '.*/mi', $vector)) {
            throw new \InvalidArgumentException((sprintf('Cvss vector "%s" is not valid. Must start with "%s"', $vector, self::$vectorHead)));
        }

        $this->vectorInputs = self::parseVector($vector);

        $resolver = $this->getInputLevelConfiguration();
        $this->vectorLevels = $resolver->resolve($this->vectorInputs);

        $this->calculate();
    }
739766
public function columns($columns)
    {
        if( is_array($columns) ||
            is_string($columns) ||
            $columns instanceof Expression ) {
            $this->columns = $columns;
        } else {
            throw new InvalidArgumentException('Invalid columns parameter');
        }
        return $this;
    }
104021
public static function stack(array $datasets) : self
    {
        $samples = $labels = [];

        foreach ($datasets as $dataset) {
            if (!$dataset instanceof self) {
                throw new InvalidArgumentException('Dataset must be'
                    . ' an instance of Labeled, ' . get_class($dataset)
                    . ' given.');
            }

            $samples = array_merge($samples, $dataset->samples());
            $labels = array_merge($labels, $dataset->labels());
        }

        return self::quick($samples, $labels);
    }
203487
public function asColumnVectors() : array
    {
        $vectors = [];

        foreach ($this->transpose() as $column) {
            $vectors[] = ColumnVector::quick($column);
        }

        return $vectors;
    }
71699
public function shift(& $item) : Vector
    {
        $values = $this->_shift($item);
        $this->setValues($values);
        return $this;
    }
570719
public function multiply(float $scale) : Vector
    {
        $result = [];

        foreach ($this->components as $i => $component) {
            $result[$i] = $component * $scale;
        }

        return new static($result);
    }
239489
public static function createFromArray(array $rows)
    {
        $matrix = new Matrix();

        foreach ($rows as $offset => $row) {
            $matrix->setRow($offset, Row::createFromArray($row));
        }

        return $matrix;
    }
1142610
public function setItems($items) {

      if (!is_array($items)) {
        throw new \InvalidArgumentException('You can set only array of items');
      }

      $this->items = $items;
      $this->rewind();
      return $this;
    }