Unverified Commit 41b41809 authored by Hongzhi (Steve), Chen's avatar Hongzhi (Steve), Chen Committed by GitHub
Browse files
parent 9c647d80
...@@ -161,6 +161,8 @@ Elementwise Operators ...@@ -161,6 +161,8 @@ Elementwise Operators
add add
sub sub
mul
div
power power
Matrix Multiplication Matrix Multiplication
......
...@@ -11,13 +11,13 @@ __all__ = ["add", "sub", "mul", "div", "power"] ...@@ -11,13 +11,13 @@ __all__ = ["add", "sub", "mul", "div", "power"]
def add( def add(
A: Union[DiagMatrix, SparseMatrix], B: Union[DiagMatrix, SparseMatrix] A: Union[DiagMatrix, SparseMatrix], B: Union[DiagMatrix, SparseMatrix]
) -> Union[DiagMatrix, SparseMatrix]: ) -> Union[DiagMatrix, SparseMatrix]:
"""Elementwise additions for ``DiagMatrix`` and ``SparseMatrix``. This is r"""Elementwise additions for ``DiagMatrix`` and ``SparseMatrix``,
equivalent to ``A + B``. equivalent to ``A + B``.
The supported combinations are shown as follows. The supported combinations are shown as follows.
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| A \\ B | DiagMatrix | SparseMatrix | scalar | | A \ B | DiagMatrix | SparseMatrix | scalar |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| DiagMatrix | ✅ | ✅ | 🚫 | | DiagMatrix | ✅ | ✅ | 🚫 |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
...@@ -56,13 +56,13 @@ def add( ...@@ -56,13 +56,13 @@ def add(
def sub(A: Union[DiagMatrix], B: Union[DiagMatrix]) -> Union[DiagMatrix]: def sub(A: Union[DiagMatrix], B: Union[DiagMatrix]) -> Union[DiagMatrix]:
"""Elementwise subtraction for ``DiagMatrix`` and ``SparseMatrix``. This is r"""Elementwise subtraction for ``DiagMatrix`` and ``SparseMatrix``. This is
equivalent to ``A - B``. equivalent to ``A - B``.
The supported combinations are shown as follows. The supported combinations are shown as follows.
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| A \\ B | DiagMatrix | SparseMatrix | scalar | | A \ B | DiagMatrix | SparseMatrix | scalar |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| DiagMatrix | ✅ | 🚫 | 🚫 | | DiagMatrix | ✅ | 🚫 | 🚫 |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
...@@ -98,13 +98,13 @@ def mul( ...@@ -98,13 +98,13 @@ def mul(
A: Union[SparseMatrix, DiagMatrix, float, int], A: Union[SparseMatrix, DiagMatrix, float, int],
B: Union[SparseMatrix, DiagMatrix, float, int], B: Union[SparseMatrix, DiagMatrix, float, int],
) -> Union[SparseMatrix, DiagMatrix]: ) -> Union[SparseMatrix, DiagMatrix]:
"""Elementwise multiplication for ``DiagMatrix`` and ``SparseMatrix``. This r"""Elementwise multiplication for ``DiagMatrix`` and ``SparseMatrix``,
is equivalent to ``A * B``. equivalent to ``A * B``.
The supported combinations are shown as follows. The supported combinations are shown as follows.
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| A \\ B | DiagMatrix | SparseMatrix | scalar | | A \ B | DiagMatrix | SparseMatrix | scalar |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| DiagMatrix | ✅ | 🚫 | ✅ | | DiagMatrix | ✅ | 🚫 | ✅ |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
...@@ -153,13 +153,13 @@ def mul( ...@@ -153,13 +153,13 @@ def mul(
def div( def div(
A: Union[DiagMatrix], B: Union[DiagMatrix, float, int] A: Union[DiagMatrix], B: Union[DiagMatrix, float, int]
) -> Union[DiagMatrix]: ) -> Union[DiagMatrix]:
"""Elementwise division for ``DiagMatrix`` and ``SparseMatrix``. This is r"""Elementwise division for ``DiagMatrix`` and ``SparseMatrix``, equivalent
equivalent to ``A / B``. to ``A / B``.
The supported combinations are shown as follows. The supported combinations are shown as follows.
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| A \\ B | DiagMatrix | SparseMatrix | scalar | | A \ B | DiagMatrix | SparseMatrix | scalar |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| DiagMatrix | ✅ | 🚫 | ✅ | | DiagMatrix | ✅ | 🚫 | ✅ |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
...@@ -199,13 +199,13 @@ def div( ...@@ -199,13 +199,13 @@ def div(
def power( def power(
A: Union[SparseMatrix, DiagMatrix], scalar: Union[float, int] A: Union[SparseMatrix, DiagMatrix], scalar: Union[float, int]
) -> Union[SparseMatrix, DiagMatrix]: ) -> Union[SparseMatrix, DiagMatrix]:
"""Elementwise exponentiation for ``DiagMatrix`` and ``SparseMatrix``. This r"""Elementwise exponentiation for ``DiagMatrix`` and ``SparseMatrix``,
is equivalent to ``A ** scalar``. equivalent to ``A ** scalar``.
The supported combinations are shown as follows. The supported combinations are shown as follows.
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| A \\ B | DiagMatrix | SparseMatrix | scalar | | A \ B | DiagMatrix | SparseMatrix | scalar |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
| DiagMatrix | 🚫 | 🚫 | ✅ | | DiagMatrix | 🚫 | 🚫 | ✅ |
+--------------+------------+--------------+--------+ +--------------+------------+--------------+--------+
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment