Skip to content

Commit

Permalink
[Add] matrix_exp docs (#6414)
Browse files Browse the repository at this point in the history
  • Loading branch information
megemini authored Dec 22, 2023
1 parent b78e03f commit 04ca3dc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/paddle/linalg/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ paddle.linalg 目录下包含飞桨框架支持的线性代数相关 API。具
" :ref:`paddle.linalg.inv <cn_api_paddle_linalg_inv>` ", "计算方阵的逆矩阵"
" :ref:`paddle.linalg.pinv <cn_api_paddle_linalg_pinv>` ", "计算矩阵的广义逆"
" :ref:`paddle.linalg.cov <cn_api_paddle_linalg_cov>` ", "计算矩阵的协方差矩阵"
" :ref:`paddle.linalg.matrix_exp <cn_api_paddle_linalg_matrix_exp>` ", "计算方阵的矩阵指数"


.. _about_matrix_decompositions:
Expand Down
32 changes: 32 additions & 0 deletions docs/api/paddle/linalg/matrix_exp_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. _cn_api_paddle_linalg_matrix_exp:

matrix_exp
-------------------------------

.. py:function:: paddle.linalg.matrix_exp(x, name=None)
计算方阵的矩阵指数。

.. math::
exp(A) = \sum_{n=0}^\infty A^n/n!
输入的张量 ``x`` 应该是方阵,比如 ``(*, M, M)`` ,矩阵指数通过比例平方法的帕德近似计算而来。

[1] Nicholas J. Higham, The scaling and squaring method for the matrix exponential revisited.


参数
::::::::::::

- **x** (Tensor) - 输入张量,形状应该为 ``(*, M, M)`` , ``*`` 表示 0 或多个维度。数据类型为: ``float32``, ``float64`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与 ``x`` 的类型和形状相同。

代码示例
::::::::::

COPY-FROM: paddle.linalg.matrix_exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## [ 仅参数名不一致 ]torch.linalg.matrix_exp
### [torch.linalg.matrix_power](https://pytorch.org/docs/stable/generated/torch.linalg.matrix_exp.html#torch.linalg.matrix_exp)

```python
torch.linalg.matrix_exp(A)
```

### [paddle.linalg.matrix_exp](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/matrix_exp_cn.html)

```python
paddle.linalg.matrix_exp(x, name=None)
```

Pytorch 相比 Paddle 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| A | x | 输入的方阵,类型为 Tensor,仅参数名不一致。 |
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@
| ----- | ----------- | ----------------- | --- |
| REFERENCE-MAPPING-ITEM(`torch.linalg.svd`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.svd.md) |
| REFERENCE-MAPPING-ITEM(`torch.linalg.matrix_power`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matrix_power.md) |
| REFERENCE-MAPPING-ITEM(`torch.linalg.matrix_exp`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matrix_exp.md) |
| REFERENCE-MAPPING-ITEM(`torch.linalg.cholesky`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.cholesky.md) |
| REFERENCE-MAPPING-ITEM(`torch.linalg.matrix_rank`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matrix_rank.md) |
| REFERENCE-MAPPING-ITEM(`torch.linalg.cross`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.cross.md) |
Expand Down

0 comments on commit 04ca3dc

Please sign in to comment.