Fast matrix generation in python, including python style and matlab style support
Project description
MatGen
介绍
在 Python 中快速构建矩阵的方法。
软件功能
基于 numpy.stack 的构造
提供了两个语法糖类,分别是 VerticalStacker 和 HorizontalStacker,以及对应的一个实例,分别是 v_ 和 h_。对 v_ 和 h_ 进行 __getitem__ 访问,效果完全等同于 numpy.vstack 和 numpy.hstack。
示例
>>>v_[np.array([1,2,3]), h_[[[4,5],[4,5]], [[6],[6]]], np.zeros((2,3)), np.eye(3)]
[[1. 2. 3.]
[4. 5. 6.]
[4. 5. 6.]
[0. 0. 0.]
[0. 0. 0.]
[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
基于 MATLAB 风格的解释器
提供一个函数 M_ 通过解析字符串的形式来构建矩阵,支持部分 MATLAB 语法和 Python 语法。该字符串的组成形式如下:
[* * ... *;
* * ... *;
... ;
* * ... *]
其中 * 代表一个元素,该元素可以是一个数字,可以是上述的矩阵(矩阵嵌套),还可以是一个 python 表达式。注意,如果该 python 表达式包含 [*] 符号,会使解释器产生误解(这是由于两种语言风格混合在一起导致的),例如 arr[1,2],解释器不知道这里是两个元素还是对 arr 的切片。如果你想表达这是一个 python 表达式,请用括号将它们包括起来,即写成 (arr[1,2])。
示例
>>>M_('[1 2 3; np.zeros((2, 2)), np.array([[1, 2]]).T]')
[[1. 2. 3.]
[0. 0. 1.]
[0. 0. 2.]]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matgen-0.1.1.tar.gz.
File metadata
- Download URL: matgen-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c030deb0f093b82bc24c21372e63cb5e3dde5e0998bcf79485a0f4f0c0e03c98
|
|
| MD5 |
2c6cfe7f59266c5170bf03899b1fd5db
|
|
| BLAKE2b-256 |
2b387989e5117059e4fdf32a77497219a737cf329a7fba3126384e0b308750bb
|
File details
Details for the file matgen-0.1.1-py3-none-any.whl.
File metadata
- Download URL: matgen-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62369f064137d289504abe0fa1d1a665897539182786b4d2415c148fc769db7a
|
|
| MD5 |
4f7bb0ad11b1597d4b58c8b0119d02a3
|
|
| BLAKE2b-256 |
fb6ca87e58ae6913a09b2bf513fe8e86e4a5563b9d348176f9fd9247f30300cc
|