Calculate the cross product between two 3 dimensional vectors.

@param \Rubix\Tensor\Vector $b
@throws \Rubix\Tensor\Exceptions\DimensionalityMismatchException
@return self
356737
public function cross(Vector $b) : self
    {
        if ($this->n !== 3 or $b->size() !== 3) {
            throw new DimensionalityMismatchException('Cross product is'
                . ' only defined for vectors of 3 dimensions.');
        }

        $c = [];

        $c[] = ($this->a[1] * $b[2]) - ($this->a[2] * $b[1]);
        $c[] = ($this->a[2] * $b[0]) - ($this->a[0] * $b[2]);
        $c[] = ($this->a[0] * $b[1]) - ($this->a[1] * $b[0]);

        return static::quick($c);
    }
574067
public function outerProduct(Vector $other): Matrix
    {
        $literal = [];

        for ($i = 0; $i < $this->getSize(); $i++) {
            for ($j = 0; $j < $other->getSize(); $j++) {
                $literal[$i][$j] = $this->toArray()[$i] * $other->toArray()[$j];
            }
        }

        return new Matrix($literal);
    }
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);
    }
378144
public function checkMatrixDimensions($B = null) {
		if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
			if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
				return true;
			} else {
				throw new PHPExcel_Calculation_Exception(self::MatrixDimensionException);
			}
		} else {
			throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
		}
	}
1151953
public function diagonalAsVector() : Vector
    {
        if (!$this->isSquare()) {
            throw new RuntimeException('Cannot trace diagonal of a'
                . ' non square matrix.');
        }

        $b = [];

        for ($i = 0; $i < $this->m; $i++) {
            $b[] = $this->a[$i][$i];
        }

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

        $c = [];

        foreach ($b as $row) {
            $temp = [];

            foreach ($row as $j => $value) {
                $temp[] = $this->a[$j] * $value;
            }

            $c[] = $temp;
        }

        return Matrix::quick($c);
    }
608020
public function initFromRgb($r, $g, $b)
    {
        $this->r = (int) $r;
        $this->g = (int) $g;
        $this->b = (int) $b;
        $this->a = 0;

        return $this;
    }
901567
def cross(self, vec):
        """"""
        if not isinstance(vec, self.__class__):
            raise TypeError('Cross product operand must be a vector')
        return self.__class__(np.cross(self, vec))
409635
public Vec multiply(Vec b)
    {
        DenseVector result = new  DenseVector(rows());
        multiply(b, 1.0, result);
        return result;
    }
1002022
def cross(self, vec):
        """"""
        if not isinstance(vec, Vector3Array):
            raise TypeError('Cross product operand must be a Vector3Array')
        if self.nV != 1 and vec.nV != 1 and self.nV != vec.nV:
            raise ValueError('Cross product operands must have the same '
                             'number of elements.')
        return Vector3Array(np.cross(self, vec))
510117
public double dot(Vector b) {
        if ((b == null) || (size != b.size)) return Double.NaN;

        double result = 0;
        int i;
        for (i = 0; i < size; i++)
            result += vector[i] * b.vector[i];
        return result;
    }

    /**
     * Cross product, only well definited in R^3
     */
    public Vector cross(Vector b) {
        if ((b == null) || (size != 3) || (b.size != 3)) return null;

        Vector result = new Vector(3);
        result.vector[0] = vector[1] * b.vector[2] - vector[2] * b.vector[1];
        result.vector[1] = vector[2] * b.vector[0] - vector[0] * b.vector[2];
        result.vector[2] = vector[0] * b.vector[1] - vector[1] * b.vector[0];
        return result;
    }

    /**
     * Return the length from this vector
     */
    public double length() {
        double value = 0;
        for (int i = 0; i < size; i++)
            value += vector[i] * vector[i];
        return Math.sqrt(value);
    }

    /**
     * Normalize this vector
     */
    public Vector normalize() {
        Vector result = new Vector(size);
        double length = length();
        for (int i = 0; i < size; i++)
            result.vector[i] = vector[i] / length;
        return result;
    }

    /**
     * Negates this vector
     */
    public Vector negate() {
        Vector result = new Vector(size);
        for (int i = 0; i < size; i++)
            result.vector[i] = -vector[i];
        return result;
    }

    /**
     *  Copy a vector
     */
    public Vector duplicate() {
        Vector result = new Vector(size);
        int i;
        for (i = 0; i < size; i++)
            result.vector[i] = vector[i];
        return result;
    }

    /**
     *  Return a vector as a string
     */
    @Override
    public String toString() {
        int i;
        StringBuffer str = new StringBuffer();
        str.append("[ ");
        for (i = 0; i < (size - 1); i++)
            str.append(vector[i] + " ");
        str.append(vector[size - 1] + " ]");
        return str.toString();
    }
}
1339486
protected function multiplyColumnVector(ColumnVector $b) : self
    {
        if ($b->m() !== $this->m) {
            throw new DimensionalityMismatchException('Matrix A requires'
                . " $this->m rows but Vector B has {$b->m()}.");
        }

        $c = [];

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

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

            $c[] = $temp;
        }

        return self::quick($c);
    }
912559
public static function cross(Vector3D $value1, Vector3D $value2) : Vector3D {
        return new Vector3D(
            ($value1->getY() * $value2->getZ()) - ($value1->getZ() * $value2->getY()),
            -(($value1->getX() * $value2->getZ()) - ($value1->getZ() * $value2->getX())),
            ($value1->getX() * $value2->getY()) - ($value1->getY() * $value2->getX())
        );
    }
1344386
public Vector add(Vector b) {
        if ((b == null) || (size != b.size)) return null;

        int i;
        Vector result = new Vector(size);
        for (i = 0; i < size; i++)
            result.vector[i] = vector[i] + b.vector[i];
        return result;
    }
85627
def cross(vec1, vec2):
        """"""
        if isinstance(vec1, Vector3) and isinstance(vec2, Vector3):
            vec3 = Vector3()
            vec3.x = (vec1.y * vec2.z) - (vec1.z * vec2.y)
            vec3.y = (vec1.z * vec2.x) - (vec1.x * vec2.z)
            vec3.z = (vec1.x * vec2.y) - (vec1.y * vec2.x)
            return vec3
        else:
            raise TypeError("vec1 and vec2 must be Vector3's")
1194756
public function rref() : self
    {
        [$b, $swaps] = $this->ref();

        $b = $b->asArray();

        $row = $col = 0;

        while ($row < $this->m and $col < $this->n) {
            $t = $b[$row];

            if (abs($t[$col]) == 0) {
                $col++;

                continue 1;
            }

            $divisor = $t[$col];

            if ($divisor != 1) {
                for ($i = 0; $i < $this->n; $i++) {
                    $t[$i] /= $divisor;
                }
            }

            for ($i = $row - 1; $i >= 0; $i--) {
                $scale = $b[$i][$col];

                if ($scale != 0) {
                    for ($j = 0; $j < $this->n; $j++) {
                        $b[$i][$j] += -$scale * $t[$j];
                    }
                }
            }

            $b[$row] = $t;

            $row++;
            $col++;
        }

        return self::quick($b);
    }
190206
public function compute(array $a, array $b) : float
    {
        $a = Vector::quick($a);
        $b = Vector::quick($b);

        return 1. - ($a->dot($b) / ($a->l2Norm() * $b->l2Norm()));
    }